|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace spec\Xabbuh\XApi\Model; |
|
4
|
|
|
|
|
5
|
|
|
use PhpSpec\ObjectBehavior; |
|
6
|
|
|
use Xabbuh\XApi\Model\Extensions; |
|
7
|
|
|
|
|
8
|
|
|
class ExtensionsSpec extends ObjectBehavior |
|
9
|
|
|
{ |
|
10
|
|
|
function let() |
|
11
|
|
|
{ |
|
12
|
|
|
$this->beConstructedWith(array('http://id.tincanapi.com/extension/topic' => 'Conformance Testing')); |
|
13
|
|
|
} |
|
14
|
|
|
|
|
15
|
|
|
function its_extensions_can_be_read() |
|
16
|
|
|
{ |
|
17
|
|
|
$extensions = array( |
|
18
|
|
|
'http://id.tincanapi.com/extension/topic' => 'Conformance Testing', |
|
19
|
|
|
'http://id.tincanapi.com/extension/color' => array( |
|
20
|
|
|
'model' => 'RGB', |
|
21
|
|
|
'value' => '#FFFFFF', |
|
22
|
|
|
), |
|
23
|
|
|
'http://id.tincanapi.com/extension/starting-position' => 1, |
|
24
|
|
|
); |
|
25
|
|
|
$this->beConstructedWith($extensions); |
|
26
|
|
|
|
|
27
|
|
|
$this->offsetExists('http://id.tincanapi.com/extension/topic')->shouldReturn(true); |
|
28
|
|
|
$this->offsetGet('http://id.tincanapi.com/extension/topic')->shouldReturn('Conformance Testing'); |
|
29
|
|
|
|
|
30
|
|
|
$this->offsetExists('http://id.tincanapi.com/extension/color')->shouldReturn(true); |
|
31
|
|
|
$this->offsetGet('http://id.tincanapi.com/extension/color')->shouldReturn(array( |
|
32
|
|
|
'model' => 'RGB', |
|
33
|
|
|
'value' => '#FFFFFF', |
|
34
|
|
|
)); |
|
35
|
|
|
|
|
36
|
|
|
$this->offsetExists('http://id.tincanapi.com/extension/starting-position')->shouldReturn(true); |
|
37
|
|
|
$this->offsetGet('http://id.tincanapi.com/extension/starting-position')->shouldReturn(1); |
|
38
|
|
|
|
|
39
|
|
|
$this->getExtensions()->shouldReturn($extensions); |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
function it_throws_exception_when_not_existing_extension_is_being_read() |
|
43
|
|
|
{ |
|
44
|
|
|
$this->shouldThrow('\InvalidArgumentException')->duringOffsetGet('z'); |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
function its_extensions_cannot_be_manipulated() |
|
48
|
|
|
{ |
|
49
|
|
|
$this->shouldThrow('\Xabbuh\XApi\Common\Exception\UnsupportedOperationException')->duringOffsetSet('z', 'baz'); |
|
50
|
|
|
$this->shouldThrow('\Xabbuh\XApi\Common\Exception\UnsupportedOperationException')->duringOffsetUnset('x'); |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
function its_not_equal_to_other_extensions_with_a_different_number_of_entries() |
|
54
|
|
|
{ |
|
55
|
|
|
$this->beConstructedWith(array('http://id.tincanapi.com/extension/topic' => 'Conformance Testing')); |
|
56
|
|
|
|
|
57
|
|
|
$this->equals(new Extensions(array()))->shouldReturn(false); |
|
58
|
|
|
$this->equals(new Extensions(array( |
|
59
|
|
|
'http://id.tincanapi.com/extension/topic' => 'Conformance Testing', |
|
60
|
|
|
'http://id.tincanapi.com/extension/starting-position' => 1, |
|
61
|
|
|
)))->shouldReturn(false); |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
function its_not_equal_to_other_extensions_if_extension_names_differ() |
|
65
|
|
|
{ |
|
66
|
|
|
$this->beConstructedWith(array('http://id.tincanapi.com/extension/topic' => 'Conformance Testing')); |
|
67
|
|
|
|
|
68
|
|
|
$this->equals(new Extensions(array('http://id.tincanapi.com/extension/subject' => 'Conformance Testing')))->shouldReturn(false); |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
function its_not_equal_to_other_extensions_if_extension_values_differ() |
|
72
|
|
|
{ |
|
73
|
|
|
$this->beConstructedWith(array('http://id.tincanapi.com/extension/topic' => 'Conformance Testing')); |
|
74
|
|
|
|
|
75
|
|
|
$this->equals(new Extensions(array('http://id.tincanapi.com/extension/topic' => 'Conformance Tests')))->shouldReturn(false); |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
function its_equal_to_other_extensions_even_if_extension_names_are_in_different_order() |
|
79
|
|
|
{ |
|
80
|
|
|
$this->beConstructedWith(array( |
|
81
|
|
|
'http://id.tincanapi.com/extension/topic' => 'Conformance Testing', |
|
82
|
|
|
'http://id.tincanapi.com/extension/color' => array( |
|
83
|
|
|
'model' => 'RGB', |
|
84
|
|
|
'value' => '#FFFFFF', |
|
85
|
|
|
), |
|
86
|
|
|
'http://id.tincanapi.com/extension/starting-position' => 1, |
|
87
|
|
|
)); |
|
88
|
|
|
|
|
89
|
|
|
$this->equals(new Extensions(array( |
|
90
|
|
|
'http://id.tincanapi.com/extension/starting-position' => 1, |
|
91
|
|
|
'http://id.tincanapi.com/extension/color' => array( |
|
92
|
|
|
'model' => 'RGB', |
|
93
|
|
|
'value' => '#FFFFFF', |
|
94
|
|
|
), |
|
95
|
|
|
'http://id.tincanapi.com/extension/topic' => 'Conformance Testing', |
|
96
|
|
|
)))->shouldReturn(true); |
|
97
|
|
|
} |
|
98
|
|
|
} |
|
99
|
|
|
|