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

ChoiceInteractionDefinitionSpec   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

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

6 Methods

Rating   Name   Duplication   Size   Complexity  
A it_is_not_equal_if_only_other_interaction_has_choices() 0 7 1
A it_is_not_equal_if_only_this_interaction_has_choices() 0 6 1
A it_is_not_equal_if_number_of_choices_differs() 0 9 1
A it_is_not_equal_if_choices_differ() 0 9 1
A it_is_equal_if_choices_are_equal() 0 9 1
A createEmptyInteraction() 0 4 1
1
<?php
2
3
namespace spec\Xabbuh\XApi\Model\Interaction;
4
5
use Xabbuh\XApi\Model\Interaction\ChoiceInteractionDefinition;
6
use Xabbuh\XApi\Model\Interaction\InteractionComponent;
7
8
class ChoiceInteractionDefinitionSpec extends InteractionDefinitionSpec
9
{
10
    function it_is_not_equal_if_only_other_interaction_has_choices()
11
    {
12
        $interaction = $this->createEmptyInteraction();
13
        $interaction = $interaction->withChoices(array(new InteractionComponent('test')));
14
15
        $this->equals($interaction)->shouldReturn(false);
16
    }
17
18
    function it_is_not_equal_if_only_this_interaction_has_choices()
19
    {
20
        $this->beConstructedWith(null, null, null, null, null, array(new InteractionComponent('test')));
21
22
        $this->equals($this->createEmptyInteraction())->shouldReturn(false);
23
    }
24
25
    function it_is_not_equal_if_number_of_choices_differs()
26
    {
27
        $this->beConstructedWith(null, null, null, null, null, array(new InteractionComponent('test')));
28
29
        $interaction = $this->createEmptyInteraction();
30
        $interaction = $interaction->withChoices(array(new InteractionComponent('test'), new InteractionComponent('foo')));
31
32
        $this->equals($interaction)->shouldReturn(false);
33
    }
34
35
    function it_is_not_equal_if_choices_differ()
36
    {
37
        $this->beConstructedWith(null, null, null, null, null, array(new InteractionComponent('foo')));
38
39
        $interaction = $this->createEmptyInteraction();
40
        $interaction = $interaction->withChoices(array(new InteractionComponent('bar')));
41
42
        $this->equals($interaction)->shouldReturn(false);
43
    }
44
45
    function it_is_equal_if_choices_are_equal()
46
    {
47
        $this->beConstructedWith(null, null, null, null, null, array(new InteractionComponent('test')));
48
49
        $interaction = $this->createEmptyInteraction();
50
        $interaction = $interaction->withChoices(array(new InteractionComponent('test')));
51
52
        $this->equals($interaction)->shouldReturn(true);
53
    }
54
55
    protected function createEmptyInteraction()
56
    {
57
        return new ChoiceInteractionDefinition();
58
    }
59
}
60