Completed
Push — master ( 2bedd9...b42c0c )
by Christian
02:23
created

StateDocumentSpec::its_data_can_be_read()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 6
nc 1
nop 0
1
<?php
2
3
/*
4
 * This file is part of the xAPI package.
5
 *
6
 * (c) Christian Flothmann <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace spec\Xabbuh\XApi\Model;
13
14
use PhpSpec\ObjectBehavior;
15
use Xabbuh\XApi\Model\Activity;
16
use Xabbuh\XApi\Model\Agent;
17
use Xabbuh\XApi\Model\DocumentData;
18
use Xabbuh\XApi\Model\InverseFunctionalIdentifier;
19
use Xabbuh\XApi\Model\State;
20
21
class StateDocumentSpec extends ObjectBehavior
22
{
23
    function let()
24
    {
25
        $activity = new Activity('http://tincanapi.com/conformancetest/activityid');
26
        $actor = new Agent(InverseFunctionalIdentifier::withMbox('mailto:[email protected]'));
27
        $this->beConstructedWith(new State($activity, $actor, 'state-id'), new DocumentData(array(
28
            'x' => 'foo',
29
            'y' => 'bar',
30
        )));
31
    }
32
33
    function it_is_a_document()
34
    {
35
        $this->shouldHaveType('Xabbuh\XApi\Model\Document');
36
    }
37
38
    function its_data_can_be_read()
39
    {
40
        $this->offsetExists('x')->shouldReturn(true);
41
        $this->offsetGet('x')->shouldReturn('foo');
42
        $this->offsetExists('y')->shouldReturn(true);
43
        $this->offsetGet('y')->shouldReturn('bar');
44
        $this->offsetExists('z')->shouldReturn(false);
45
    }
46
47
    function it_throws_exception_when_not_existing_data_is_being_read()
48
    {
49
        $this->shouldThrow('\InvalidArgumentException')->duringOffsetGet('z');
50
    }
51
52
    function its_data_cannot_be_manipulated()
53
    {
54
        $this->shouldThrow('\Xabbuh\XApi\Common\Exception\UnsupportedOperationException')->duringOffsetSet('z', 'baz');
55
        $this->shouldThrow('\Xabbuh\XApi\Common\Exception\UnsupportedOperationException')->duringOffsetUnset('x');
56
    }
57
}
58