|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace spec\Xabbuh\XApi\Model; |
|
4
|
|
|
|
|
5
|
|
|
use PhpSpec\ObjectBehavior; |
|
6
|
|
|
use Xabbuh\XApi\Model\Agent; |
|
7
|
|
|
use Xabbuh\XApi\Model\ContextActivities; |
|
8
|
|
|
use Xabbuh\XApi\Model\Extensions; |
|
9
|
|
|
use Xabbuh\XApi\Model\Group; |
|
10
|
|
|
use Xabbuh\XApi\Model\InverseFunctionalIdentifier; |
|
11
|
|
|
use Xabbuh\XApi\Model\StatementReference; |
|
12
|
|
|
|
|
13
|
|
|
class ContextSpec extends ObjectBehavior |
|
14
|
|
|
{ |
|
15
|
|
|
public function its_properties_are_empty_by_default() |
|
16
|
|
|
{ |
|
17
|
|
|
$this->getRegistration()->shouldBeNull(); |
|
18
|
|
|
$this->getInstructor()->shouldBeNull(); |
|
19
|
|
|
$this->getTeam()->shouldBeNull(); |
|
20
|
|
|
$this->getContextActivities()->shouldBeNull(); |
|
21
|
|
|
$this->getRevision()->shouldBeNull(); |
|
22
|
|
|
$this->getPlatform()->shouldBeNull(); |
|
23
|
|
|
$this->getLanguage()->shouldBeNull(); |
|
24
|
|
|
$this->getStatement()->shouldBeNull(); |
|
25
|
|
|
$this->getExtensions()->shouldBeNull(); |
|
26
|
|
|
} |
|
27
|
|
|
|
|
28
|
|
|
public function it_returns_a_new_instance_with_registration() |
|
29
|
|
|
{ |
|
30
|
|
|
$context = $this->withRegistration('12345678-1234-5678-8234-567812345678'); |
|
31
|
|
|
|
|
32
|
|
|
$this->getRegistration()->shouldBeNull(); |
|
33
|
|
|
|
|
34
|
|
|
$context->shouldNotBe($this); |
|
35
|
|
|
$context->shouldBeAnInstanceOf('\Xabbuh\XApi\Model\Context'); |
|
36
|
|
|
$context->getRegistration()->shouldReturn('12345678-1234-5678-8234-567812345678'); |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
public function it_returns_a_new_instance_with_instructor() |
|
40
|
|
|
{ |
|
41
|
|
|
$instructor = new Agent(InverseFunctionalIdentifier::withMbox('mailto:[email protected]')); |
|
42
|
|
|
$context = $this->withInstructor($instructor); |
|
43
|
|
|
|
|
44
|
|
|
$this->getInstructor()->shouldBeNull(); |
|
45
|
|
|
|
|
46
|
|
|
$context->shouldNotBe($this); |
|
47
|
|
|
$context->shouldBeAnInstanceOf('\Xabbuh\XApi\Model\Context'); |
|
48
|
|
|
$context->getInstructor()->shouldReturn($instructor); |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
public function it_returns_a_new_instance_with_team() |
|
52
|
|
|
{ |
|
53
|
|
|
$team = new Group(InverseFunctionalIdentifier::withMbox('mailto:[email protected]'), 'team'); |
|
54
|
|
|
$context = $this->withTeam($team); |
|
55
|
|
|
|
|
56
|
|
|
$this->getTeam()->shouldBeNull(); |
|
57
|
|
|
|
|
58
|
|
|
$context->shouldNotBe($this); |
|
59
|
|
|
$context->shouldBeAnInstanceOf('\Xabbuh\XApi\Model\Context'); |
|
60
|
|
|
$context->getTeam()->shouldReturn($team); |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
public function it_returns_a_new_instance_with_context_activities() |
|
64
|
|
|
{ |
|
65
|
|
|
$contextActivities = new ContextActivities(); |
|
66
|
|
|
$context = $this->withContextActivities($contextActivities); |
|
67
|
|
|
|
|
68
|
|
|
$this->getContextActivities()->shouldBeNull(); |
|
69
|
|
|
|
|
70
|
|
|
$context->shouldNotBe($this); |
|
71
|
|
|
$context->shouldBeAnInstanceOf('\Xabbuh\XApi\Model\Context'); |
|
72
|
|
|
$context->getContextActivities()->shouldReturn($contextActivities); |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
public function it_returns_a_new_instance_with_revision() |
|
76
|
|
|
{ |
|
77
|
|
|
$context = $this->withRevision('test'); |
|
78
|
|
|
|
|
79
|
|
|
$this->getRevision()->shouldBeNull(); |
|
80
|
|
|
|
|
81
|
|
|
$context->shouldNotBe($this); |
|
82
|
|
|
$context->shouldBeAnInstanceOf('\Xabbuh\XApi\Model\Context'); |
|
83
|
|
|
$context->getRevision()->shouldReturn('test'); |
|
84
|
|
|
} |
|
85
|
|
|
|
|
86
|
|
|
public function it_returns_a_new_instance_with_platform() |
|
87
|
|
|
{ |
|
88
|
|
|
$context = $this->withPlatform('test'); |
|
89
|
|
|
|
|
90
|
|
|
$this->getPlatform()->shouldBeNull(); |
|
91
|
|
|
|
|
92
|
|
|
$context->shouldNotBe($this); |
|
93
|
|
|
$context->shouldBeAnInstanceOf('\Xabbuh\XApi\Model\Context'); |
|
94
|
|
|
$context->getPlatform()->shouldReturn('test'); |
|
95
|
|
|
} |
|
96
|
|
|
|
|
97
|
|
|
public function it_returns_a_new_instance_with_language() |
|
98
|
|
|
{ |
|
99
|
|
|
$context = $this->withLanguage('en-US'); |
|
100
|
|
|
|
|
101
|
|
|
$this->getLanguage()->shouldBeNull(); |
|
102
|
|
|
|
|
103
|
|
|
$context->shouldNotBe($this); |
|
104
|
|
|
$context->shouldBeAnInstanceOf('\Xabbuh\XApi\Model\Context'); |
|
105
|
|
|
$context->getLanguage()->shouldReturn('en-US'); |
|
106
|
|
|
} |
|
107
|
|
|
|
|
108
|
|
|
public function it_returns_a_new_instance_with_statement_reference() |
|
109
|
|
|
{ |
|
110
|
|
|
$statementReference = new StatementReference('16fd2706-8baf-433b-82eb-8c7fada847da'); |
|
111
|
|
|
$context = $this->withStatement($statementReference); |
|
112
|
|
|
|
|
113
|
|
|
$this->getStatement()->shouldBeNull(); |
|
114
|
|
|
|
|
115
|
|
|
$context->shouldNotBe($this); |
|
116
|
|
|
$context->shouldBeAnInstanceOf('\Xabbuh\XApi\Model\Context'); |
|
117
|
|
|
$context->getStatement()->shouldReturn($statementReference); |
|
118
|
|
|
} |
|
119
|
|
|
|
|
120
|
|
|
public function it_returns_a_new_instance_with_extensions() |
|
121
|
|
|
{ |
|
122
|
|
|
$extensions = new Extensions(array('http://id.tincanapi.com/extension/topic' => 'Conformance Testing')); |
|
123
|
|
|
$context = $this->withExtensions($extensions); |
|
124
|
|
|
|
|
125
|
|
|
$this->getExtensions()->shouldBeNull(); |
|
126
|
|
|
|
|
127
|
|
|
$context->shouldNotBe($this); |
|
128
|
|
|
$context->shouldBeAnInstanceOf('\Xabbuh\XApi\Model\Context'); |
|
129
|
|
|
$context->getExtensions()->shouldReturn($extensions); |
|
130
|
|
|
} |
|
131
|
|
|
} |
|
132
|
|
|
|