Completed
Push — master ( 21b23e...04c0e6 )
by Christian
04:03
created

StatementIdSpec   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

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

5 Methods

Rating   Name   Duplication   Size   Complexity  
A it_can_be_created_from_a_uuid() 0 5 1
A it_can_be_created_from_a_string() 0 5 1
A it_should_reject_malformed_uuids() 0 5 1
A its_value_is_a_uuid_string() 0 6 1
A it_is_equal_to_statement_ids_with_equal_value() 0 11 1
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 Rhumsaa\Uuid\Uuid;
16
use Xabbuh\XApi\Model\StatementId;
17
18
class StatementIdSpec extends ObjectBehavior
19
{
20
    function it_can_be_created_from_a_uuid()
21
    {
22
        $this->beConstructedThrough('fromUuid', array(Uuid::fromString('39e24cc4-69af-4b01-a824-1fdc6ea8a3af')));
23
        $this->shouldBeAnInstanceOf('Xabbuh\XApi\Model\StatementId');
24
    }
25
26
    function it_can_be_created_from_a_string()
27
    {
28
        $this->beConstructedThrough('fromString', array('39e24cc4-69af-4b01-a824-1fdc6ea8a3af'));
29
        $this->shouldBeAnInstanceOf('Xabbuh\XApi\Model\StatementId');
30
    }
31
32
    function it_should_reject_malformed_uuids()
33
    {
34
        $this->beConstructedThrough('fromString', array('bad-uuid'));
35
        $this->shouldThrow('\InvalidArgumentException')->duringInstantiation();
36
    }
37
38
    function its_value_is_a_uuid_string()
39
    {
40
        $this->beConstructedThrough('fromUuid', array(Uuid::fromString('39e24cc4-69af-4b01-a824-1fdc6ea8a3af')));
41
42
        $this->getValue()->shouldReturn('39e24cc4-69af-4b01-a824-1fdc6ea8a3af');
43
    }
44
45
    function it_is_equal_to_statement_ids_with_equal_value()
46
    {
47
        $value = '39e24cc4-69af-4b01-a824-1fdc6ea8a3af';
48
        $uuid = Uuid::fromString($value);
49
50
        $this->beConstructedThrough('fromUuid', array($uuid));
51
52
        $this->equals(StatementId::fromString($value))->shouldReturn(true);
53
        $this->equals(StatementId::fromUuid(Uuid::fromString($value)))->shouldReturn(true);
54
        $this->equals(StatementId::fromUuid($uuid))->shouldReturn(true);
55
    }
56
}
57