-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
Copy pathCourseFinderTest.php
47 lines (33 loc) · 1.19 KB
/
CourseFinderTest.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
38
39
40
41
42
43
44
45
46
47
<?php
declare(strict_types=1);
namespace CodelyTv\Tests\Mooc\Courses\Application\Find;
use CodelyTv\Mooc\Courses\Application\Find\CourseFinder;
use CodelyTv\Mooc\Courses\Domain\CourseNotExist;
use CodelyTv\Tests\Mooc\Courses\CoursesModuleUnitTestCase;
use CodelyTv\Tests\Mooc\Courses\Domain\CourseIdMother;
use CodelyTv\Tests\Mooc\Courses\Domain\CourseMother;
class CourseFinderTest extends CoursesModuleUnitTestCase
{
private CourseFinder|null $finder;
protected function setUp(): void
{
parent::setUp();
$this->finder = new CourseFinder($this->repository());
}
/** @test */
public function it_should_throw_an_exception_when_the_course_not_exist(): void
{
$this->expectException(CourseNotExist::class);
$id = CourseIdMother::create();
$this->shouldSearch($id, null);
$this->finder->__invoke($id);
}
/** @test */
public function it_should_find_an_existing_courses(): void
{
$course = CourseMother::create();
$this->shouldSearch($course->id(), $course);
$courseFromRepository = $this->finder->__invoke($course->id());
$this->assertEquals($courseFromRepository, $course);
}
}