|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace spec\Xabbuh\XApi\Serializer\Normalizer; |
|
4
|
|
|
|
|
5
|
|
|
use PhpSpec\ObjectBehavior; |
|
6
|
|
|
use Xabbuh\XApi\Model\LanguageMap; |
|
7
|
|
|
|
|
8
|
|
|
class LanguageMapNormalizerSpec extends ObjectBehavior |
|
9
|
|
|
{ |
|
10
|
|
|
function it_is_a_normalizer() |
|
11
|
|
|
{ |
|
12
|
|
|
$this->shouldHaveType('Symfony\Component\Serializer\Normalizer\NormalizerInterface'); |
|
13
|
|
|
} |
|
14
|
|
|
|
|
15
|
|
|
function it_is_a_denormalizer() |
|
16
|
|
|
{ |
|
17
|
|
|
$this->shouldHaveType('Symfony\Component\Serializer\Normalizer\DenormalizerInterface'); |
|
18
|
|
|
} |
|
19
|
|
|
|
|
20
|
|
|
function it_supports_normalizing_language_map_objects() |
|
21
|
|
|
{ |
|
22
|
|
|
$this->supportsNormalization(new LanguageMap())->shouldReturn(true); |
|
23
|
|
|
} |
|
24
|
|
|
|
|
25
|
|
|
function it_normalizes_language_map_instances_to_arrays() |
|
26
|
|
|
{ |
|
27
|
|
|
$map = array( |
|
28
|
|
|
'de-DE' => 'teilgenommen', |
|
29
|
|
|
'en-GB' => 'attended', |
|
30
|
|
|
'en-US' => 'attended', |
|
31
|
|
|
); |
|
32
|
|
|
|
|
33
|
|
|
$normalizedMap = $this->normalize(LanguageMap::create($map)); |
|
34
|
|
|
|
|
35
|
|
|
$normalizedMap->shouldBeArray(); |
|
36
|
|
|
$normalizedMap->shouldHaveCount(3); |
|
37
|
|
|
$normalizedMap->shouldHaveKeyWithValue('de-DE', 'teilgenommen'); |
|
38
|
|
|
$normalizedMap->shouldHaveKeyWithValue('en-GB', 'attended'); |
|
39
|
|
|
$normalizedMap->shouldHaveKeyWithValue('en-US', 'attended'); |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
function it_supports_denormalizing_to_language_map_objects() |
|
43
|
|
|
{ |
|
44
|
|
|
$this->supportsDenormalization(array(), 'Xabbuh\XApi\Model\LanguageMap')->shouldReturn(true); |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
function it_denormalizes_arrays_to_language_map_instances() |
|
48
|
|
|
{ |
|
49
|
|
|
$map = array( |
|
50
|
|
|
'de-DE' => 'teilgenommen', |
|
51
|
|
|
'en-GB' => 'attended', |
|
52
|
|
|
'en-US' => 'attended', |
|
53
|
|
|
); |
|
54
|
|
|
$languageMap = LanguageMap::create($map); |
|
55
|
|
|
|
|
56
|
|
|
$this->denormalize($map, 'Xabbuh\XApi\Model\LanguageMap')->equals($languageMap)->shouldReturn(true); |
|
57
|
|
|
} |
|
58
|
|
|
} |
|
59
|
|
|
|