/** * @test */ public function shouldRegisterEncoder() { $encoder = $this->getMockBuilder(EncoderInterface::class)->getMock(); $factory = function () use($encoder) { return $encoder; }; $this->registry->registerEncoder('test', $factory); $this->assertSame($factory, $this->registry->getEncoder('test')); }
/** * Returns configured decoders/encoders factory * * @param FactoryInterface $factory * @return JsonApiRegistry */ private function getRegistry(FactoryInterface $factory) { $registry = new JsonApiRegistry(); $decoder = $this->getDecoder(); $registry->registerDecoder('jsonapi.decoders.jsonapi', function () use($decoder) { return $decoder; }); $encoder = $this->getEncoder($factory); $registry->registerEncoder('jsonapi.encoders.jsonapi', function () use($encoder) { return $encoder; }); return $registry; }