diff --git a/Tests/Normalizer/AbstractObjectNormalizerTest.php b/Tests/Normalizer/AbstractObjectNormalizerTest.php index 711f51ee9..3de0ac086 100644 --- a/Tests/Normalizer/AbstractObjectNormalizerTest.php +++ b/Tests/Normalizer/AbstractObjectNormalizerTest.php @@ -40,7 +40,7 @@ class AbstractObjectNormalizerTest extends TestCase public function testDenormalize() { $normalizer = new AbstractObjectNormalizerDummy(); - $normalizedData = $normalizer->denormalize(['foo' => 'foo', 'bar' => 'bar', 'baz' => 'baz'], __NAMESPACE__.'\Dummy'); + $normalizedData = $normalizer->denormalize(['foo' => 'foo', 'bar' => 'bar', 'baz' => 'baz'], Dummy::class); $this->assertSame('foo', $normalizedData->foo); $this->assertNull($normalizedData->bar); @@ -50,12 +50,12 @@ public function testDenormalize() public function testInstantiateObjectDenormalizer() { $data = ['foo' => 'foo', 'bar' => 'bar', 'baz' => 'baz']; - $class = __NAMESPACE__.'\Dummy'; + $class = Dummy::class; $context = []; $normalizer = new AbstractObjectNormalizerDummy(); - $this->assertInstanceOf(__NAMESPACE__.'\Dummy', $normalizer->instantiateObject($data, $class, $context, new \ReflectionClass($class), [])); + $this->assertInstanceOf(Dummy::class, $normalizer->instantiateObject($data, $class, $context, new \ReflectionClass($class), [])); } public function testDenormalizeWithExtraAttributes() @@ -66,7 +66,7 @@ public function testDenormalizeWithExtraAttributes() $normalizer = new AbstractObjectNormalizerDummy($factory); $normalizer->denormalize( ['fooFoo' => 'foo', 'fooBar' => 'bar'], - __NAMESPACE__.'\Dummy', + Dummy::class, 'any', ['allow_extra_attributes' => false] ); diff --git a/Tests/Normalizer/ArrayDenormalizerTest.php b/Tests/Normalizer/ArrayDenormalizerTest.php index a8302be91..fbceb90cf 100644 --- a/Tests/Normalizer/ArrayDenormalizerTest.php +++ b/Tests/Normalizer/ArrayDenormalizerTest.php @@ -68,7 +68,7 @@ public function testSupportsValidArray() { $this->serializer->expects($this->once()) ->method('supportsDenormalization') - ->with($this->anything(), __NAMESPACE__.'\ArrayDummy', $this->anything()) + ->with($this->anything(), ArrayDummy::class, $this->anything()) ->willReturn(true); $this->assertTrue( @@ -104,7 +104,7 @@ public function testSupportsNoArray() $this->assertFalse( $this->denormalizer->supportsDenormalization( ['foo' => 'one', 'bar' => 'two'], - __NAMESPACE__.'\ArrayDummy' + ArrayDummy::class ) ); } diff --git a/Tests/Normalizer/GetSetMethodNormalizerTest.php b/Tests/Normalizer/GetSetMethodNormalizerTest.php index f58d43ce1..c5c47185e 100644 --- a/Tests/Normalizer/GetSetMethodNormalizerTest.php +++ b/Tests/Normalizer/GetSetMethodNormalizerTest.php @@ -68,7 +68,7 @@ protected function setUp(): void private function createNormalizer(array $defaultContext = []) { - $this->serializer = $this->getMockBuilder(__NAMESPACE__.'\SerializerNormalizer')->getMock(); + $this->serializer = $this->getMockBuilder(SerializerNormalizer::class)->getMock(); $this->normalizer = new GetSetMethodNormalizer(null, null, null, null, null, $defaultContext); $this->normalizer->setSerializer($this->serializer); } @@ -157,7 +157,7 @@ public function testConstructorDenormalize() { $obj = $this->normalizer->denormalize( ['foo' => 'foo', 'bar' => 'bar', 'baz' => true, 'fooBar' => 'foobar'], - __NAMESPACE__.'\GetConstructorDummy', 'any'); + GetConstructorDummy::class, 'any'); $this->assertEquals('foo', $obj->getFoo()); $this->assertEquals('bar', $obj->getBar()); $this->assertTrue($obj->isBaz()); @@ -167,7 +167,7 @@ public function testConstructorDenormalizeWithNullArgument() { $obj = $this->normalizer->denormalize( ['foo' => 'foo', 'bar' => null, 'baz' => true], - __NAMESPACE__.'\GetConstructorDummy', 'any'); + GetConstructorDummy::class, 'any'); $this->assertEquals('foo', $obj->getFoo()); $this->assertNull($obj->getBar()); $this->assertTrue($obj->isBaz()); @@ -177,7 +177,7 @@ public function testConstructorDenormalizeWithMissingOptionalArgument() { $obj = $this->normalizer->denormalize( ['foo' => 'test', 'baz' => [1, 2, 3]], - __NAMESPACE__.'\GetConstructorOptionalArgsDummy', 'any'); + GetConstructorOptionalArgsDummy::class, 'any'); $this->assertEquals('test', $obj->getFoo()); $this->assertEquals([], $obj->getBar()); $this->assertEquals([1, 2, 3], $obj->getBaz()); @@ -187,7 +187,7 @@ public function testConstructorDenormalizeWithOptionalDefaultArgument() { $obj = $this->normalizer->denormalize( ['bar' => 'test'], - __NAMESPACE__.'\GetConstructorArgsWithDefaultValueDummy', 'any'); + GetConstructorArgsWithDefaultValueDummy::class, 'any'); $this->assertEquals([], $obj->getFoo()); $this->assertEquals('test', $obj->getBar()); } @@ -215,14 +215,14 @@ public function testConstructorWithObjectDenormalize() $data->bar = 'bar'; $data->baz = true; $data->fooBar = 'foobar'; - $obj = $this->normalizer->denormalize($data, __NAMESPACE__.'\GetConstructorDummy', 'any'); + $obj = $this->normalizer->denormalize($data, GetConstructorDummy::class, 'any'); $this->assertEquals('foo', $obj->getFoo()); $this->assertEquals('bar', $obj->getBar()); } public function testConstructorWArgWithPrivateMutator() { - $obj = $this->normalizer->denormalize(['foo' => 'bar'], __NAMESPACE__.'\ObjectConstructorArgsWithPrivateMutatorDummy', 'any'); + $obj = $this->normalizer->denormalize(['foo' => 'bar'], ObjectConstructorArgsWithPrivateMutatorDummy::class, 'any'); $this->assertEquals('bar', $obj->getFoo()); } @@ -479,7 +479,7 @@ public function testNoStaticGetSetSupport() public function testPrivateSetter() { - $obj = $this->normalizer->denormalize(['foo' => 'foobar'], __NAMESPACE__.'\ObjectWithPrivateSetterDummy'); + $obj = $this->normalizer->denormalize(['foo' => 'foobar'], ObjectWithPrivateSetterDummy::class); $this->assertEquals('bar', $obj->getFoo()); } diff --git a/Tests/Normalizer/ObjectNormalizerTest.php b/Tests/Normalizer/ObjectNormalizerTest.php index 860294b9c..b1ea04a1d 100644 --- a/Tests/Normalizer/ObjectNormalizerTest.php +++ b/Tests/Normalizer/ObjectNormalizerTest.php @@ -80,7 +80,7 @@ protected function setUp(): void private function createNormalizer(array $defaultContext = [], ClassMetadataFactoryInterface $classMetadataFactory = null) { - $this->serializer = $this->getMockBuilder(__NAMESPACE__.'\ObjectSerializerNormalizer')->getMock(); + $this->serializer = $this->getMockBuilder(ObjectSerializerNormalizer::class)->getMock(); $this->normalizer = new ObjectNormalizer($classMetadataFactory, null, null, null, null, null, $defaultContext); $this->normalizer->setSerializer($this->serializer); } @@ -159,7 +159,7 @@ public function testConstructorDenormalize() { $obj = $this->normalizer->denormalize( ['foo' => 'foo', 'bar' => 'bar', 'baz' => true, 'fooBar' => 'foobar'], - __NAMESPACE__.'\ObjectConstructorDummy', 'any'); + ObjectConstructorDummy::class, 'any'); $this->assertEquals('foo', $obj->getFoo()); $this->assertEquals('bar', $obj->bar); $this->assertTrue($obj->isBaz()); @@ -169,7 +169,7 @@ public function testConstructorDenormalizeWithNullArgument() { $obj = $this->normalizer->denormalize( ['foo' => 'foo', 'bar' => null, 'baz' => true], - __NAMESPACE__.'\ObjectConstructorDummy', 'any'); + ObjectConstructorDummy::class, 'any'); $this->assertEquals('foo', $obj->getFoo()); $this->assertNull($obj->bar); $this->assertTrue($obj->isBaz()); @@ -179,7 +179,7 @@ public function testConstructorDenormalizeWithMissingOptionalArgument() { $obj = $this->normalizer->denormalize( ['foo' => 'test', 'baz' => [1, 2, 3]], - __NAMESPACE__.'\ObjectConstructorOptionalArgsDummy', 'any'); + ObjectConstructorOptionalArgsDummy::class, 'any'); $this->assertEquals('test', $obj->getFoo()); $this->assertEquals([], $obj->bar); $this->assertEquals([1, 2, 3], $obj->getBaz()); @@ -189,7 +189,7 @@ public function testConstructorDenormalizeWithOptionalDefaultArgument() { $obj = $this->normalizer->denormalize( ['bar' => 'test'], - __NAMESPACE__.'\ObjectConstructorArgsWithDefaultValueDummy', 'any'); + ObjectConstructorArgsWithDefaultValueDummy::class, 'any'); $this->assertEquals([], $obj->getFoo()); $this->assertEquals('test', $obj->getBar()); } @@ -201,7 +201,7 @@ public function testConstructorWithObjectDenormalize() $data->bar = 'bar'; $data->baz = true; $data->fooBar = 'foobar'; - $obj = $this->normalizer->denormalize($data, __NAMESPACE__.'\ObjectConstructorDummy', 'any'); + $obj = $this->normalizer->denormalize($data, ObjectConstructorDummy::class, 'any'); $this->assertEquals('foo', $obj->getFoo()); $this->assertEquals('bar', $obj->bar); } diff --git a/Tests/Normalizer/PropertyNormalizerTest.php b/Tests/Normalizer/PropertyNormalizerTest.php index b4238e041..a111ec620 100644 --- a/Tests/Normalizer/PropertyNormalizerTest.php +++ b/Tests/Normalizer/PropertyNormalizerTest.php @@ -104,7 +104,7 @@ public function testDenormalize() { $obj = $this->normalizer->denormalize( ['foo' => 'foo', 'bar' => 'bar'], - __NAMESPACE__.'\PropertyDummy', + PropertyDummy::class, 'any' ); $this->assertEquals('foo', $obj->foo); @@ -143,7 +143,7 @@ public function testConstructorDenormalize() { $obj = $this->normalizer->denormalize( ['foo' => 'foo', 'bar' => 'bar'], - __NAMESPACE__.'\PropertyConstructorDummy', + PropertyConstructorDummy::class, 'any' ); $this->assertEquals('foo', $obj->getFoo()); @@ -154,7 +154,7 @@ public function testConstructorDenormalizeWithNullArgument() { $obj = $this->normalizer->denormalize( ['foo' => null, 'bar' => 'bar'], - __NAMESPACE__.'\PropertyConstructorDummy', ' + PropertyConstructorDummy::class, ' any' ); $this->assertNull($obj->getFoo()); @@ -381,13 +381,13 @@ public function testDenormalizeNonExistingAttribute() { $this->assertEquals( new PropertyDummy(), - $this->normalizer->denormalize(['non_existing' => true], __NAMESPACE__.'\PropertyDummy') + $this->normalizer->denormalize(['non_existing' => true], PropertyDummy::class) ); } public function testDenormalizeShouldIgnoreStaticProperty() { - $obj = $this->normalizer->denormalize(['outOfScope' => true], __NAMESPACE__.'\PropertyDummy'); + $obj = $this->normalizer->denormalize(['outOfScope' => true], PropertyDummy::class); $this->assertEquals(new PropertyDummy(), $obj); $this->assertEquals('out_of_scope', PropertyDummy::$outOfScope);