Completed
Pull Request — master (#27)
by Christian
02:36
created

InteractionComponentSpec   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 64
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 7
lcom 1
cbo 3
dl 0
loc 64
rs 10
c 0
b 0
f 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
A its_properties_can_be_read() 0 8 1
A it_is_not_equal_with_other_interaction_component_if_ids_differ() 0 9 1
A it_is_not_equal_with_other_interaction_component_if_descriptions_differ() 0 8 1
A it_is_not_equal_with_other_interaction_component_if_other_interaction_component_does_not_have_a_description() 0 8 1
A it_is_not_equal_with_other_interaction_component_if_only_the_other_interaction_component_does_have_a_description() 0 8 1
A it_is_equal_with_other_interaction_component_if_ids_and_descriptions_are_equal() 0 8 1
A it_is_equal_with_other_interaction_component_if_ids_are_equal_and_descriptions_are_not_present() 0 6 1
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