1 | <?php |
||
29 | class SubStatementSpec extends ObjectBehavior |
||
30 | { |
||
31 | function let() |
||
32 | { |
||
33 | $actor = new Agent(InverseFunctionalIdentifier::withMbox('mailto:[email protected]')); |
||
34 | $verb = new Verb('http://tincanapi.com/conformancetest/verbid', LanguageMap::create(array('en-US' => 'test'))); |
||
35 | $object = new Activity('http://tincanapi.com/conformancetest/activityid'); |
||
36 | $this->beConstructedWith($actor, $verb, $object); |
||
37 | } |
||
38 | |||
39 | function it_is_an_xapi_object() |
||
40 | { |
||
41 | $actor = new Agent(InverseFunctionalIdentifier::withMbox('mailto:[email protected]')); |
||
42 | $verb = new Verb('http://tincanapi.com/conformancetest/verbid', LanguageMap::create(array('en-US' => 'test'))); |
||
43 | $object = new Activity('http://tincanapi.com/conformancetest/activityid'); |
||
44 | $this->beConstructedWith($actor, $verb, $object); |
||
45 | |||
46 | $this->shouldHaveType('Xabbuh\XApi\Model\Object'); |
||
47 | } |
||
48 | |||
49 | function it_is_different_from_another_sub_statement_if_contexts_differ() |
||
50 | { |
||
51 | $actor = new Agent(InverseFunctionalIdentifier::withMbox('mailto:[email protected]')); |
||
52 | $verb = new Verb('http://tincanapi.com/conformancetest/verbid', LanguageMap::create(array('en-US' => 'test'))); |
||
53 | $object = new Activity('http://tincanapi.com/conformancetest/activityid'); |
||
54 | $this->beConstructedWith($actor, $verb, $object, null, new Context()); |
||
55 | |||
56 | $subStatement = new SubStatement($actor, $verb, $object); |
||
57 | |||
58 | $this->equals($subStatement)->shouldReturn(false); |
||
59 | |||
60 | $context = new Context(); |
||
61 | $context = $context->withRegistration('16fd2706-8baf-433b-82eb-8c7fada847da') |
||
62 | ->withInstructor(new Agent(InverseFunctionalIdentifier::withMbox('mailto:[email protected]'))) |
||
63 | ->withTeam(new Group(InverseFunctionalIdentifier::withMbox('mailto:[email protected]'))) |
||
64 | ->withContextActivities(new ContextActivities( |
||
65 | array(new Activity('http://tincanapi.com/conformancetest/activityid')), |
||
66 | array(new Activity('http://tincanapi.com/conformancetest/activityid')), |
||
67 | array(new Activity('http://tincanapi.com/conformancetest/activityid')), |
||
68 | array(new Activity('http://tincanapi.com/conformancetest/activityid')) |
||
69 | )) |
||
70 | ->withRevision('test') |
||
71 | ->withPlatform('test') |
||
72 | ->withLanguage('en-US') |
||
73 | ->withStatement(new StatementReference(StatementId::fromString('16fd2706-8baf-433b-82eb-8c7fada847da'))) |
||
74 | ->withExtensions(new Extensions(array())) |
||
75 | ; |
||
76 | $subStatement = new SubStatement($actor, $verb, $object, null, $context); |
||
77 | |||
78 | $this->equals($subStatement)->shouldReturn(false); |
||
79 | } |
||
80 | |||
81 | function it_rejects_to_hold_another_sub_statement_as_object() |
||
82 | { |
||
83 | $actor = new Agent(InverseFunctionalIdentifier::withMbox('mailto:[email protected]')); |
||
84 | $verb = new Verb('http://tincanapi.com/conformancetest/verbid', LanguageMap::create(array('en-US' => 'test'))); |
||
85 | $object = new Activity('http://tincanapi.com/conformancetest/activityid'); |
||
86 | $subStatement = new SubStatement($actor, $verb, $object); |
||
87 | |||
88 | $this->shouldThrow('\InvalidArgumentException')->during('__construct', array($actor, $verb, $subStatement)); |
||
89 | } |
||
90 | |||
91 | public function it_returns_a_new_instance_with_actor() |
||
92 | { |
||
93 | $actor = new Agent(InverseFunctionalIdentifier::withOpenId('http://openid.tincanapi.com')); |
||
94 | $subStatement = $this->withActor($actor); |
||
95 | |||
96 | $subStatement->shouldNotBe($this); |
||
97 | $subStatement->shouldBeAnInstanceOf('\Xabbuh\XApi\Model\SubStatement'); |
||
98 | $subStatement->getActor()->shouldReturn($actor); |
||
99 | } |
||
100 | |||
101 | public function it_returns_a_new_instance_with_verb() |
||
102 | { |
||
103 | $verb = new Verb('http://adlnet.gov/expapi/verbs/voided'); |
||
104 | $subStatement = $this->withVerb($verb); |
||
105 | |||
106 | $subStatement->shouldNotBe($this); |
||
107 | $subStatement->shouldBeAnInstanceOf('\Xabbuh\XApi\Model\SubStatement'); |
||
108 | $subStatement->getVerb()->shouldReturn($verb); |
||
109 | } |
||
110 | |||
111 | public function it_returns_a_new_instance_with_object() |
||
112 | { |
||
113 | $statementReference = new StatementReference(StatementId::fromString('12345678-1234-5678-8234-567812345678')); |
||
114 | $subStatement = $this->withObject($statementReference); |
||
115 | |||
116 | $subStatement->shouldNotBe($this); |
||
117 | $subStatement->shouldBeAnInstanceOf('\Xabbuh\XApi\Model\SubStatement'); |
||
118 | $subStatement->getObject()->shouldReturn($statementReference); |
||
119 | } |
||
120 | |||
121 | public function it_returns_a_new_instance_with_result() |
||
122 | { |
||
123 | $result = new Result(); |
||
124 | $subStatement = $this->withResult($result); |
||
125 | |||
126 | $subStatement->shouldNotBe($this); |
||
127 | $subStatement->shouldBeAnInstanceOf('\Xabbuh\XApi\Model\SubStatement'); |
||
128 | $subStatement->getResult()->shouldReturn($result); |
||
129 | } |
||
130 | |||
131 | public function it_returns_a_new_instance_with_context() |
||
132 | { |
||
133 | $context = new Context(); |
||
134 | $subStatement = $this->withContext($context); |
||
135 | |||
136 | $subStatement->shouldNotBe($this); |
||
137 | $subStatement->shouldBeAnInstanceOf('\Xabbuh\XApi\Model\SubStatement'); |
||
138 | $subStatement->getContext()->shouldReturn($context); |
||
139 | } |
||
140 | } |
||
141 |