|
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\Service\Post\Recommendation; |
|
9
|
|
|
|
|
10
|
|
|
class FetchRecommendationsForPostTest extends TestCase |
|
11
|
|
|
{ |
|
12
|
|
|
/** @var Recommendation */ |
|
13
|
|
|
private $recommendationService; |
|
14
|
|
|
|
|
15
|
|
|
/** @var FetchRecommendationsForPost */ |
|
16
|
|
|
private $fetchRecommendationsForPostService; |
|
17
|
|
|
|
|
18
|
|
|
protected function setUp(): void |
|
19
|
|
|
{ |
|
20
|
|
|
$this->recommendationService = $this->prophesize(Recommendation::class); |
|
|
|
|
|
|
21
|
|
|
|
|
22
|
|
|
$this->fetchRecommendationsForPostService = new FetchRecommendationsForPost( |
|
23
|
|
|
$this->recommendationService->reveal() |
|
24
|
|
|
); |
|
25
|
|
|
} |
|
26
|
|
|
|
|
27
|
|
|
public function testExecute(): void |
|
28
|
|
|
{ |
|
29
|
|
|
$referencePost = $this->prophesize(AudioEpisode::class)->reveal(); |
|
30
|
|
|
$episode01 = $this->prophesize(AudioEpisode::class)->reveal(); |
|
31
|
|
|
$episode02 = $this->prophesize(AudioEpisode::class)->reveal(); |
|
32
|
|
|
$episode03 = $this->prophesize(AudioEpisode::class)->reveal(); |
|
33
|
|
|
$episode04 = $this->prophesize(AudioEpisode::class)->reveal(); |
|
34
|
|
|
|
|
35
|
|
|
$this->recommendationService |
|
36
|
|
|
->recommendEpisodesForPost($referencePost, 2) |
|
37
|
|
|
->willReturn(new AudioEpisodeCollection([$episode01, $episode02, $episode03, $episode04])); |
|
|
|
|
|
|
38
|
|
|
|
|
39
|
|
|
$result = $this->fetchRecommendationsForPostService->execute($referencePost, 2); |
|
40
|
|
|
$this->assertCount(2, $result); |
|
41
|
|
|
} |
|
42
|
|
|
} |
|
43
|
|
|
|
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..