diff --git a/core/modules/serialization/tests/src/Unit/Normalizer/EntityNormalizerTest.php b/core/modules/serialization/tests/src/Unit/Normalizer/EntityNormalizerTest.php index 759f98c4f7e3a973390fbedbf7687f718efdef3a..648c2f92e645ca21c206ece5ffc09fc80f058469 100644 --- a/core/modules/serialization/tests/src/Unit/Normalizer/EntityNormalizerTest.php +++ b/core/modules/serialization/tests/src/Unit/Normalizer/EntityNormalizerTest.php @@ -94,18 +94,11 @@ public function testNormalize() { ->method('getFields') ->willReturn($definitions); - $serializer = $this->getMockBuilder('Symfony\Component\Serializer\Serializer') - ->disableOriginalConstructor() - ->onlyMethods(['normalize']) - ->getMock(); - $serializer->expects($this->exactly(2)) - ->method('normalize') - ->withConsecutive( - [$list_item_1, 'test_format'], - [$list_item_2, 'test_format'], - ); + $serializer = $this->prophesize('Symfony\Component\Serializer\Serializer'); + $serializer->normalize($list_item_1, 'test_format', [])->shouldBeCalled(); + $serializer->normalize($list_item_2, 'test_format', [])->shouldBeCalled(); - $this->entityNormalizer->setSerializer($serializer); + $this->entityNormalizer->setSerializer($serializer->reveal()); $this->entityNormalizer->normalize($content_entity, 'test_format'); } @@ -224,18 +217,15 @@ public function testDenormalizeWithValidBundle() { // Setup expectations for the serializer. This will be called for each field // item. - $serializer = $this->getMockBuilder('Symfony\Component\Serializer\Serializer') - ->disableOriginalConstructor() - ->onlyMethods(['denormalize']) - ->getMock(); - $serializer->expects($this->exactly(2)) - ->method('denormalize') - ->withConsecutive( - ['value_1', get_class($key_1), NULL, ['target_instance' => $key_1, 'entity_type' => 'test']], - ['value_2', get_class($key_2), NULL, ['target_instance' => $key_2, 'entity_type' => 'test']], - ); + $serializer = $this->prophesize('Symfony\Component\Serializer\Serializer'); + $serializer->denormalize('value_1', get_class($key_1), NULL, ['target_instance' => $key_1, 'entity_type' => 'test']) + ->willReturn(NULL) + ->shouldBeCalled(); + $serializer->denormalize('value_2', get_class($key_2), NULL, ['target_instance' => $key_2, 'entity_type' => 'test']) + ->willReturn(NULL) + ->shouldBeCalled(); - $this->entityNormalizer->setSerializer($serializer); + $this->entityNormalizer->setSerializer($serializer->reveal()); $this->assertNotNull($this->entityNormalizer->denormalize($test_data, 'Drupal\Core\Entity\ContentEntityBase', NULL, ['entity_type' => 'test'])); } @@ -377,18 +367,15 @@ public function testDenormalizeWithNoBundle() { // Setup expectations for the serializer. This will be called for each field // item. - $serializer = $this->getMockBuilder('Symfony\Component\Serializer\Serializer') - ->disableOriginalConstructor() - ->onlyMethods(['denormalize']) - ->getMock(); - $serializer->expects($this->exactly(2)) - ->method('denormalize') - ->withConsecutive( - ['value_1', get_class($key_1), NULL, ['target_instance' => $key_1, 'entity_type' => 'test']], - ['value_2', get_class($key_2), NULL, ['target_instance' => $key_2, 'entity_type' => 'test']], - ); - - $this->entityNormalizer->setSerializer($serializer); + $serializer = $this->prophesize('Symfony\Component\Serializer\Serializer'); + $serializer->denormalize('value_1', get_class($key_1), NULL, ['target_instance' => $key_1, 'entity_type' => 'test']) + ->willReturn(NULL) + ->shouldBeCalled(); + $serializer->denormalize('value_2', get_class($key_2), NULL, ['target_instance' => $key_2, 'entity_type' => 'test']) + ->willReturn(NULL) + ->shouldBeCalled(); + + $this->entityNormalizer->setSerializer($serializer->reveal()); $this->assertNotNull($this->entityNormalizer->denormalize($test_data, 'Drupal\Core\Entity\ContentEntityBase', NULL, ['entity_type' => 'test'])); } diff --git a/core/phpstan-baseline.neon b/core/phpstan-baseline.neon index 04e8de9b634b7ce58d9b26cfb04cedc7718d7869..c30a4a8f631da80152dbcb0aa2301ed5442032b0 100644 --- a/core/phpstan-baseline.neon +++ b/core/phpstan-baseline.neon @@ -2159,11 +2159,6 @@ parameters: count: 1 path: modules/serialization/src/Normalizer/EntityNormalizer.php - - - message: "#^Call to deprecated method withConsecutive\\(\\) of class PHPUnit\\\\Framework\\\\MockObject\\\\Builder\\\\InvocationMocker\\.$#" - count: 3 - path: modules/serialization/tests/src/Unit/Normalizer/EntityNormalizerTest.php - - message: "#^Method Drupal\\\\shortcut\\\\Form\\\\SetCustomize\\:\\:save\\(\\) should return int but return statement is missing\\.$#" count: 1