-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
Copy pathCreateCourseCommandHandlerTest.php
37 lines (27 loc) · 1.13 KB
/
CreateCourseCommandHandlerTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
declare(strict_types=1);
namespace CodelyTv\Tests\Mooc\Courses\Application\Create;
use CodelyTv\Mooc\Courses\Application\Create\CourseCreator;
use CodelyTv\Mooc\Courses\Application\Create\CreateCourseCommandHandler;
use CodelyTv\Tests\Mooc\Courses\CoursesModuleUnitTestCase;
use CodelyTv\Tests\Mooc\Courses\Domain\CourseCreatedDomainEventMother;
use CodelyTv\Tests\Mooc\Courses\Domain\CourseMother;
final class CreateCourseCommandHandlerTest extends CoursesModuleUnitTestCase
{
private CreateCourseCommandHandler|null $handler;
protected function setUp(): void
{
parent::setUp();
$this->handler = new CreateCourseCommandHandler(new CourseCreator($this->repository(), $this->eventBus()));
}
/** @test */
public function it_should_create_a_valid_course(): void
{
$command = CreateCourseCommandMother::create();
$course = CourseMother::fromRequest($command);
$domainEvent = CourseCreatedDomainEventMother::fromCourse($course);
$this->shouldSave($course);
$this->shouldPublishDomainEvent($domainEvent);
$this->dispatch($command, $this->handler);
}
}