|
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\Group; |
|
9
|
|
|
use Xabbuh\XApi\Model\InverseFunctionalIdentifier; |
|
10
|
|
|
use Xabbuh\XApi\Model\Verb; |
|
11
|
|
|
|
|
12
|
|
|
class StatementSpec extends ObjectBehavior |
|
13
|
|
|
{ |
|
14
|
|
|
function let() |
|
15
|
|
|
{ |
|
16
|
|
|
$actor = new Agent(InverseFunctionalIdentifier::withMbox('mailto:[email protected]')); |
|
17
|
|
|
$verb = new Verb('http://tincanapi.com/conformancetest/verbid', array('en-US' => 'test')); |
|
18
|
|
|
$object = new Activity('http://tincanapi.com/conformancetest/activityid'); |
|
19
|
|
|
$this->beConstructedWith('39e24cc4-69af-4b01-a824-1fdc6ea8a3af', $actor, $verb, $object); |
|
20
|
|
|
} |
|
21
|
|
|
|
|
22
|
|
|
function it_creates_reference_to_itself() |
|
23
|
|
|
{ |
|
24
|
|
|
$reference = $this->getStatementReference(); |
|
25
|
|
|
$reference->shouldBeAnInstanceOf('Xabbuh\XApi\Model\StatementReference'); |
|
26
|
|
|
$reference->getStatementId()->shouldReturn('39e24cc4-69af-4b01-a824-1fdc6ea8a3af'); |
|
27
|
|
|
} |
|
28
|
|
|
|
|
29
|
|
|
function it_creates_statement_voiding_itself() |
|
30
|
|
|
{ |
|
31
|
|
|
$voidingActor = new Agent(InverseFunctionalIdentifier::withOpenId('http://openid.tincanapi.com')); |
|
32
|
|
|
$voidingStatement = $this->getVoidStatement($voidingActor); |
|
33
|
|
|
$voidingStatement->getActor()->shouldBe($voidingActor); |
|
34
|
|
|
$voidingStatement->getVerb()->getId()->shouldReturn('http://adlnet.gov/expapi/verbs/voided'); |
|
35
|
|
|
|
|
36
|
|
|
$voidedStatement = $voidingStatement->getObject(); |
|
37
|
|
|
$voidedStatement->shouldBeAnInstanceOf('Xabbuh\XApi\Model\StatementReference'); |
|
38
|
|
|
$voidedStatement->getStatementId()->shouldReturn('39e24cc4-69af-4b01-a824-1fdc6ea8a3af'); |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
function it_can_be_authorized() |
|
42
|
|
|
{ |
|
43
|
|
|
$authority = new Agent(InverseFunctionalIdentifier::withOpenId('http://openid.tincanapi.com')); |
|
44
|
|
|
$authorizedStatement = $this->withAuthority($authority); |
|
45
|
|
|
$authorizedStatement->getAuthority()->shouldReturn($authority); |
|
46
|
|
|
|
|
47
|
|
|
$authorizedStatement->shouldBeAnInstanceOf('Xabbuh\XApi\Model\Statement'); |
|
48
|
|
|
$authorizedStatement->getActor()->equals($this->getActor())->shouldBe(true); |
|
49
|
|
|
$authorizedStatement->getVerb()->equals($this->getVerb())->shouldBe(true); |
|
50
|
|
|
$authorizedStatement->getObject()->equals($this->getObject())->shouldBe(true); |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
function it_overrides_existing_authority_when_it_is_authorized() |
|
54
|
|
|
{ |
|
55
|
|
|
$actor = new Agent(InverseFunctionalIdentifier::withMbox('mailto:[email protected]')); |
|
56
|
|
|
$verb = new Verb('http://tincanapi.com/conformancetest/verbid', array('en-US' => 'test')); |
|
57
|
|
|
$object = new Activity('http://tincanapi.com/conformancetest/activityid'); |
|
58
|
|
|
$authority = new Group(InverseFunctionalIdentifier::withMbox('mailto:[email protected]')); |
|
59
|
|
|
$this->beConstructedWith('39e24cc4-69af-4b01-a824-1fdc6ea8a3af', $actor, $verb, $object, null, $authority); |
|
60
|
|
|
|
|
61
|
|
|
$authority = new Agent(InverseFunctionalIdentifier::withOpenId('http://openid.tincanapi.com')); |
|
62
|
|
|
$authorizedStatement = $this->withAuthority($authority); |
|
63
|
|
|
$authorizedStatement->getAuthority()->shouldReturn($authority); |
|
64
|
|
|
|
|
65
|
|
|
$authorizedStatement->shouldBeAnInstanceOf('Xabbuh\XApi\Model\Statement'); |
|
66
|
|
|
$authorizedStatement->getActor()->equals($this->getActor())->shouldBe(true); |
|
67
|
|
|
$authorizedStatement->getVerb()->equals($this->getVerb())->shouldBe(true); |
|
68
|
|
|
$authorizedStatement->getObject()->equals($this->getObject())->shouldBe(true); |
|
69
|
|
|
$authorizedStatement->getAuthority()->equals($this->getAuthority())->shouldBe(false); |
|
70
|
|
|
} |
|
71
|
|
|
} |
|
72
|
|
|
|