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

AgentProfileDocumentSpec   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 5
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\Agent;
16
use Xabbuh\XApi\Model\AgentProfile;
17
use Xabbuh\XApi\Model\DocumentData;
18
use Xabbuh\XApi\Model\InverseFunctionalIdentifier;
19
20
class AgentProfileDocumentSpec extends ObjectBehavior
21
{
22
    function let()
23
    {
24
        $this->beConstructedWith(new AgentProfile('id', new Agent(InverseFunctionalIdentifier::withMbox('mailto:[email protected]'))), new DocumentData(array(
25
            'x' => 'foo',
26
            'y' => 'bar',
27
        )));
28
    }
29
30
    function it_is_a_document()
31
    {
32
        $this->shouldHaveType('Xabbuh\XApi\Model\Document');
33
    }
34
35
    function its_data_can_be_read()
36
    {
37
        $this->offsetExists('x')->shouldReturn(true);
38
        $this->offsetGet('x')->shouldReturn('foo');
39
        $this->offsetExists('y')->shouldReturn(true);
40
        $this->offsetGet('y')->shouldReturn('bar');
41
        $this->offsetExists('z')->shouldReturn(false);
42
    }
43
44
    function it_throws_exception_when_not_existing_data_is_being_read()
45
    {
46
        $this->shouldThrow('\InvalidArgumentException')->duringOffsetGet('z');
47
    }
48
49
    function its_data_cannot_be_manipulated()
50
    {
51
        $this->shouldThrow('\Xabbuh\XApi\Common\Exception\UnsupportedOperationException')->duringOffsetSet('z', 'baz');
52
        $this->shouldThrow('\Xabbuh\XApi\Common\Exception\UnsupportedOperationException')->duringOffsetUnset('x');
53
    }
54
}
55