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

createEmptyInteraction()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace spec\Xabbuh\XApi\Model\Interaction;
4
5
use Xabbuh\XApi\Model\Interaction\InteractionComponent;
6
use Xabbuh\XApi\Model\Interaction\SequencingInteractionDefinition;
7
8
class SequencingInteractionDefinitionSpec extends InteractionDefinitionSpec
9
{
10
    public function it_returns_a_new_instance_with_choices()
11
    {
12
        $choices = array(new InteractionComponent('test'));
13
        $interaction = $this->withChoices($choices);
14
15
        $this->getChoices()->shouldBeNull();
16
17
        $interaction->shouldNotBe($this);
18
        $interaction->shouldBeAnInstanceOf('\Xabbuh\XApi\Model\Interaction\SequencingInteractionDefinition');
19
        $interaction->getChoices()->shouldReturn($choices);
20
    }
21
22
    function it_is_not_equal_if_only_other_interaction_has_choices()
23
    {
24
        $interaction = $this->createEmptyInteraction();
25
        $interaction = $interaction->withChoices(array(new InteractionComponent('test')));
26
27
        $this->equals($interaction)->shouldReturn(false);
28
    }
29
30
    function it_is_not_equal_if_only_this_interaction_has_choices()
31
    {
32
        $this->beConstructedWith(null, null, null, null, null, array(new InteractionComponent('test')));
33
34
        $this->equals($this->createEmptyInteraction())->shouldReturn(false);
35
    }
36
37
    function it_is_not_equal_if_number_of_choices_differs()
38
    {
39
        $this->beConstructedWith(null, null, null, null, null, array(new InteractionComponent('test')));
40
41
        $interaction = $this->createEmptyInteraction();
42
        $interaction = $interaction->withChoices(array(new InteractionComponent('test'), new InteractionComponent('foo')));
43
44
        $this->equals($interaction)->shouldReturn(false);
45
    }
46
47
    function it_is_not_equal_if_choices_differ()
48
    {
49
        $this->beConstructedWith(null, null, null, null, null, array(new InteractionComponent('foo')));
50
51
        $interaction = $this->createEmptyInteraction();
52
        $interaction = $interaction->withChoices(array(new InteractionComponent('bar')));
53
54
        $this->equals($interaction)->shouldReturn(false);
55
    }
56
57
    function it_is_equal_if_choices_are_equal()
58
    {
59
        $this->beConstructedWith(null, null, null, null, null, array(new InteractionComponent('test')));
60
61
        $interaction = $this->createEmptyInteraction();
62
        $interaction = $interaction->withChoices(array(new InteractionComponent('test')));
63
64
        $this->equals($interaction)->shouldReturn(true);
65
    }
66
67
    protected function createEmptyInteraction()
68
    {
69
        return new SequencingInteractionDefinition();
70
    }
71
}
72