|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace PODEntender\Application\Service\Post; |
|
4
|
|
|
|
|
5
|
|
|
use PHPUnit\Framework\TestCase; |
|
6
|
|
|
use PODEntender\Domain\Model\Post\AudioEpisode; |
|
7
|
|
|
use PODEntender\Domain\Model\Post\AudioEpisodeCollection; |
|
8
|
|
|
use PODEntender\Domain\Model\Post\PostRepository; |
|
9
|
|
|
|
|
10
|
|
|
class FetchExistentCategoryNamesTest extends TestCase |
|
11
|
|
|
{ |
|
12
|
|
|
/** @var PostRepository */ |
|
13
|
|
|
private $postRepository; |
|
14
|
|
|
|
|
15
|
|
|
/** @var FetchExistentCategoryNames */ |
|
16
|
|
|
private $fetchExistentCategoryNames; |
|
17
|
|
|
|
|
18
|
|
|
protected function setUp(): void |
|
19
|
|
|
{ |
|
20
|
|
|
$this->postRepository = $this->prophesize(PostRepository::class); |
|
21
|
|
|
$this->fetchExistentCategoryNames = new FetchExistentCategoryNames( |
|
22
|
|
|
$this->postRepository->reveal() |
|
23
|
|
|
); |
|
24
|
|
|
} |
|
25
|
|
|
|
|
26
|
|
|
public function testExecute(): void |
|
27
|
|
|
{ |
|
28
|
|
|
$episode01 = $this->prophesize(AudioEpisode::class); |
|
29
|
|
|
$episode01->category()->willReturn('Entrevista'); |
|
30
|
|
|
|
|
31
|
|
|
$episode02 = $this->prophesize(AudioEpisode::class); |
|
32
|
|
|
$episode02->category()->willReturn('Drops'); |
|
33
|
|
|
|
|
34
|
|
|
$episode03 = $this->prophesize(AudioEpisode::class); |
|
35
|
|
|
$episode03->category()->willReturn('News'); |
|
36
|
|
|
|
|
37
|
|
|
$episode04 = $this->prophesize(AudioEpisode::class); |
|
38
|
|
|
$episode04->category()->willReturn('Entrevista'); |
|
39
|
|
|
|
|
40
|
|
|
$this->postRepository->withAudio()->willReturn(new AudioEpisodeCollection([ |
|
41
|
|
|
$episode01->reveal(), |
|
42
|
|
|
$episode02->reveal(), |
|
43
|
|
|
$episode03->reveal(), |
|
44
|
|
|
$episode04->reveal(), |
|
45
|
|
|
])); |
|
46
|
|
|
|
|
47
|
|
|
$categoryNames = $this->fetchExistentCategoryNames->execute(); |
|
48
|
|
|
$this->assertCount(3, $categoryNames); |
|
49
|
|
|
$this->assertContains('Entrevista', $categoryNames); |
|
50
|
|
|
$this->assertContains('Drops', $categoryNames); |
|
51
|
|
|
$this->assertContains('News', $categoryNames); |
|
52
|
|
|
} |
|
53
|
|
|
} |
|
54
|
|
|
|