|
@@ -22,6 +22,7 @@ use JMS\Serializer\Construction\UnserializeObjectConstructor;
|
|
|
use JMS\Serializer\Handler\HandlerRegistry;
|
|
|
use JMS\Serializer\EventDispatcher\EventDispatcher;
|
|
|
use Doctrine\Common\Annotations\AnnotationReader;
|
|
|
+use JMS\Serializer\Handler\SubscribingHandlerInterface;
|
|
|
use JMS\Serializer\Metadata\Driver\AnnotationDriver;
|
|
|
use JMS\Serializer\GraphNavigator;
|
|
|
use Metadata\MetadataFactory;
|
|
@@ -131,22 +132,7 @@ class GraphNavigatorTest extends \PHPUnit_Framework_TestCase
|
|
|
$event->setType($type['name'], $type['params']);
|
|
|
});
|
|
|
|
|
|
- $subscribingHandlerClass = $this->getMockClass('JMS\Serializer\Handler\SubscribingHandlerInterface', array('getSubscribingMethods', 'serialize'));
|
|
|
- $subscribingHandlerClass::staticExpects($this->once())
|
|
|
- ->method('getSubscribingMethods')
|
|
|
- ->will($this->returnValue(array(array(
|
|
|
- 'type' => $typeName,
|
|
|
- 'format' => 'foo',
|
|
|
- 'direction' => GraphNavigator::DIRECTION_SERIALIZATION,
|
|
|
- 'method' => 'serialize'
|
|
|
- ))));
|
|
|
-
|
|
|
- $subscribingHandler = new $subscribingHandlerClass();
|
|
|
- $subscribingHandler->expects($this->once())
|
|
|
- ->method('serialize')
|
|
|
- ->with($this->equalTo($this->context), $this->equalTo($object));
|
|
|
-
|
|
|
- $this->handlerRegistry->registerSubscribingHandler($subscribingHandler);
|
|
|
+ $this->handlerRegistry->registerSubscribingHandler(new TestSubscribingHandler());
|
|
|
|
|
|
$this->context->expects($this->any())
|
|
|
->method('getDirection')
|
|
@@ -176,3 +162,16 @@ class SerializableClass
|
|
|
{
|
|
|
public $foo = 'bar';
|
|
|
}
|
|
|
+
|
|
|
+class TestSubscribingHandler implements SubscribingHandlerInterface
|
|
|
+{
|
|
|
+ public static function getSubscribingMethods()
|
|
|
+ {
|
|
|
+ return array(array(
|
|
|
+ 'type' => 'JsonSerializable',
|
|
|
+ 'format' => 'foo',
|
|
|
+ 'direction' => GraphNavigator::DIRECTION_SERIALIZATION,
|
|
|
+ 'method' => 'serialize'
|
|
|
+ ));
|
|
|
+ }
|
|
|
+}
|