1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace spec\Xabbuh\XApi\Model\Interaction; |
4
|
|
|
|
5
|
|
|
use PhpSpec\ObjectBehavior; |
6
|
|
|
use Xabbuh\XApi\Model\Definition; |
7
|
|
|
use Xabbuh\XApi\Model\Interaction\InteractionDefinition; |
8
|
|
|
|
9
|
|
|
abstract class InteractionDefinitionSpec extends ObjectBehavior |
10
|
|
|
{ |
11
|
|
|
function it_is_a_definition() |
12
|
|
|
{ |
13
|
|
|
$this->shouldHaveType('Xabbuh\XApi\Model\Definition'); |
14
|
|
|
} |
15
|
|
|
|
16
|
|
|
function it_is_an_interaction() |
17
|
|
|
{ |
18
|
|
|
$this->shouldHaveType('Xabbuh\XApi\Model\Interaction\InteractionDefinition'); |
19
|
|
|
} |
20
|
|
|
|
21
|
|
|
function it_is_not_equal_to_generic_definition() |
22
|
|
|
{ |
23
|
|
|
$this->equals(new Definition())->shouldReturn(false); |
24
|
|
|
} |
25
|
|
|
|
26
|
|
|
function it_is_not_equal_if_only_other_interaction_has_correct_responses_pattern() |
27
|
|
|
{ |
28
|
|
|
$interaction = $this->createEmptyInteraction(); |
29
|
|
|
$interaction = $interaction->withCorrectResponsesPattern(array('test')); |
30
|
|
|
|
31
|
|
|
$this->equals($interaction)->shouldReturn(false); |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
function it_is_not_equal_if_only_this_interaction_has_correct_responses_pattern() |
35
|
|
|
{ |
36
|
|
|
$this->beConstructedWith(null, null, null, null, array('test')); |
37
|
|
|
|
38
|
|
|
$this->equals($this->createEmptyInteraction())->shouldReturn(false); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
function it_is_not_equal_if_number_of_correct_responses_pattern_differs() |
42
|
|
|
{ |
43
|
|
|
$this->beConstructedWith(null, null, null, null, array('test')); |
44
|
|
|
|
45
|
|
|
$interaction = $this->createEmptyInteraction(); |
46
|
|
|
$interaction = $interaction->withCorrectResponsesPattern(array('test', 'foo')); |
47
|
|
|
|
48
|
|
|
$this->equals($interaction)->shouldReturn(false); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
function it_is_not_equal_if_correct_responses_pattern_values_differ() |
52
|
|
|
{ |
53
|
|
|
$this->beConstructedWith(null, null, null, null, array('foo')); |
54
|
|
|
|
55
|
|
|
$interaction = $this->createEmptyInteraction(); |
56
|
|
|
$interaction = $interaction->withCorrectResponsesPattern(array('bar')); |
57
|
|
|
|
58
|
|
|
$this->equals($interaction)->shouldReturn(false); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
function it_is_equal_if_correct_responses_pattern_values_are_equal() |
62
|
|
|
{ |
63
|
|
|
$this->beConstructedWith(null, null, null, null, array('test')); |
64
|
|
|
|
65
|
|
|
$interaction = $this->createEmptyInteraction(); |
66
|
|
|
$interaction = $interaction->withCorrectResponsesPattern(array('test')); |
67
|
|
|
|
68
|
|
|
$this->equals($interaction)->shouldReturn(true); |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* @return InteractionDefinition |
73
|
|
|
*/ |
74
|
|
|
abstract protected function createEmptyInteraction(); |
75
|
|
|
} |
76
|
|
|
|