Skip to content

Commit

Permalink
Mock MjlmService in tests (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
pa-cholek authored Dec 15, 2021
1 parent 425f589 commit 41dce08
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
11 changes: 11 additions & 0 deletions tests/Api/AuthTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
use EscolaLms\TemplatesEmail\Core\EmailMailable;
use EscolaLms\TemplatesEmail\Events\Registered;
use EscolaLms\TemplatesEmail\Notifications\ResetPassword;
use EscolaLms\TemplatesEmail\Services\Contracts\MjmlServiceContract;
use EscolaLms\TemplatesEmail\Services\MjmlService;
use EscolaLms\TemplatesEmail\Tests\TestCase;
use Illuminate\Auth\Notifications\ResetPassword as LaravelResetPassword;
use Illuminate\Auth\Notifications\VerifyEmail;
Expand All @@ -18,6 +20,8 @@
use Illuminate\Support\Facades\Event;
use Illuminate\Support\Facades\Mail;
use Illuminate\Support\Facades\Notification;
use Mockery;
use Mockery\MockInterface;

class AuthTest extends TestCase
{
Expand All @@ -29,6 +33,13 @@ public function setUp(): void
if (!class_exists(\EscolaLms\Auth\EscolaLmsAuthServiceProvider::class)) {
$this->markTestSkipped('Auth package not installed');
}

$this->instance(
MjmlServiceContract::class,
Mockery::mock(MjmlService::class, function (MockInterface $mock) {
$mock->shouldReceive('render')->once()->andReturnArg(0);
})
);
}

public function testVerifyEmail()
Expand Down
11 changes: 11 additions & 0 deletions tests/Api/CoursesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,17 @@
use EscolaLms\Courses\ValueObjects\CourseProgressCollection;
use EscolaLms\Templates\Listeners\TemplateEventListener;
use EscolaLms\TemplatesEmail\Core\EmailMailable;
use EscolaLms\TemplatesEmail\Services\Contracts\MjmlServiceContract;
use EscolaLms\TemplatesEmail\Services\MjmlService;
use EscolaLms\TemplatesEmail\Tests\TestCase;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Foundation\Testing\WithoutMiddleware;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\Event;
use Illuminate\Support\Facades\Mail;
use Illuminate\Support\Facades\Notification;
use Mockery;
use Mockery\MockInterface;

class CoursesTest extends TestCase
{
Expand All @@ -40,6 +44,13 @@ public function setUp(): void
if (!class_exists(\EscolaLms\Scorm\EscolaLmsScormServiceProvider::class)) {
$this->markTestSkipped('Scorm package not installed');
}

$this->instance(
MjmlServiceContract::class,
Mockery::mock(MjmlService::class, function (MockInterface $mock) {
$mock->shouldReceive('render')->once()->andReturnArg(0);
})
);
}

public function testDeadlineNotification()
Expand Down

0 comments on commit 41dce08

Please sign in to comment.