protected function EntityReferenceFieldItemNormalizerTest::assertDenormalize in Drupal 9
Same name and namespace in other branches
- 8 core/modules/serialization/tests/src/Unit/Normalizer/EntityReferenceFieldItemNormalizerTest.php \Drupal\Tests\serialization\Unit\Normalizer\EntityReferenceFieldItemNormalizerTest::assertDenormalize()
- 10 core/modules/serialization/tests/src/Unit/Normalizer/EntityReferenceFieldItemNormalizerTest.php \Drupal\Tests\serialization\Unit\Normalizer\EntityReferenceFieldItemNormalizerTest::assertDenormalize()
Asserts denormalization process is correct for give data.
Parameters
array $data: The data to denormalize.
7 calls to EntityReferenceFieldItemNormalizerTest::assertDenormalize()
- EntityReferenceFieldItemNormalizerTest::testConstructValueProperties in core/
modules/ serialization/ tests/ src/ Unit/ Normalizer/ EntityReferenceFieldItemNormalizerTest.php - @covers ::constructValue
- EntityReferenceFieldItemNormalizerTest::testDenormalizeWithEmptyUuid in core/
modules/ serialization/ tests/ src/ Unit/ Normalizer/ EntityReferenceFieldItemNormalizerTest.php - @covers ::denormalize
- EntityReferenceFieldItemNormalizerTest::testDenormalizeWithId in core/
modules/ serialization/ tests/ src/ Unit/ Normalizer/ EntityReferenceFieldItemNormalizerTest.php - @covers ::denormalize
- EntityReferenceFieldItemNormalizerTest::testDenormalizeWithTypeAndUuid in core/
modules/ serialization/ tests/ src/ Unit/ Normalizer/ EntityReferenceFieldItemNormalizerTest.php - @covers ::denormalize
- EntityReferenceFieldItemNormalizerTest::testDenormalizeWithTypeWithIncorrectUuid in core/
modules/ serialization/ tests/ src/ Unit/ Normalizer/ EntityReferenceFieldItemNormalizerTest.php - @covers ::denormalize
File
- core/
modules/ serialization/ tests/ src/ Unit/ Normalizer/ EntityReferenceFieldItemNormalizerTest.php, line 431
Class
- EntityReferenceFieldItemNormalizerTest
- @coversDefaultClass \Drupal\serialization\Normalizer\EntityReferenceFieldItemNormalizer @group serialization
Namespace
Drupal\Tests\serialization\Unit\NormalizerCode
protected function assertDenormalize(array $data) {
$this->fieldItem
->getParent()
->willReturn($this
->prophesize(FieldItemListInterface::class)
->reveal());
$this->fieldItem
->getFieldDefinition()
->willReturn($this->fieldDefinition
->reveal());
if (!empty($data['target_uuid'])) {
$this->fieldDefinition
->getSetting('target_type')
->willReturn('test_type')
->shouldBeCalled();
}
// Avoid a static method call by returning dummy serialized property data.
$this->fieldDefinition
->getFieldStorageDefinition()
->willReturn()
->shouldBeCalled();
$this->fieldDefinition
->getName()
->willReturn('field_reference')
->shouldBeCalled();
$entity = $this
->prophesize(EntityInterface::class);
$entity_type = $this
->prophesize(EntityTypeInterface::class);
$entity
->getEntityType()
->willReturn($entity_type
->reveal())
->shouldBeCalled();
$this->fieldItem
->getPluginDefinition()
->willReturn([
'serialized_property_names' => [
'foo' => 'bar',
],
])
->shouldBeCalled();
$this->fieldItem
->getEntity()
->willReturn($entity
->reveal())
->shouldBeCalled();
$context = [
'target_instance' => $this->fieldItem
->reveal(),
];
$denormalized = $this->normalizer
->denormalize($data, EntityReferenceItem::class, 'json', $context);
$this
->assertSame($context['target_instance'], $denormalized);
}