-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Expand file tree
/
Copy pathVideosModuleUnitTestCase.php
More file actions
42 lines (35 loc) · 1.18 KB
/
VideosModuleUnitTestCase.php
File metadata and controls
42 lines (35 loc) · 1.18 KB
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
<?php
declare(strict_types=1);
namespace CodelyTv\Tests\Mooc\Videos;
use CodelyTv\Mooc\Courses\Domain\Course;
use CodelyTv\Mooc\Courses\Domain\CourseRepository;
use CodelyTv\Mooc\Shared\Domain\Courses\CourseId;
use CodelyTv\Mooc\Videos\Domain\Video;
use CodelyTv\Mooc\Videos\Domain\VideoId;
use CodelyTv\Mooc\Videos\Domain\VideoRepository;
use CodelyTv\Tests\Shared\Infrastructure\PhpUnit\UnitTestCase;
use Mockery\MockInterface;
abstract class VideosModuleUnitTestCase extends UnitTestCase
{
private VideoRepository|MockInterface|null $repository;
protected function shouldSave(Video $video): void
{
$this->repository()
->shouldReceive('save')
->with($this->similarTo($video))
->once()
->andReturnNull();
}
protected function shouldSearch(VideoId $id, ?Video $video): void
{
$this->repository()
->shouldReceive('search')
->with($this->similarTo($id))
->once()
->andReturn($video);
}
protected function repository(): VideoRepository|MockInterface
{
return $this->repository = $this->repository ?? $this->mock(VideoRepository::class);
}
}