diff --git a/tests/lib/MVC/Symfony/Component/Serializer/CompoundMatcherNormalizerTest.php b/tests/lib/MVC/Symfony/Component/Serializer/CompoundMatcherNormalizerTest.php index 9388725b48..f496e68738 100644 --- a/tests/lib/MVC/Symfony/Component/Serializer/CompoundMatcherNormalizerTest.php +++ b/tests/lib/MVC/Symfony/Component/Serializer/CompoundMatcherNormalizerTest.php @@ -15,20 +15,30 @@ use Ibexa\Tests\Core\MVC\Symfony\Component\Serializer\Stubs\MatcherStub; use Ibexa\Tests\Core\MVC\Symfony\Component\Serializer\Stubs\SerializerStub; use PHPUnit\Framework\TestCase; +use Symfony\Component\Serializer\Normalizer\ObjectNormalizer; +use Symfony\Component\Serializer\Serializer; final class CompoundMatcherNormalizerTest extends TestCase { public function testNormalization(): void { $matcher = new CompoundStub([]); - $matcher->setSubMatchers([ - 'foo' => new MatcherStub('foo'), - 'bar' => new MatcherStub('bar'), - 'baz' => new MatcherStub('baz'), - ]); + $matcher->setSubMatchers( + [ + 'foo' => new MatcherStub('foo'), + 'bar' => new MatcherStub('bar'), + 'baz' => new MatcherStub('baz'), + ] + ); $normalizer = new CompoundMatcherNormalizer(); - $normalizer->setSerializer(new SerializerStub()); + $serializer = new Serializer( + [ + $normalizer, + new SerializerStub(), + new ObjectNormalizer(), + ] + ); self::assertEquals( [ @@ -40,7 +50,7 @@ public function testNormalization(): void 'config' => [], 'matchersMap' => [], ], - $normalizer->normalize($matcher) + $serializer->normalize($matcher) ); } @@ -52,6 +62,9 @@ public function testSupportsNormalization(): void self::assertFalse($normalizer->supportsNormalization($this->createMock(Matcher::class))); } + /** + * @throws \JsonException + */ public function testSupportsDenormalization(): void { $normalizer = new CompoundMatcherNormalizer(); @@ -63,7 +76,8 @@ public function testSupportsDenormalization(): void ], 'config' => [], 'matchersMap' => [], - ] + ], + JSON_THROW_ON_ERROR ); self::assertTrue($normalizer->supportsDenormalization($data, Compound::class, 'json')); diff --git a/tests/lib/MVC/Symfony/Component/Serializer/HostElementNormalizerTest.php b/tests/lib/MVC/Symfony/Component/Serializer/HostElementNormalizerTest.php index 6821ad5e24..8f2ace75c3 100644 --- a/tests/lib/MVC/Symfony/Component/Serializer/HostElementNormalizerTest.php +++ b/tests/lib/MVC/Symfony/Component/Serializer/HostElementNormalizerTest.php @@ -12,15 +12,24 @@ use Ibexa\Core\MVC\Symfony\Routing\SimplifiedRequest; use Ibexa\Core\MVC\Symfony\SiteAccess\Matcher; use Ibexa\Core\MVC\Symfony\SiteAccess\Matcher\HostElement; -use Ibexa\Tests\Core\MVC\Symfony\Component\Serializer\Stubs\SerializerStub; use PHPUnit\Framework\TestCase; +use Symfony\Component\Serializer\Normalizer\ObjectNormalizer; +use Symfony\Component\Serializer\Serializer; +/** + * @covers \Ibexa\Core\MVC\Symfony\Component\Serializer\HostElementNormalizer + */ final class HostElementNormalizerTest extends TestCase { public function testNormalization(): void { $normalizer = new HostElementNormalizer(); - $normalizer->setSerializer(new SerializerStub()); + $serializer = new Serializer( + [ + $normalizer, + new ObjectNormalizer(), + ] + ); $matcher = new HostElement(2); // Set request and invoke match to initialize HostElement::$hostElements @@ -35,7 +44,7 @@ public function testNormalization(): void 'dev', ], ], - $normalizer->normalize($matcher) + $serializer->normalize($matcher) ); } diff --git a/tests/lib/MVC/Symfony/Component/Serializer/HostTextNormalizerTest.php b/tests/lib/MVC/Symfony/Component/Serializer/HostTextNormalizerTest.php index 6f34cf217f..599f0876f6 100644 --- a/tests/lib/MVC/Symfony/Component/Serializer/HostTextNormalizerTest.php +++ b/tests/lib/MVC/Symfony/Component/Serializer/HostTextNormalizerTest.php @@ -11,15 +11,21 @@ use Ibexa\Core\MVC\Symfony\Component\Serializer\HostTextNormalizer; use Ibexa\Core\MVC\Symfony\SiteAccess\Matcher; use Ibexa\Core\MVC\Symfony\SiteAccess\Matcher\HostText; -use Ibexa\Tests\Core\MVC\Symfony\Component\Serializer\Stubs\SerializerStub; use Ibexa\Tests\Core\Search\TestCase; +use Symfony\Component\Serializer\Normalizer\ObjectNormalizer; +use Symfony\Component\Serializer\Serializer; final class HostTextNormalizerTest extends TestCase { public function testNormalize(): void { $normalizer = new HostTextNormalizer(); - $normalizer->setSerializer(new SerializerStub()); + $serializer = new Serializer( + [ + $normalizer, + new ObjectNormalizer(), + ] + ); $matcher = new HostText([ 'prefix' => 'foo', @@ -33,7 +39,7 @@ public function testNormalize(): void 'suffix' => 'bar', ], ], - $normalizer->normalize($matcher) + $serializer->normalize($matcher) ); } diff --git a/tests/lib/MVC/Symfony/Component/Serializer/RegexHostNormalizerTest.php b/tests/lib/MVC/Symfony/Component/Serializer/RegexHostNormalizerTest.php index 978c74d60b..720a300081 100644 --- a/tests/lib/MVC/Symfony/Component/Serializer/RegexHostNormalizerTest.php +++ b/tests/lib/MVC/Symfony/Component/Serializer/RegexHostNormalizerTest.php @@ -11,15 +11,21 @@ use Ibexa\Core\MVC\Symfony\Component\Serializer\RegexHostNormalizer; use Ibexa\Core\MVC\Symfony\SiteAccess\Matcher; use Ibexa\Core\MVC\Symfony\SiteAccess\Matcher\Regex\Host; -use Ibexa\Tests\Core\MVC\Symfony\Component\Serializer\Stubs\SerializerStub; use Ibexa\Tests\Core\Search\TestCase; +use Symfony\Component\Serializer\Normalizer\ObjectNormalizer; +use Symfony\Component\Serializer\Serializer; final class RegexHostNormalizerTest extends TestCase { public function testNormalize(): void { $normalizer = new RegexHostNormalizer(); - $normalizer->setSerializer(new SerializerStub()); + $serializer = new Serializer( + [ + $normalizer, + new ObjectNormalizer(), + ] + ); $matcher = new Host([ 'regex' => '/^Foo(.*)/(.*)/', @@ -33,7 +39,7 @@ public function testNormalize(): void 'itemNumber' => 2, ], ], - $normalizer->normalize($matcher) + $serializer->normalize($matcher) ); } diff --git a/tests/lib/MVC/Symfony/Component/Serializer/RegexURINormalizerTest.php b/tests/lib/MVC/Symfony/Component/Serializer/RegexURINormalizerTest.php index acdef30d8f..2fa16c2e36 100644 --- a/tests/lib/MVC/Symfony/Component/Serializer/RegexURINormalizerTest.php +++ b/tests/lib/MVC/Symfony/Component/Serializer/RegexURINormalizerTest.php @@ -11,15 +11,21 @@ use Ibexa\Core\MVC\Symfony\Component\Serializer\RegexURINormalizer; use Ibexa\Core\MVC\Symfony\SiteAccess\Matcher; use Ibexa\Core\MVC\Symfony\SiteAccess\Matcher\Regex\URI; -use Ibexa\Tests\Core\MVC\Symfony\Component\Serializer\Stubs\SerializerStub; use Ibexa\Tests\Core\Search\TestCase; +use Symfony\Component\Serializer\Normalizer\ObjectNormalizer; +use Symfony\Component\Serializer\Serializer; final class RegexURINormalizerTest extends TestCase { public function testNormalize(): void { $normalizer = new RegexURINormalizer(); - $normalizer->setSerializer(new SerializerStub()); + $serializer = new Serializer( + [ + $normalizer, + new ObjectNormalizer(), + ] + ); $matcher = new URI([ 'regex' => '/^Foo(.*)/(.*)/', @@ -33,7 +39,7 @@ public function testNormalize(): void 'itemNumber' => 2, ], ], - $normalizer->normalize($matcher) + $serializer->normalize($matcher) ); } diff --git a/tests/lib/MVC/Symfony/Component/Serializer/Stubs/SerializerStub.php b/tests/lib/MVC/Symfony/Component/Serializer/Stubs/SerializerStub.php index 545e5c77ab..0da03526c4 100644 --- a/tests/lib/MVC/Symfony/Component/Serializer/Stubs/SerializerStub.php +++ b/tests/lib/MVC/Symfony/Component/Serializer/Stubs/SerializerStub.php @@ -45,6 +45,6 @@ public function normalize($object, string $format = null, array $context = []): public function supportsNormalization($data, string $format = null): bool { - return true; + return $data instanceof MatcherStub; } } diff --git a/tests/lib/MVC/Symfony/Component/Serializer/URIElementNormalizerTest.php b/tests/lib/MVC/Symfony/Component/Serializer/URIElementNormalizerTest.php index ee02ddd759..6607fa1901 100644 --- a/tests/lib/MVC/Symfony/Component/Serializer/URIElementNormalizerTest.php +++ b/tests/lib/MVC/Symfony/Component/Serializer/URIElementNormalizerTest.php @@ -12,15 +12,21 @@ use Ibexa\Core\MVC\Symfony\Routing\SimplifiedRequest; use Ibexa\Core\MVC\Symfony\SiteAccess\Matcher; use Ibexa\Core\MVC\Symfony\SiteAccess\Matcher\URIElement; -use Ibexa\Tests\Core\MVC\Symfony\Component\Serializer\Stubs\SerializerStub; use PHPUnit\Framework\TestCase; +use Symfony\Component\Serializer\Normalizer\ObjectNormalizer; +use Symfony\Component\Serializer\Serializer; final class URIElementNormalizerTest extends TestCase { public function testNormalization(): void { $normalizer = new URIElementNormalizer(); - $normalizer->setSerializer(new SerializerStub()); + $serializer = new Serializer( + [ + $normalizer, + new ObjectNormalizer(), + ] + ); $matcher = new URIElement(2); // Set request and invoke match to initialize HostElement::$hostElements @@ -32,7 +38,7 @@ public function testNormalization(): void 'elementNumber' => 2, 'uriElements' => ['foo', 'bar'], ], - $normalizer->normalize($matcher) + $serializer->normalize($matcher) ); } diff --git a/tests/lib/MVC/Symfony/Component/Serializer/URITextNormalizerTest.php b/tests/lib/MVC/Symfony/Component/Serializer/URITextNormalizerTest.php index e9940c4c23..e3ebe2fea9 100644 --- a/tests/lib/MVC/Symfony/Component/Serializer/URITextNormalizerTest.php +++ b/tests/lib/MVC/Symfony/Component/Serializer/URITextNormalizerTest.php @@ -11,15 +11,21 @@ use Ibexa\Core\MVC\Symfony\Component\Serializer\URITextNormalizer; use Ibexa\Core\MVC\Symfony\SiteAccess\Matcher; use Ibexa\Core\MVC\Symfony\SiteAccess\Matcher\URIText; -use Ibexa\Tests\Core\MVC\Symfony\Component\Serializer\Stubs\SerializerStub; use Ibexa\Tests\Core\Search\TestCase; +use Symfony\Component\Serializer\Normalizer\ObjectNormalizer; +use Symfony\Component\Serializer\Serializer; final class URITextNormalizerTest extends TestCase { public function testNormalize(): void { $normalizer = new URITextNormalizer(); - $normalizer->setSerializer(new SerializerStub()); + $serializer = new Serializer( + [ + $normalizer, + new ObjectNormalizer(), + ] + ); $matcher = new URIText([ 'prefix' => 'foo', @@ -33,7 +39,7 @@ public function testNormalize(): void 'suffix' => 'bar', ], ], - $normalizer->normalize($matcher) + $serializer->normalize($matcher) ); }