Completed
Pull Request — master (#21)
by Christian
03:16
created

AccountNormalizerSpec   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
c 1
b 0
f 0
lcom 0
cbo 3
dl 0
loc 31
ccs 0
cts 23
cp 0
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A it_is_a_normalizer() 0 4 1
A it_is_a_denormalizer() 0 4 1
A it_supports_normalizing_accounts() 0 4 1
A it_denormalizes_accounts() 0 8 1
A it_supports_denormalizing_accounts() 0 4 1
1
<?php
2
3
namespace spec\Xabbuh\XApi\Serializer\Normalizer;
4
5
use PhpSpec\ObjectBehavior;
6
use Xabbuh\XApi\DataFixtures\AccountFixtures;
7
use Xabbuh\XApi\Model\IRL;
8
use XApi\Fixtures\Json\AccountJsonFixtures;
9
10
class AccountNormalizerSpec extends ObjectBehavior
11
{
12
    function it_is_a_normalizer()
13
    {
14
        $this->shouldHaveType('Symfony\Component\Serializer\Normalizer\NormalizerInterface');
15
    }
16
17
    function it_is_a_denormalizer()
18
    {
19
        $this->shouldHaveType('Symfony\Component\Serializer\Normalizer\DenormalizerInterface');
20
    }
21
22
    function it_supports_normalizing_accounts()
23
    {
24
        $this->supportsNormalization(AccountFixtures::getTypicalAccount())->shouldBe(true);
25
    }
26
27
    function it_denormalizes_accounts()
28
    {
29
        $account = $this->denormalize(array('homePage' => 'https://tincanapi.com', 'name' => 'test'), 'Xabbuh\XApi\Model\Account');
30
31
        $account->shouldBeAnInstanceOf('Xabbuh\XApi\Model\Account');
32
        $account->getHomePage()->equals(IRL::fromString('https://tincanapi.com'))->shouldReturn(true);
33
        $account->getName()->shouldReturn('test');
34
    }
35
36
    function it_supports_denormalizing_accounts()
37
    {
38
        $this->supportsDenormalization(AccountJsonFixtures::getTypicalAccount(), 'Xabbuh\XApi\Model\Account')->shouldBe(true);
39
    }
40
}
41