Completed
Push — master ( 22c070...618420 )
by Níckolas Daniel
05:00
created

FetchExistentCategoryNamesTest::setUp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 5
rs 10
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\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);
1 ignored issue
show
Documentation Bug introduced by
It seems like $this->prophesize(PODEnt...\PostRepository::class) of type Prophecy\Prophecy\ObjectProphecy is incompatible with the declared type PODEntender\Domain\Model\Post\PostRepository of property $postRepository.

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
        $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([
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

40
        $this->postRepository->withAudio()->/** @scrutinizer ignore-call */ willReturn(new AudioEpisodeCollection([
Loading history...
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