Commit 5ee806ab authored by catch's avatar catch
Browse files

Issue #3417551 by longwave, Spokje: Remove withConsecutive() in EntityNormalizerTest

(cherry picked from commit 8474508c)
parent a3cc5307
Loading
Loading
Loading
Loading
Loading
+21 −34
Original line number Diff line number Diff line
@@ -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']));
  }
+0 −5
Original line number Diff line number Diff line
@@ -2210,11 +2210,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