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