/**
  * @test
  */
 public function shouldSerializeModelToJsonUsingJMSSerializer()
 {
     $object = new \stdClass();
     $viewModel = new SerializedJsonModel($object);
     $viewModel->setSerializer($this->serializerMock);
     $viewModel->setContext(SerializationContext::create());
     $serializedJson = json_encode(array('foo' => 'bar'));
     $this->serializerMock->expects($this->once())->method('serialize')->with($object, 'json')->will($this->returnValue($serializedJson));
     $this->assertEquals($serializedJson, $viewModel->serialize());
 }
 /**
  * @param ServiceLocatorInterface $serviceLocator
  * @return SerializationContext
  */
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     /** @var ServiceManager $serviceLocator */
     /** @var SerializerInterface $serializer */
     $serializer = $serviceLocator->get('Aeris\\ZendRestModule\\Serializer');
     /** @var SerializationContext $context */
     $context = $serviceLocator->create('Aeris\\ZendRestModule\\Serializer\\SerializationContext');
     $jsonModel = new SerializedJsonModel();
     $jsonModel->setSerializer($serializer);
     $jsonModel->setContext($context);
     return $jsonModel;
 }