| @@ 23-31 (lines=9) @@ | ||
| 20 | */ |
|
| 21 | final class HydratorContainerTest extends AbstractTestCase |
|
| 22 | { |
|
| 23 | public function testAlias() |
|
| 24 | { |
|
| 25 | $handlers = new FallbackHydratorContainer(); |
|
| 26 | $handlers->add(\stdClass::class, function() { return 'value'; }); |
|
| 27 | $handlers->addAlias(\DateTime::class, \stdClass::class); |
|
| 28 | ||
| 29 | $this->assertSame('value', call_user_func($handlers->getHandler(\stdClass::class))); |
|
| 30 | $this->assertSame('value', call_user_func($handlers->getHandler(\DateTime::class))); |
|
| 31 | } |
|
| 32 | ||
| 33 | public function testInterface() |
|
| 34 | { |
|
| @@ 42-50 (lines=9) @@ | ||
| 39 | $this->assertSame('type', call_user_func($hydrators->getHandler(TypeB::class))); |
|
| 40 | } |
|
| 41 | ||
| 42 | public function testInheritance() |
|
| 43 | { |
|
| 44 | $hydrators = new FallbackHydratorContainer(); |
|
| 45 | $hydrators->add(FakeUserParentParent::class, function() { return 'ancestor'; }); |
|
| 46 | ||
| 47 | $this->assertSame('ancestor', call_user_func($hydrators->getHandler(FakeUserParentParent::class))); |
|
| 48 | $this->assertSame('ancestor', call_user_func($hydrators->getHandler(FakeUserParent::class))); |
|
| 49 | $this->assertSame('ancestor', call_user_func($hydrators->getHandler(FakeUser::class))); |
|
| 50 | } |
|
| 51 | ||
| 52 | public function testMultipleInterfacesException() |
|
| 53 | { |
|
| @@ 23-31 (lines=9) @@ | ||
| 20 | */ |
|
| 21 | final class NormalizerContainerTest extends AbstractTestCase |
|
| 22 | { |
|
| 23 | public function testAlias() |
|
| 24 | { |
|
| 25 | $normalizers = new FallbackNormalizerContainer(); |
|
| 26 | $normalizers->add(\stdClass::class, function() { return 'value'; }); |
|
| 27 | $normalizers->addAlias(\DateTime::class, \stdClass::class); |
|
| 28 | ||
| 29 | $this->assertSame('value', call_user_func($normalizers->getHandler(\stdClass::class))); |
|
| 30 | $this->assertSame('value', call_user_func($normalizers->getHandler(\DateTime::class))); |
|
| 31 | } |
|
| 32 | ||
| 33 | public function testInterface() |
|
| 34 | { |
|
| @@ 42-50 (lines=9) @@ | ||
| 39 | $this->assertSame('type', call_user_func($normalizers->getHandler(TypeB::class))); |
|
| 40 | } |
|
| 41 | ||
| 42 | public function testInheritance() |
|
| 43 | { |
|
| 44 | $normalizers = new FallbackNormalizerContainer(); |
|
| 45 | $normalizers->add(FakeUserParentParent::class, function() { return 'ancestor'; }); |
|
| 46 | ||
| 47 | $this->assertSame('ancestor', call_user_func($normalizers->getHandler(FakeUserParentParent::class))); |
|
| 48 | $this->assertSame('ancestor', call_user_func($normalizers->getHandler(FakeUserParent::class))); |
|
| 49 | $this->assertSame('ancestor', call_user_func($normalizers->getHandler(FakeUser::class))); |
|
| 50 | } |
|
| 51 | ||
| 52 | public function testMultipleInterfacesException() |
|
| 53 | { |
|