Completed
Pull Request — master (#5)
by Christian
08:25
created

AccountNormalizerSpec::it_is_a_denormalizer()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 0
cts 4
cp 0
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 2
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