Completed
Pull Request — master (#27)
by Christian
03:12
created

it_is_equal_if_choices_are_equal()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 9
rs 9.6666
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 0
1
<?php
2
3
namespace spec\Xabbuh\XApi\Model\Interaction;
4
5
use Xabbuh\XApi\Model\Interaction\ChoiceInteraction;
6
use Xabbuh\XApi\Model\Interaction\InteractionComponent;
7
8
class ChoiceInteractionSpec extends InteractionSpec
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 ChoiceInteraction();
58
    }
59
}
60