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

PerformanceInteractionDefinitionSpec   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 it_returns_a_new_instance_with_steps() 0 11 1
A it_is_not_equal_if_only_other_interaction_has_steps() 0 7 1
A it_is_not_equal_if_only_this_interaction_has_steps() 0 6 1
A it_is_not_equal_if_number_of_steps_differs() 0 9 1
A it_is_not_equal_if_steps_differ() 0 9 1
A it_is_equal_if_steps_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\InteractionComponent;
6
use Xabbuh\XApi\Model\Interaction\PerformanceInteractionDefinition;
7
8
class PerformanceInteractionDefinitionSpec extends InteractionDefinitionSpec
9
{
10
    public function it_returns_a_new_instance_with_steps()
11
    {
12
        $steps = array(new InteractionComponent('test'));
13
        $interaction = $this->withSteps($steps);
14
15
        $this->getSteps()->shouldBeNull();
16
17
        $interaction->shouldNotBe($this);
18
        $interaction->shouldBeAnInstanceOf('\Xabbuh\XApi\Model\Interaction\PerformanceInteractionDefinition');
19
        $interaction->getSteps()->shouldReturn($steps);
20
    }
21
22
    function it_is_not_equal_if_only_other_interaction_has_steps()
23
    {
24
        $interaction = $this->createEmptyInteraction();
25
        $interaction = $interaction->withSteps(array(new InteractionComponent('test')));
26
27
        $this->equals($interaction)->shouldReturn(false);
28
    }
29
30
    function it_is_not_equal_if_only_this_interaction_has_steps()
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_steps_differs()
38
    {
39
        $this->beConstructedWith(null, null, null, null, null, array(new InteractionComponent('test')));
40
41
        $interaction = $this->createEmptyInteraction();
42
        $interaction = $interaction->withSteps(array(new InteractionComponent('test'), new InteractionComponent('foo')));
43
44
        $this->equals($interaction)->shouldReturn(false);
45
    }
46
47
    function it_is_not_equal_if_steps_differ()
48
    {
49
        $this->beConstructedWith(null, null, null, null, null, array(new InteractionComponent('foo')));
50
51
        $interaction = $this->createEmptyInteraction();
52
        $interaction = $interaction->withSteps(array(new InteractionComponent('bar')));
53
54
        $this->equals($interaction)->shouldReturn(false);
55
    }
56
57
    function it_is_equal_if_steps_are_equal()
58
    {
59
        $this->beConstructedWith(null, null, null, null, null, array(new InteractionComponent('test')));
60
61
        $interaction = $this->createEmptyInteraction();
62
        $interaction = $interaction->withSteps(array(new InteractionComponent('test')));
63
64
        $this->equals($interaction)->shouldReturn(true);
65
    }
66
67
    protected function createEmptyInteraction()
68
    {
69
        return new PerformanceInteractionDefinition();
70
    }
71
}
72