1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* This file is part of slick/configuration |
5
|
|
|
* |
6
|
|
|
* For the full copyright and license information, please view the LICENSE |
7
|
|
|
* file that was distributed with this source code. |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
namespace spec\Slick\Configuration\Common; |
11
|
|
|
|
12
|
|
|
use Slick\Configuration\Common\PriorityList; |
13
|
|
|
use PhpSpec\ObjectBehavior; |
14
|
|
|
use Slick\Configuration\ConfigurationInterface; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* PriorityListSpec specs |
18
|
|
|
* |
19
|
|
|
* @package spec\Slick\Configuration\Common |
20
|
|
|
*/ |
21
|
|
|
class PriorityListSpec extends ObjectBehavior |
22
|
|
|
{ |
23
|
|
|
function it_is_initializable() |
|
|
|
|
24
|
|
|
{ |
25
|
|
|
$this->shouldHaveType(PriorityList::class); |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
function it_can_be_used_as_an_array() |
29
|
|
|
{ |
30
|
|
|
$this->shouldBeAnInstanceOf(\ArrayAccess::class); |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
function its_an_iterable() |
34
|
|
|
{ |
35
|
|
|
$this->shouldImplement(\IteratorAggregate::class); |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
function it_can_insert_objects(ConfigurationInterface $driver) |
39
|
|
|
{ |
40
|
|
|
$this->insert($driver, 10)->shouldBe($this->getWrappedObject()); |
|
|
|
|
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
function it_can_be_converted_to_array() |
44
|
|
|
{ |
45
|
|
|
$this->asArray()->shouldBeArray(); |
|
|
|
|
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
function it_adds_elements_with_a_given_priority( |
49
|
|
|
ConfigurationInterface $driver1, |
50
|
|
|
ConfigurationInterface $driver2, |
51
|
|
|
ConfigurationInterface $driver3, |
52
|
|
|
) { |
53
|
|
|
|
54
|
|
|
$this->insert($driver1, 10) |
55
|
|
|
->insert($driver2, 20) |
56
|
|
|
->insert($driver3, 15); |
57
|
|
|
$array = $this->asArray(); |
58
|
|
|
$array[2]->shouldBe($driver2); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
function it_can_be_counted( |
62
|
|
|
ConfigurationInterface $driver1, |
63
|
|
|
ConfigurationInterface $driver2, |
64
|
|
|
ConfigurationInterface $driver3 |
65
|
|
|
) { |
66
|
|
|
$this->insert($driver1, 10) |
67
|
|
|
->insert($driver2, 20) |
68
|
|
|
->insert($driver3, 15); |
69
|
|
|
$this->shouldBeAnInstanceOf(\Countable::class); |
70
|
|
|
$this->count()->shouldBe(3); |
|
|
|
|
71
|
|
|
} |
72
|
|
|
} |
73
|
|
|
|
Adding explicit visibility (
private
,protected
, orpublic
) is generally recommend to communicate to other developers how, and from where this method is intended to be used.