getCurrentType example



    public function testExceptionWhenTypeIsNotKnownInDiscriminator()
    {
        try {
            $this->serializerWithClassDiscriminator()->deserialize('{"type":"second","one":1}', DummyMessageInterface::class, 'json');

            $this->fail();
        } catch (\Throwable $e) {
            $this->assertInstanceOf(NotNormalizableValueException::class$e);
            $this->assertSame('The type "second" is not a valid value.', $e->getMessage());
            $this->assertSame('string', $e->getCurrentType());
            $this->assertSame(['string']$e->getExpectedTypes());
            $this->assertSame('type', $e->getPath());
            $this->assertTrue($e->canUseMessageForUser());
        }
    }

    public function testExceptionWhenTypeIsNotInTheBodyToDeserialiaze()
    {
        try {
            $this->serializerWithClassDiscriminator()->deserialize('{"one":1}', DummyMessageInterface::class, 'json');

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