|
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); |
|
|
|
|
|
|
81
|
|
|
} |
|
82
|
|
|
} |
|
83
|
|
|
|
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:
The
getFirstName()method in theSoncalls the wrong method in the parent class.