1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace spec\Xabbuh\XApi\Model\Interaction; |
4
|
|
|
|
5
|
|
|
use PhpSpec\ObjectBehavior; |
6
|
|
|
use Xabbuh\XApi\Model\Interaction\InteractionComponent; |
7
|
|
|
use Xabbuh\XApi\Model\LanguageMap; |
8
|
|
|
|
9
|
|
|
class InteractionComponentSpec extends ObjectBehavior |
10
|
|
|
{ |
11
|
|
|
function its_properties_can_be_read() |
12
|
|
|
{ |
13
|
|
|
$description = LanguageMap::create(array('en-US' => 'test')); |
14
|
|
|
$this->beConstructedWith('test', $description); |
15
|
|
|
|
16
|
|
|
$this->getId()->shouldReturn('test'); |
17
|
|
|
$this->getDescription()->shouldReturn($description); |
18
|
|
|
} |
19
|
|
|
|
20
|
|
|
function it_is_not_equal_with_other_interaction_component_if_ids_differ() |
21
|
|
|
{ |
22
|
|
|
$description = LanguageMap::create(array('en-US' => 'test')); |
23
|
|
|
$this->beConstructedWith('test', $description); |
24
|
|
|
|
25
|
|
|
$interactionComponent = new InteractionComponent('Test', $description); |
26
|
|
|
|
27
|
|
|
$this->equals($interactionComponent)->shouldReturn(false); |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
function it_is_not_equal_with_other_interaction_component_if_descriptions_differ() |
31
|
|
|
{ |
32
|
|
|
$this->beConstructedWith('test', LanguageMap::create(array('en-US' => 'test'))); |
33
|
|
|
|
34
|
|
|
$interactionComponent = new InteractionComponent('test', LanguageMap::create(array('en-GB' => 'test'))); |
35
|
|
|
|
36
|
|
|
$this->equals($interactionComponent)->shouldReturn(false); |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
function it_is_not_equal_with_other_interaction_component_if_other_interaction_component_does_not_have_a_description() |
40
|
|
|
{ |
41
|
|
|
$this->beConstructedWith('test', LanguageMap::create(array('en-US' => 'test'))); |
42
|
|
|
|
43
|
|
|
$interactionComponent = new InteractionComponent('test'); |
44
|
|
|
|
45
|
|
|
$this->equals($interactionComponent)->shouldReturn(false); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
function it_is_not_equal_with_other_interaction_component_if_only_the_other_interaction_component_does_have_a_description() |
49
|
|
|
{ |
50
|
|
|
$this->beConstructedWith('test'); |
51
|
|
|
|
52
|
|
|
$interactionComponent = new InteractionComponent('test', LanguageMap::create(array('en-US' => 'test'))); |
53
|
|
|
|
54
|
|
|
$this->equals($interactionComponent)->shouldReturn(false); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
function it_is_equal_with_other_interaction_component_if_ids_and_descriptions_are_equal() |
58
|
|
|
{ |
59
|
|
|
$this->beConstructedWith('test', LanguageMap::create(array('en-US' => 'test'))); |
60
|
|
|
|
61
|
|
|
$interactionComponent = new InteractionComponent('test', LanguageMap::create(array('en-US' => 'test'))); |
62
|
|
|
|
63
|
|
|
$this->equals($interactionComponent)->shouldReturn(true); |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
function it_is_equal_with_other_interaction_component_if_ids_are_equal_and_descriptions_are_not_present() |
67
|
|
|
{ |
68
|
|
|
$this->beConstructedWith('test'); |
69
|
|
|
|
70
|
|
|
$this->equals(new InteractionComponent('test'))->shouldReturn(true); |
71
|
|
|
} |
72
|
|
|
} |
73
|
|
|
|