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
|
|
|
|