1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace spec\Xabbuh\XApi\Model; |
4
|
|
|
|
5
|
|
|
use PhpSpec\ObjectBehavior; |
6
|
|
|
use Xabbuh\XApi\Model\Activity; |
7
|
|
|
use Xabbuh\XApi\Model\Agent; |
8
|
|
|
use Xabbuh\XApi\Model\Context; |
9
|
|
|
use Xabbuh\XApi\Model\InverseFunctionalIdentifier; |
10
|
|
|
use Xabbuh\XApi\Model\Result; |
11
|
|
|
use Xabbuh\XApi\Model\Verb; |
12
|
|
|
|
13
|
|
|
class StatementFactorySpec extends ObjectBehavior |
14
|
|
|
{ |
15
|
|
|
function it_creates_a_statement() |
16
|
|
|
{ |
17
|
|
|
$this->withActor(new Agent(InverseFunctionalIdentifier::withMbox('mailto:[email protected]'))); |
18
|
|
|
$this->withVerb(new Verb('http://tincanapi.com/conformancetest/verbid')); |
19
|
|
|
$this->withObject(new Activity('http://tincanapi.com/conformancetest/activityid')); |
20
|
|
|
|
21
|
|
|
$this->createStatement()->shouldBeAnInstanceOf('\Xabbuh\Xapi\Model\Statement'); |
22
|
|
|
} |
23
|
|
|
|
24
|
|
|
function it_configures_all_statement_properties() |
25
|
|
|
{ |
26
|
|
|
$id = '39e24cc4-69af-4b01-a824-1fdc6ea8a3af'; |
27
|
|
|
$actor = new Agent(InverseFunctionalIdentifier::withMbox('mailto:[email protected]')); |
28
|
|
|
$verb = new Verb('http://tincanapi.com/conformancetest/verbid'); |
29
|
|
|
$object = new Activity('http://tincanapi.com/conformancetest/activityid'); |
30
|
|
|
$result = new Result(); |
31
|
|
|
$context = new Context(); |
32
|
|
|
$created = new \DateTime('2014-07-23T12:34:02-05:00'); |
33
|
|
|
$stored = new \DateTime('2014-07-24T12:34:02-05:00'); |
34
|
|
|
$authority = new Agent(InverseFunctionalIdentifier::withOpenId('http://openid.tincanapi.com')); |
35
|
|
|
|
36
|
|
|
$this->withId($id); |
37
|
|
|
$this->withActor($actor); |
38
|
|
|
$this->withVerb($verb); |
39
|
|
|
$this->withObject($object); |
40
|
|
|
$this->withResult($result); |
41
|
|
|
$this->withContext($context); |
42
|
|
|
$this->withCreated($created); |
43
|
|
|
$this->withStored($stored); |
44
|
|
|
$this->withAuthority($authority); |
45
|
|
|
|
46
|
|
|
$statement = $this->createStatement(); |
47
|
|
|
|
48
|
|
|
$statement->getId()->shouldBe($id); |
49
|
|
|
$statement->getActor()->shouldBe($actor); |
50
|
|
|
$statement->getVerb()->shouldBe($verb); |
51
|
|
|
$statement->getObject()->shouldBe($object); |
52
|
|
|
$statement->getResult()->shouldBe($result); |
53
|
|
|
$statement->getContext()->shouldBe($context); |
54
|
|
|
$statement->getCreated()->shouldBe($created); |
55
|
|
|
$statement->getStored()->shouldBe($stored); |
56
|
|
|
$statement->getAuthority()->shouldBe($authority); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
function it_throws_an_exception_when_a_statement_is_created_without_an_actor() |
60
|
|
|
{ |
61
|
|
|
$this->withVerb(new Verb('http://tincanapi.com/conformancetest/verbid')); |
62
|
|
|
$this->withObject(new Activity('http://tincanapi.com/conformancetest/activityid')); |
63
|
|
|
|
64
|
|
|
$this->shouldThrow('\Xabbuh\XApi\Model\Exception\InvalidStateException')->during('createStatement'); |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
function it_throws_an_exception_when_a_statement_is_created_without_a_verb() |
68
|
|
|
{ |
69
|
|
|
$this->withActor(new Agent(InverseFunctionalIdentifier::withMbox('mailto:[email protected]'))); |
70
|
|
|
$this->withObject(new Activity('http://tincanapi.com/conformancetest/activityid')); |
71
|
|
|
|
72
|
|
|
$this->shouldThrow('\Xabbuh\XApi\Model\Exception\InvalidStateException')->during('createStatement'); |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
function it_throws_an_exception_when_a_statement_is_created_without_an_object() |
76
|
|
|
{ |
77
|
|
|
$this->withActor(new Agent(InverseFunctionalIdentifier::withMbox('mailto:[email protected]'))); |
78
|
|
|
$this->withVerb(new Verb('http://tincanapi.com/conformancetest/verbid')); |
79
|
|
|
|
80
|
|
|
$this->shouldThrow('\Xabbuh\XApi\Model\Exception\InvalidStateException')->during('createStatement'); |
81
|
|
|
} |
82
|
|
|
} |
83
|
|
|
|