These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
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 |
||
24 | ->object($classMetadata) |
||
25 | ->isInstanceOf('Hateoas\Configuration\Metadata\ClassMetadata') |
||
26 | ; |
||
27 | |||
28 | /** @var $relations Relation[] */ |
||
29 | $relations = $classMetadata->getRelations(); |
||
30 | |||
31 | $this->array($relations); |
||
32 | foreach ($relations as $relation) { |
||
33 | $this |
||
34 | ->object($relation) |
||
35 | ->isInstanceOf('Hateoas\Configuration\Relation') |
||
36 | ; |
||
37 | } |
||
38 | |||
39 | $i = 0; |
||
40 | |||
41 | $relation = $relations[$i++]; |
||
42 | $this |
||
0 ignored issues
–
show
|
|||
43 | ->string($relation->getName()) |
||
44 | ->isEqualTo('self') |
||
45 | ->string($relation->getHref()) |
||
46 | ->isEqualTo('http://hateoas.web/user/42') |
||
47 | ->array($relation->getAttributes()) |
||
48 | ->isEqualTo(array( |
||
49 | 'type' => 'application/json', |
||
50 | )) |
||
51 | ->variable($relation->getEmbedded()) |
||
52 | ->isNull() |
||
53 | ->variable($relation->getExclusion()) |
||
54 | ->isNull() |
||
55 | ; |
||
56 | |||
57 | $relation = $relations[$i++]; |
||
58 | $this |
||
59 | ->string($relation->getName()) |
||
60 | ->isEqualTo('foo') |
||
61 | ->object($relation->getHref()) |
||
62 | ->isInstanceOf('Hateoas\Configuration\Route') |
||
63 | ->and($route = $relation->getHref()) |
||
64 | ->string($route->getName()) |
||
65 | ->isEqualTo('user_get') |
||
66 | ->array($route->getParameters()) |
||
67 | ->isEqualTo(array( |
||
68 | 'id' => 'expr(object.getId())', |
||
69 | )) |
||
70 | ->boolean($route->isAbsolute()) |
||
71 | ->isEqualTo(false) |
||
72 | ->object($relation->getEmbedded()) |
||
73 | ->isInstanceOf('Hateoas\Configuration\Embedded') |
||
74 | ->and($embedded = $relation->getEmbedded()) |
||
75 | ->string($embedded->getContent()) |
||
76 | ->isEqualTo('expr(object.getFoo())') |
||
77 | ->variable($embedded->getXmlElementName()) |
||
78 | ->isNull() |
||
79 | ->variable($relation->getExclusion()) |
||
80 | ->isNull() |
||
81 | ; |
||
82 | |||
83 | $relation = $relations[$i++]; |
||
84 | $this |
||
0 ignored issues
–
show
The method
string() does not exist on mageekguy\atoum\asserters\string . Did you maybe mean __toString() ?
This check marks calls to methods that do not seem to exist on an object. This is most likely the result of a method being renamed without all references to it being renamed likewise.
Loading history...
|
|||
85 | ->string($relation->getName()) |
||
86 | ->isEqualTo('bar') |
||
87 | ->string($relation->getHref()) |
||
88 | ->isEqualTo('foo') |
||
89 | ->object($relation->getEmbedded()) |
||
90 | ->isInstanceOf('Hateoas\Configuration\Embedded') |
||
91 | ->and($embedded = $relation->getEmbedded()) |
||
92 | ->variable($embedded->getContent()) |
||
93 | ->isEqualTo('data') |
||
94 | ->string($embedded->getXmlElementName()) |
||
95 | ->isEqualTo('barTag') |
||
96 | ->variable($relation->getExclusion()) |
||
97 | ->isNull() |
||
98 | ; |
||
99 | |||
100 | $relation = $relations[$i++]; |
||
101 | $this |
||
102 | ->string($relation->getName()) |
||
103 | ->isEqualTo('baz') |
||
104 | ->object($relation->getHref()) |
||
105 | ->isInstanceOf('Hateoas\Configuration\Route') |
||
106 | ->and($route = $relation->getHref()) |
||
107 | ->string($route->getName()) |
||
108 | ->isEqualTo('user_get') |
||
109 | ->array($route->getParameters()) |
||
110 | ->isEqualTo(array( |
||
111 | 'id' => 'expr(object.getId())', |
||
112 | )) |
||
113 | ->boolean($route->isAbsolute()) |
||
114 | ->isEqualTo(true) |
||
115 | ->variable($relation->getExclusion()) |
||
116 | ->isNull() |
||
117 | ; |
||
118 | |||
119 | $relation = $relations[$i++]; |
||
120 | $this |
||
121 | ->string($relation->getName()) |
||
122 | ->isEqualTo('boom') |
||
123 | ->object($relation->getHref()) |
||
124 | ->isInstanceOf('Hateoas\Configuration\Route') |
||
125 | ->and($route = $relation->getHref()) |
||
126 | ->string($route->getName()) |
||
127 | ->isEqualTo('user_get') |
||
128 | ->array($route->getParameters()) |
||
129 | ->isEqualTo(array( |
||
130 | 'id' => 'expr(object.getId())', |
||
131 | )) |
||
132 | ->boolean($route->isAbsolute()) |
||
133 | ->isEqualTo(false) |
||
134 | ->variable($relation->getExclusion()) |
||
135 | ->isNull() |
||
136 | ; |
||
137 | |||
138 | $relation = $relations[$i++]; |
||
139 | $this |
||
140 | ->string($relation->getName()) |
||
141 | ->isEqualTo('badaboom') |
||
142 | ->variable($relation->getHref()) |
||
143 | ->isNull() |
||
144 | ->object($relation->getEmbedded()) |
||
145 | ->isInstanceOf('Hateoas\Configuration\Embedded') |
||
146 | ->and($embedded = $relation->getEmbedded()) |
||
147 | ->string($embedded->getContent()) |
||
148 | ->isEqualTo('expr(object.getFoo())') |
||
149 | ->variable($relation->getExclusion()) |
||
150 | ->isNull() |
||
151 | ; |
||
152 | |||
153 | $relation = $relations[$i++]; |
||
154 | $this |
||
155 | ->string($relation->getName()) |
||
156 | ->isEqualTo('hello') |
||
157 | ->variable($relation->getHref()) |
||
158 | ->isEqualTo('/hello') |
||
159 | ->object($relation->getExclusion()) |
||
160 | ->isInstanceOf('Hateoas\Configuration\Exclusion') |
||
161 | ->and($exclusion = $relation->getExclusion()) |
||
162 | ->array($exclusion->getGroups()) |
||
163 | ->isEqualTo(array('group1', 'group2')) |
||
164 | ->float($exclusion->getSinceVersion()) |
||
165 | ->isEqualTo(1.0) |
||
166 | ->float($exclusion->getUntilVersion()) |
||
167 | ->isEqualTo(2.2) |
||
168 | ->integer($exclusion->getMaxDepth()) |
||
169 | ->isEqualTo(42) |
||
170 | ->string($exclusion->getExcludeIf()) |
||
171 | ->isEqualTo('foo') |
||
172 | ->object($relation->getEmbedded()) |
||
173 | ->isInstanceOf('Hateoas\Configuration\Embedded') |
||
174 | ->and($embedded = $relation->getEmbedded()) |
||
175 | ->string($embedded->getContent()) |
||
176 | ->isEqualTo('hello') |
||
177 | ->object($embedded->getExclusion()) |
||
178 | ->isInstanceOf('Hateoas\Configuration\Exclusion') |
||
179 | ->and($exclusion = $embedded->getExclusion()) |
||
180 | ->array($exclusion->getGroups()) |
||
181 | ->isEqualTo(array('group3', 'group4')) |
||
182 | ->float($exclusion->getSinceVersion()) |
||
183 | ->isEqualTo(1.1) |
||
184 | ->float($exclusion->getUntilVersion()) |
||
185 | ->isEqualTo(2.3) |
||
186 | ->integer($exclusion->getMaxDepth()) |
||
187 | ->isEqualTo(43) |
||
188 | ->string($exclusion->getExcludeIf()) |
||
189 | ->isEqualTo('bar') |
||
190 | ; |
||
191 | |||
192 | /** @var $relations RelationProvider[] */ |
||
193 | $relationProviders = $classMetadata->getRelationProviders(); |
||
194 | |||
195 | $this->array($relationProviders); |
||
196 | foreach ($relationProviders as $relationProvider) { |
||
197 | $this |
||
198 | ->object($relationProvider) |
||
199 | ->isInstanceOf('Hateoas\Configuration\RelationProvider') |
||
200 | ; |
||
201 | } |
||
202 | |||
203 | $relationProvider = current($relationProviders); |
||
204 | $this |
||
205 | ->string($relationProvider->getName()) |
||
206 | ->isEqualTo('getRelations') |
||
207 | ; |
||
208 | } |
||
209 | |||
210 | public function testEmptyClass() |
||
211 | { |
||
212 | $driver = $this->createDriver(); |
||
213 | $class = new \ReflectionClass('Hateoas\Tests\Fixtures\EmptyClass'); |
||
214 | $classMetadata = $driver->loadMetadataForClass($class); |
||
215 | |||
216 | $this |
||
217 | ->variable($classMetadata) |
||
218 | ->isNull() |
||
219 | ; |
||
220 | } |
||
221 | } |
||
222 |
This check marks calls to methods that do not seem to exist on an object.
This is most likely the result of a method being renamed without all references to it being renamed likewise.