GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 1978d2...e2f699 )
by William
03:55
created

EmbeddedsFactoryTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 7

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 1
c 2
b 0
f 0
lcom 1
cbo 7
dl 0
loc 49
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B test() 0 46 1
1
<?php
2
3
namespace Hateoas\Tests\Factory;
4
5
use Hateoas\Configuration\Embedded;
6
use Hateoas\Configuration\Relation;
7
use Hateoas\Factory\EmbeddedsFactory;
8
use Hateoas\Tests\TestCase;
9
use Prophecy\Argument;
10
11
class EmbeddedsFactoryTest extends TestCase
12
{
13
    public function test()
14
    {
15
        $relations = array(
16
            new Relation('self', '/users/1'),
17
            new Relation('friend', '/users/42', 'expr(object.getFriend())'),
18
            new Relation('expr(object.getManagerRel())', '/users/42', new Embedded('expr(object.getManager())', 'expr(object.getXmlElementName())')),
19
        );
20
        $object = new \StdClass();
21
        $context = $this->prophesize('JMS\Serializer\SerializationContext')->reveal();
22
23
        $relationsRepositoryProphecy = $this->prophesize('Hateoas\Configuration\RelationsRepository');
24
        $relationsRepositoryProphecy
25
            ->getRelations($object)
26
            ->willReturn($relations)
27
            ->shouldBeCalledTimes(1)
28
        ;
29
30
        $ELProphecy = $this->prophesize('Hateoas\Expression\ExpressionEvaluator');
31
        $ELProphecy->evaluate('expr(object.getFriend())', $object)->willReturn(42)->shouldBeCalledTimes(1);
32
        $ELProphecy->evaluate('expr(object.getManager())', $object)->willReturn(42)->shouldBeCalledTimes(1);
33
        $ELProphecy->evaluate('expr(object.getManagerRel())', $object)->willReturn(42)->shouldBeCalledTimes(1);
34
        $ELProphecy->evaluate('expr(object.getXmlElementName())', $object)->willReturn(42)->shouldBeCalledTimes(1);
35
        $ELProphecy->evaluate(Argument::any(), $object)->willReturnArgument();
36
37
        $exclusionManagerProphecy = $this->prophesize('Hateoas\Serializer\ExclusionManager');
38
        $exclusionManagerProphecy->shouldSkipEmbedded($object, $relations[0], $context)->willReturn(true);
39
        $exclusionManagerProphecy->shouldSkipEmbedded($object, $relations[1], $context)->willReturn(false);
40
        $exclusionManagerProphecy->shouldSkipEmbedded($object, $relations[2], $context)->willReturn(false);
41
42
        $embeddedsFactory = new EmbeddedsFactory(
43
            $relationsRepositoryProphecy->reveal(),
44
            $ELProphecy->reveal(),
45
            $exclusionManagerProphecy->reveal()
46
        );
47
48
        $embeddeds = $embeddedsFactory->create($object, $context);
49
50
        $this->assertCount(2, $embeddeds);
51
        $this->assertInstanceOf('Hateoas\Model\Embedded', $embeddeds[0]);
52
        $this->assertSame('friend', $embeddeds[0]->getRel());
53
        $this->assertSame(42, $embeddeds[0]->getData());
54
        $this->assertInstanceOf('Hateoas\Model\Embedded', $embeddeds[1]);
55
        $this->assertSame(42, $embeddeds[1]->getRel());
56
        $this->assertSame(42, $embeddeds[1]->getData());
57
        $this->assertSame(42, $embeddeds[1]->getXmlElementName());
58
    }
59
}
60