Completed
Push — feature-EZP-25696 ( 1cfd30...140426 )
by André
24:27
created

testDoesNotReceiveOtherSignals()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 6
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 11
rs 9.4285
1
<?php
2
3
/**
4
 * This file is part of the eZ Publish Kernel package.
5
 *
6
 * @copyright Copyright (C) eZ Systems AS. All rights reserved.
7
 * @license For full copyright and license information view LICENSE file distributed with this source code.
8
 */
9
namespace eZ\Publish\Core\MVC\Symfony\Cache\Tests\Http\SignalSlot;
10
11
use eZ\Publish\Core\SignalSlot\Signal\ContentService\PublishVersionSignal;
12
use eZ\Publish\SPI\Persistence\Content\Location;
13
14
class PublishVersionSlotTest extends AbstractContentSlotTest
15
{
16
    protected $locationId = 45;
17
    protected $parentLocationId = 32;
18
19
    /** @var \eZ\Publish\SPI\Persistence\Content\Location\Handler|\PHPUnit_Framework_MockObject_MockObject */
20
    protected $spiLocationHandlerMock;
21
22
    public function getSlotClass()
23
    {
24
        return 'eZ\Publish\Core\MVC\Symfony\Cache\Http\SignalSlot\PublishVersionSlot';
25
    }
26
27
    public function createSignal()
28
    {
29
        return new PublishVersionSignal(['contentId' => $this->contentId]);
30
    }
31
32
    public function getReceivedSignalClasses()
33
    {
34
        return ['eZ\Publish\Core\SignalSlot\Signal\ContentService\PublishVersionSignal'];
35
    }
36
37
    protected function createSlot()
38
    {
39
        $class = $this->getSlotClass();
40
        if ($this->spiLocationHandlerMock === null) {
41
            $this->spiLocationHandlerMock = $this->getMock('eZ\Publish\SPI\Persistence\Content\Location\Handler');
42
        }
43
44
        return new $class($this->purgeClientMock, $this->spiLocationHandlerMock);
45
    }
46
47
    /**
48
     * @dataProvider getUnreceivedSignals
49
     */
50
    public function testDoesNotReceiveOtherSignals($signal)
51
    {
52
        $this->purgeClientMock->expects($this->never())->method('purge');
53
        $this->purgeClientMock->expects($this->never())->method('purgeByTags');
54
        $this->purgeClientMock->expects($this->never())->method('purgeAll');
55
56
        $this->spiLocationHandlerMock->expects($this->never())->method('loadLocationsByContent');
57
58
59
        $this->slot->receive($signal);
60
    }
61
62
    /**
63
     * @dataProvider getReceivedSignals
64
     */
65
    public function testReceivePurgesCacheForTags($signal)
66
    {
67
        $this->spiLocationHandlerMock
68
            ->expects($this->once())
69
            ->method('loadLocationsByContent')
70
            ->with($this->contentId)
71
            ->willReturn(
72
                [
73
                    new Location(['id' => $this->locationId, 'parentId' => $this->parentLocationId])
74
                ]
75
            );
76
77
78
        $this->purgeClientMock->expects($this->once())->method('purgeByTags')->with($this->generateTags());
79
        $this->purgeClientMock->expects($this->never())->method('purgeAll');
80
        parent::receive($signal);
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (receive() instead of testReceivePurgesCacheForTags()). Are you sure this is correct? If so, you might want to change this to $this->receive().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
81
    }
82
}
83