Ejemplo n.º 1
0
 public function __construct(RequestStack $requestStack, RestSerializerFactory $serializerFactory, VersionParser $versionParser, FormatParser $formatParser, array $defaultTransformersNames, array $defaultEncodersNames)
 {
     $this->requestStack = $requestStack;
     $this->serializerFactory = $serializerFactory;
     $this->versionParser = $versionParser;
     $this->formatParser = $formatParser;
     $this->defaultTransformersNames = $defaultTransformersNames;
     $this->serializer = $serializerFactory->buildDefaultSerializer($defaultTransformersNames, $defaultEncodersNames);
 }
 public function testBuildDefaultSerializer()
 {
     $defaultTransformersNames = array('sobolan.restnegotiator.transformer.list');
     $defaultEncodersNames = array('sobolan.restnegotiator.encoder.json');
     $jsonEncoderMock = $this->getMockBuilder('Symfony\\Component\\Serializer\\Encoder\\JsonEncoder')->disableOriginalConstructor()->getMock();
     $this->container->set('sobolan.restnegotiator.encoder.json', $jsonEncoderMock);
     $serializerFactory = new RestSerializerFactory();
     $serializerFactory->setContainer($this->container);
     $instance = $serializerFactory->buildDefaultSerializer($defaultTransformersNames, $defaultEncodersNames);
     $this->assertInstanceOf('SoboLAN\\RestNegotiator\\Serializer\\RestSerializerInterface', $instance);
 }