Conditions | 1 |
Paths | 1 |
Total Lines | 24 |
Code Lines | 16 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
20 | function testConverter() |
||
21 | { |
||
22 | $source = [ |
||
23 | 'nick' => 'test', |
||
24 | 'collection' => [ |
||
25 | ['id' => 1], |
||
26 | ['id' => 2] |
||
27 | ] |
||
28 | ]; |
||
29 | |||
30 | $converter = $this->app->get(Converter::class); |
||
31 | |||
32 | $object = $converter->toObject($source); |
||
33 | |||
34 | $this->assertInternalType('object', $object); |
||
35 | $this->assertSame($object->nick, 'test'); |
||
36 | $this->assertInternalType('array', $object->collection); |
||
37 | $this->assertInternalType('object', $object->collection[0]); |
||
38 | $this->assertSame(1, $object->collection[0]->id); |
||
39 | $this->assertSame(2, $object->collection[1]->id); |
||
40 | |||
41 | $array = $converter->toArray($object); |
||
42 | $this->assertSame($source, $array); |
||
43 | } |
||
44 | } |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.