|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* @copyright Copyright (C) eZ Systems AS. All rights reserved. |
|
5
|
|
|
* @license For full copyright and license information view LICENSE file distributed with this source code. |
|
6
|
|
|
*/ |
|
7
|
|
|
namespace eZ\Publish\Core\SignalSlot\Tests\SlotFactory; |
|
8
|
|
|
|
|
9
|
|
|
use eZ\Publish\Core\SignalSlot; |
|
10
|
|
|
use eZ\Publish\Core\Base\Exceptions\NotFoundException; |
|
11
|
|
|
use PHPUnit\Framework\TestCase; |
|
12
|
|
|
|
|
13
|
|
|
/** |
|
14
|
|
|
* @group signalSlot |
|
15
|
|
|
* @covers \eZ\Publish\Core\SignalSlot\SlotFactory\GeneralSlotFactory |
|
16
|
|
|
*/ |
|
17
|
|
|
class GeneralSlotFactoryTest extends TestCase |
|
18
|
|
|
{ |
|
19
|
|
|
public function providerForFactoryTests() |
|
20
|
|
|
{ |
|
21
|
|
|
return [ |
|
22
|
|
|
[['slot1' => true, 'slot2' => true]], |
|
23
|
|
|
[ |
|
24
|
|
|
[ |
|
25
|
|
|
'slot1' => $this->createMock(SignalSlot\Slot::class), |
|
26
|
|
|
'slot2' => $this->createMock(SignalSlot\Slot::class), |
|
27
|
|
|
], |
|
28
|
|
|
], |
|
29
|
|
|
]; |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* @dataProvider providerForFactoryTests |
|
34
|
|
|
*/ |
|
35
|
|
|
public function testValidSlot($slots) |
|
36
|
|
|
{ |
|
37
|
|
|
$factory = $this->setUpFactory($slots); |
|
38
|
|
|
foreach ($slots as $slotIdentifier => $slotValue) { |
|
39
|
|
|
$this->assertEquals($slotValue, $factory->getSlot($slotIdentifier)); |
|
40
|
|
|
} |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* @dataProvider providerForFactoryTests |
|
45
|
|
|
*/ |
|
46
|
|
|
public function testInValidSlot($slots) |
|
47
|
|
|
{ |
|
48
|
|
|
$factory = $this->setUpFactory($slots); |
|
49
|
|
|
foreach (array_keys($slots) as $slotIdentifier) { |
|
50
|
|
|
try { |
|
51
|
|
|
$factory->getSlot($slotIdentifier . '42'); |
|
52
|
|
|
$this->fail('expected NotFoundException '); |
|
53
|
|
|
} catch (NotFoundException $e) { |
|
|
|
|
|
|
54
|
|
|
} |
|
55
|
|
|
} |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
private function setUpFactory($slots) |
|
59
|
|
|
{ |
|
60
|
|
|
return new SignalSlot\SlotFactory\GeneralSlotFactory($slots); |
|
|
|
|
|
|
61
|
|
|
} |
|
62
|
|
|
} |
|
63
|
|
|
|