Completed
Push — EZP-31287 ( fe8c5c...af9523 )
by
unknown
34:01
created

GeneralSlotFactoryTest::testValidSlot()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 1
dl 0
loc 7
rs 10
c 0
b 0
f 0
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) {
0 ignored issues
show
Coding Style Comprehensibility introduced by
Consider adding a comment why this CATCH block is empty.
Loading history...
54
            }
55
        }
56
    }
57
58
    private function setUpFactory($slots)
59
    {
60
        return new SignalSlot\SlotFactory\GeneralSlotFactory($slots);
0 ignored issues
show
Deprecated Code introduced by
The class eZ\Publish\Core\SignalSl...tory\GeneralSlotFactory has been deprecated with message: Slot factories are not needed any more.

This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.

Loading history...
61
    }
62
}
63