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

StateDocumentSpec   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 6

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 0
cbo 6
dl 0
loc 32
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A let() 0 9 1
A it_is_a_document() 0 4 1
A its_data_can_be_read() 0 8 1
A its_data_cannot_be_manipulated() 0 5 1
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\DocumentData;
9
use Xabbuh\XApi\Model\InverseFunctionalIdentifier;
10
use Xabbuh\XApi\Model\State;
11
12
class StateDocumentSpec extends ObjectBehavior
13
{
14
    function let()
15
    {
16
        $activity = new Activity('http://tincanapi.com/conformancetest/activityid');
17
        $actor = new Agent(InverseFunctionalIdentifier::withMbox('mailto:[email protected]'));
18
        $this->beConstructedWith(new State($activity, $actor, 'state-id'), new DocumentData(array(
19
            'x' => 'foo',
20
            'y' => 'bar',
21
        )));
22
    }
23
24
    function it_is_a_document()
25
    {
26
        $this->shouldHaveType('Xabbuh\XApi\Model\Document');
27
    }
28
29
    function its_data_can_be_read()
30
    {
31
        $this->offsetExists('x')->shouldReturn(true);
32
        $this->offsetGet('x')->shouldReturn('foo');
33
        $this->offsetExists('y')->shouldReturn(true);
34
        $this->offsetGet('y')->shouldReturn('bar');
35
        $this->offsetExists('z')->shouldReturn(false);
36
    }
37
38
    function its_data_cannot_be_manipulated()
39
    {
40
        $this->shouldThrow('\Xabbuh\XApi\Common\Exception\UnsupportedOperationException')->duringOffsetSet('z', 'baz');
41
        $this->shouldThrow('\Xabbuh\XApi\Common\Exception\UnsupportedOperationException')->duringOffsetUnset('x');
42
    }
43
}
44