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

ActivityProfileDocumentSpec   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 4
dl 0
loc 35
rs 10
c 0
b 0
f 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\ActivityProfile;
17
use Xabbuh\XApi\Model\DocumentData;
18
19
class ActivityProfileDocumentSpec extends ObjectBehavior
20
{
21
    function let()
22
    {
23
        $this->beConstructedWith(new ActivityProfile('id', new Activity('http://tincanapi.com/conformancetest/activityid')), new DocumentData(array(
24
            'x' => 'foo',
25
            'y' => 'bar',
26
        )));
27
    }
28
29
    function it_is_a_document()
30
    {
31
        $this->shouldHaveType('Xabbuh\XApi\Model\Document');
32
    }
33
34
    function its_data_can_be_read()
35
    {
36
        $this->offsetExists('x')->shouldReturn(true);
37
        $this->offsetGet('x')->shouldReturn('foo');
38
        $this->offsetExists('y')->shouldReturn(true);
39
        $this->offsetGet('y')->shouldReturn('bar');
40
        $this->offsetExists('z')->shouldReturn(false);
41
    }
42
43
    function it_throws_exception_when_not_existing_data_is_being_read()
44
    {
45
        $this->shouldThrow('\InvalidArgumentException')->duringOffsetGet('z');
46
    }
47
48
    function its_data_cannot_be_manipulated()
49
    {
50
        $this->shouldThrow('\Xabbuh\XApi\Common\Exception\UnsupportedOperationException')->duringOffsetSet('z', 'baz');
51
        $this->shouldThrow('\Xabbuh\XApi\Common\Exception\UnsupportedOperationException')->duringOffsetUnset('x');
52
    }
53
}
54