1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace spec\Xabbuh\XApi\Serializer\Normalizer; |
4
|
|
|
|
5
|
|
|
use PhpSpec\ObjectBehavior; |
6
|
|
|
use Xabbuh\XApi\Model\Definition; |
7
|
|
|
|
8
|
|
|
class DefinitionNormalizerSpec extends ObjectBehavior |
9
|
|
|
{ |
10
|
|
|
function it_is_a_normalizer() |
11
|
|
|
{ |
12
|
|
|
$this->shouldHaveType('Symfony\Component\Serializer\Normalizer\NormalizerInterface'); |
13
|
|
|
} |
14
|
|
|
|
15
|
|
|
function it_supports_normalizing_definition_objects() |
16
|
|
|
{ |
17
|
|
|
$this->supportsNormalization(new Definition())->shouldReturn(true); |
18
|
|
|
} |
19
|
|
|
|
20
|
|
|
function it_is_a_denormalizer() |
21
|
|
|
{ |
22
|
|
|
$this->shouldHaveType('Symfony\Component\Serializer\Normalizer\DenormalizerInterface'); |
23
|
|
|
} |
24
|
|
|
|
25
|
|
|
function it_supports_denormalizing_to_definition_objects() |
26
|
|
|
{ |
27
|
|
|
$this->supportsDenormalization(array(), 'Xabbuh\XApi\Model\Definition')->shouldReturn(true); |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
function it_supports_denormalizing_to_interaction_definition_objects() |
31
|
|
|
{ |
32
|
|
|
$this->supportsDenormalization(array(), 'Xabbuh\XApi\Model\Interaction\ChoiceInteractionDefinition')->shouldReturn(true); |
33
|
|
|
$this->supportsDenormalization(array(), 'Xabbuh\XApi\Model\Interaction\FillInInteractionDefinition')->shouldReturn(true); |
34
|
|
|
$this->supportsDenormalization(array(), 'Xabbuh\XApi\Model\Interaction\LikertInteractionDefinition')->shouldReturn(true); |
35
|
|
|
$this->supportsDenormalization(array(), 'Xabbuh\XApi\Model\Interaction\LongFillInInteractionDefinition')->shouldReturn(true); |
36
|
|
|
$this->supportsDenormalization(array(), 'Xabbuh\XApi\Model\Interaction\MatchingInteractionDefinition')->shouldReturn(true); |
37
|
|
|
$this->supportsDenormalization(array(), 'Xabbuh\XApi\Model\Interaction\NumericInteractionDefinition')->shouldReturn(true); |
38
|
|
|
$this->supportsDenormalization(array(), 'Xabbuh\XApi\Model\Interaction\OtherInteractionDefinition')->shouldReturn(true); |
39
|
|
|
$this->supportsDenormalization(array(), 'Xabbuh\XApi\Model\Interaction\PerformanceInteractionDefinition')->shouldReturn(true); |
40
|
|
|
$this->supportsDenormalization(array(), 'Xabbuh\XApi\Model\Interaction\SequencingInteractionDefinition')->shouldReturn(true); |
41
|
|
|
$this->supportsDenormalization(array(), 'Xabbuh\XApi\Model\Interaction\TrueFalseInteractionDefinition')->shouldReturn(true); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
function it_throws_an_exception_when_an_unknown_interaction_type_should_be_denormalized() |
45
|
|
|
{ |
46
|
|
|
$this->shouldThrow('Symfony\Component\Serializer\Exception\InvalidArgumentException')->during('denormalize', array( |
47
|
|
|
array('interactionType' => 'foo'), |
48
|
|
|
'Xabbuh\XApi\Model\Definition' |
49
|
|
|
)); |
50
|
|
|
} |
51
|
|
|
} |
52
|
|
|
|