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.

RelationsRepositoryTest   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 72
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 5
dl 0
loc 72
c 0
b 0
f 0
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A testEmptyGetRelations() 0 10 1
B testMetadataFactoryRelations() 0 25 1
A testRelationProviderRelations() 0 16 1
A prophesizeRelationProvider() 0 10 2
A prophesizeMetadataFactory() 0 4 1
1
<?php
2
3
namespace Hateoas\Tests\Configuration;
4
5
use Hateoas\Tests\TestCase;
6
use Hateoas\Configuration\Relation;
7
use Hateoas\Configuration\RelationsRepository;
8
use Prophecy\Argument;
9
10
class RelationsRepositoryTest extends TestCase
11
{
12
    public function testEmptyGetRelations()
13
    {
14
        $relationsRepository = new RelationsRepository(
15
            $this->prophesizeMetadataFactory()->reveal(),
16
            $this->prophesizeRelationProvider()->reveal()
17
        );
18
        $object = new \StdClass();
19
20
        $this->assertEmpty($relationsRepository->getRelations($object));
21
    }
22
23
    public function testMetadataFactoryRelations()
24
    {
25
        $relations = array(
26
            new Relation('', ''),
27
            new Relation('', ''),
28
        );
29
30
        $classMetadataProphecy = $this->prophesize('Hateoas\Configuration\Metadata\ClassMetadataInterface');
31
        $classMetadataProphecy
32
            ->getRelations()
33
            ->willReturn($relations)
34
            ->shouldBeCalledTimes(1)
35
        ;
36
        $metadataFactoryProphecy = $this->prophesizeMetadataFactory();
37
        $metadataFactoryProphecy
38
            ->getMetadataForClass('stdClass')
39
            ->willReturn($classMetadataProphecy->reveal())
40
        ;
41
        $relationsRepository = new RelationsRepository(
42
            $metadataFactoryProphecy->reveal(),
43
            $this->prophesizeRelationProvider()->reveal()
44
        );
45
46
        $this->assertSame($relations, $relationsRepository->getRelations(new \StdClass()));
47
    }
48
49
    public function testRelationProviderRelations()
50
    {
51
        $relations = array(
52
            new Relation('', ''),
53
            new Relation('', ''),
54
        );
55
56
        $object = new \StdClass();
57
58
        $relationsRepository = new RelationsRepository(
59
            $this->prophesizeMetadataFactory()->reveal(),
60
            $this->prophesizeRelationProvider($relations, $object)->reveal()
61
        );
62
63
        $this->assertSame($relations, $relationsRepository->getRelations($object));
64
    }
65
66
    private function prophesizeRelationProvider($relations = array(), $object = null)
67
    {
68
        $relationProviderProphecy = $this->prophesize('Hateoas\Configuration\Provider\RelationProvider');
69
        $relationProviderProphecy
70
            ->getRelations($object ?: Argument::any())
71
            ->willReturn($relations)
72
        ;
73
74
        return $relationProviderProphecy;
75
    }
76
77
    private function prophesizeMetadataFactory()
78
    {
79
        return $this->prophesize('Metadata\MetadataFactoryInterface');
80
    }
81
}
82