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.

AbstractDriverTest   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 113
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 3
dl 0
loc 113
c 0
b 0
f 0
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
createDriver() 0 1 ?
B testUser() 0 96 3
A testEmptyClass() 0 8 1
1
<?php
2
3
namespace Hateoas\Tests\Configuration\Metadata\Driver;
4
5
use Hateoas\Configuration\Relation;
6
use Hateoas\Configuration\RelationProvider;
7
use Metadata\Driver\DriverInterface;
8
use Hateoas\Tests\TestCase;
9
10
abstract class AbstractDriverTest extends TestCase
11
{
12
    /**
13
     * @return DriverInterface
14
     */
15
    abstract public function createDriver();
16
17
    public function testUser()
18
    {
19
        $driver = $this->createDriver();
20
        $class = new \ReflectionClass('Hateoas\Tests\Fixtures\User');
21
        $classMetadata = $driver->loadMetadataForClass($class);
22
23
        $this->assertInstanceOf('Hateoas\Configuration\Metadata\ClassMetadata', $classMetadata);
24
25
        /** @var $relations Relation[] */
26
        $relations = $classMetadata->getRelations();
27
28
        $this->assertInternalType('array', $relations);
29
        foreach ($relations as $relation) {
30
            $this->assertInstanceOf('Hateoas\Configuration\Relation', $relation);
31
        }
32
33
        $i = 0;
34
35
        $relation = $relations[$i++];
36
        $this->assertSame('self', $relation->getName());
37
        $this->assertSame('http://hateoas.web/user/42', $relation->getHref());
38
        $this->assertSame(['type' => 'application/json'], $relation->getAttributes());
39
        $this->assertNull($relation->getEmbedded());
40
        $this->assertNull($relation->getExclusion());
41
42
        $relation = $relations[$i++];
43
        $this->assertSame('foo', $relation->getName());
44
        $this->assertInstanceOf('Hateoas\Configuration\Route', $relation->getHref());
45
        $this->assertSame('user_get', $relation->getHref()->getName());
46
        $this->assertSame(['id' => 'expr(object.getId())'], $relation->getHref()->getParameters());
47
        $this->assertFalse($relation->getHref()->isAbsolute());
48
        $this->assertInstanceOf('Hateoas\Configuration\Embedded', $relation->getEmbedded());
49
        $this->assertSame('expr(object.getFoo())', $relation->getEmbedded()->getContent());
50
        $this->assertNull($relation->getEmbedded()->getXmlElementName());
51
        $this->assertNull($relation->getEmbedded()->getExclusion());
52
53
        $relation = $relations[$i++];
54
        $this->assertSame('bar', $relation->getName());
55
        $this->assertSame('foo', $relation->getHref());
56
        $this->assertInstanceOf('Hateoas\Configuration\Embedded', $relation->getEmbedded());
57
        $this->assertSame('data', $relation->getEmbedded()->getContent());
58
        $this->assertSame('barTag', $relation->getEmbedded()->getXmlElementName());
59
        $this->assertNull($relation->getEmbedded()->getExclusion());
60
61
        $relation = $relations[$i++];
62
        $this->assertSame('baz', $relation->getName());
63
        $this->assertInstanceOf('Hateoas\Configuration\Route', $relation->getHref());
64
        $this->assertSame('user_get', $relation->getHref()->getName());
65
        $this->assertSame(['id' => 'expr(object.getId())'], $relation->getHref()->getParameters());
66
        $this->assertTrue($relation->getHref()->isAbsolute());
67
        $this->assertNull($relation->getExclusion());
68
69
        $relation = $relations[$i++];
70
        $this->assertSame('boom', $relation->getName());
71
        $this->assertInstanceOf('Hateoas\Configuration\Route', $relation->getHref());
72
        $this->assertSame('user_get', $relation->getHref()->getName());
73
        $this->assertSame(['id' => 'expr(object.getId())'], $relation->getHref()->getParameters());
74
        $this->assertFalse($relation->getHref()->isAbsolute());
75
        $this->assertNull($relation->getExclusion());
76
77
        $relation = $relations[$i++];
78
        $this->assertSame('badaboom', $relation->getName());
79
        $this->assertNull($relation->getHref());
80
        $this->assertInstanceOf('Hateoas\Configuration\Embedded', $relation->getEmbedded());
81
        $this->assertSame('expr(object.getFoo())', $relation->getEmbedded()->getContent());
82
        $this->assertNull($relation->getExclusion());
83
84
        $relation = $relations[$i++];
85
        $this->assertSame('hello', $relation->getName());
86
        $this->assertSame('/hello', $relation->getHref());
87
        $this->assertInstanceOf('Hateoas\Configuration\Exclusion', $relation->getExclusion());
88
        $this->assertSame(['group1', 'group2'], $relation->getExclusion()->getGroups());
89
        $this->assertSame(1.0, $relation->getExclusion()->getSinceVersion());
90
        $this->assertSame(2.2, $relation->getExclusion()->getUntilVersion());
91
        $this->assertSame(42, $relation->getExclusion()->getMaxDepth());
92
        $this->assertSame('foo', $relation->getExclusion()->getExcludeIf());
93
        $this->assertInstanceOf('Hateoas\Configuration\Embedded', $relation->getEmbedded());
94
        $this->assertSame('hello', $relation->getEmbedded()->getContent());
95
        $this->assertInstanceOf('Hateoas\Configuration\Exclusion', $relation->getEmbedded()->getExclusion());
96
        $this->assertSame(['group3', 'group4'], $relation->getEmbedded()->getExclusion()->getGroups());
97
        $this->assertSame(1.1, $relation->getEmbedded()->getExclusion()->getSinceVersion());
98
        $this->assertSame(2.3, $relation->getEmbedded()->getExclusion()->getUntilVersion());
99
        $this->assertSame(43, $relation->getEmbedded()->getExclusion()->getMaxDepth());
100
        $this->assertSame('bar', $relation->getEmbedded()->getExclusion()->getExcludeIf());
101
102
        /** @var $relations RelationProvider[] */
103
        $relationProviders = $classMetadata->getRelationProviders();
104
105
        $this->assertInternalType('array', $relationProviders);
106
        foreach ($relationProviders as $relationProvider) {
107
            $this->assertInstanceOf('Hateoas\Configuration\RelationProvider', $relationProvider);
108
        }
109
110
        $relationProvider = current($relationProviders);
111
        $this->assertSame('getRelations', $relationProvider->getName());
112
    }
113
114
    public function testEmptyClass()
115
    {
116
        $driver = $this->createDriver();
117
        $class = new \ReflectionClass('Hateoas\Tests\Fixtures\EmptyClass');
118
        $classMetadata = $driver->loadMetadataForClass($class);
119
120
        $this->assertNull($classMetadata);
121
    }
122
}
123