1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace spec\Xabbuh\XApi\Serializer\Normalizer; |
4
|
|
|
|
5
|
|
|
use PhpSpec\ObjectBehavior; |
6
|
|
|
use Xabbuh\XApi\DataFixtures\AccountFixtures; |
7
|
|
|
use XApi\Fixtures\Json\AccountJsonFixtures; |
8
|
|
|
|
9
|
|
|
class AccountNormalizerSpec extends ObjectBehavior |
10
|
|
|
{ |
11
|
|
|
function it_is_a_normalizer() |
12
|
|
|
{ |
13
|
|
|
$this->shouldHaveType('Symfony\Component\Serializer\Normalizer\NormalizerInterface'); |
14
|
|
|
} |
15
|
|
|
|
16
|
|
|
function it_is_a_denormalizer() |
17
|
|
|
{ |
18
|
|
|
$this->shouldHaveType('Symfony\Component\Serializer\Normalizer\DenormalizerInterface'); |
19
|
|
|
} |
20
|
|
|
|
21
|
|
|
function it_normalizes_accounts() |
22
|
|
|
{ |
23
|
|
|
$data = $this->normalize(AccountFixtures::getTypicalAccount()); |
24
|
|
|
|
25
|
|
|
$data->shouldHaveCount(2); |
26
|
|
|
$data->shouldHaveKey('homePage'); |
27
|
|
|
$data->shouldHaveKey('name'); |
28
|
|
|
$data['homePage']->shouldBeEqualTo('https://tincanapi.com'); |
29
|
|
|
$data['name']->shouldBeEqualTo('test'); |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
function it_supports_normalizing_accounts() |
33
|
|
|
{ |
34
|
|
|
$this->supportsNormalization(AccountFixtures::getTypicalAccount())->shouldBe(true); |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
function it_denormalizes_accounts() |
38
|
|
|
{ |
39
|
|
|
$account = $this->denormalize(array('homePage' => 'https://tincanapi.com', 'name' => 'test'), 'Xabbuh\XApi\Model\Account'); |
40
|
|
|
|
41
|
|
|
$account->shouldBeAnInstanceOf('Xabbuh\XApi\Model\Account'); |
42
|
|
|
$account->getHomePage()->shouldReturn('https://tincanapi.com'); |
43
|
|
|
$account->getName()->shouldReturn('test'); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
function it_supports_denormalizing_accounts() |
47
|
|
|
{ |
48
|
|
|
$this->supportsDenormalization(AccountJsonFixtures::getTypicalAccount(), 'Xabbuh\XApi\Model\Account')->shouldBe(true); |
49
|
|
|
} |
50
|
|
|
} |
51
|
|
|
|