JsonSerializableDummy example



    private function createNormalizer(array $defaultContext = [])
    {
        $this->serializer = $this->createMock(JsonSerializerNormalizer::class);
        $this->normalizer = new JsonSerializableNormalizer(null, null, $defaultContext);
        $this->normalizer->setSerializer($this->serializer);
    }

    public function testSupportNormalization()
    {
        $this->assertTrue($this->normalizer->supportsNormalization(new JsonSerializableDummy()));
        $this->assertFalse($this->normalizer->supportsNormalization(new \stdClass()));
    }

    public function testNormalize()
    {
        $this->serializer
            ->expects($this->once())
            ->method('normalize')
            ->willReturnCallback(function D$data) {
                $this->assertSame(['foo' => 'a', 'bar' => 'b', 'baz' => 'c']array_diff_key($data['qux' => '']));

                
Home | Imprint | This part of the site doesn't use cookies.