Completed
Push — master ( 618420...452863 )
by Níckolas Daniel
05:07
created

FetchRecommendationsForPostTest::testExecute()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 14
rs 9.9332
c 0
b 0
f 0
cc 1
nc 1
nop 0
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);
1 ignored issue
show
Documentation Bug introduced by
It seems like $this->prophesize(PODEnt...\Recommendation::class) of type Prophecy\Prophecy\ObjectProphecy is incompatible with the declared type PODEntender\Domain\Service\Post\Recommendation of property $recommendationService.

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..

Loading history...
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]));
1 ignored issue
show
Bug introduced by
The method willReturn() does not exist on PODEntender\Domain\Model...\AudioEpisodeCollection. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

37
            ->/** @scrutinizer ignore-call */ willReturn(new AudioEpisodeCollection([$episode01, $episode02, $episode03, $episode04]));
Loading history...
38
39
        $result = $this->fetchRecommendationsForPostService->execute($referencePost, 2);
40
        $this->assertCount(2, $result);
41
    }
42
}
43