FetchRecommendationsForPostTest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 16
dl 0
loc 31
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 6 1
A testExecute() 0 14 1
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