Completed
Branch master (3247f7)
by Christian
02:24
created

it_creates_statement_voiding_itself()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 11
rs 9.4285
cc 1
eloc 8
nc 1
nop 0
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