function ComplexDataNormalizerTest::testNormalizeComplexData
Same name in other branches
- 8.9.x core/modules/serialization/tests/src/Unit/Normalizer/ComplexDataNormalizerTest.php \Drupal\Tests\serialization\Unit\Normalizer\ComplexDataNormalizerTest::testNormalizeComplexData()
- 10 core/modules/serialization/tests/src/Unit/Normalizer/ComplexDataNormalizerTest.php \Drupal\Tests\serialization\Unit\Normalizer\ComplexDataNormalizerTest::testNormalizeComplexData()
- 11.x core/modules/serialization/tests/src/Unit/Normalizer/ComplexDataNormalizerTest.php \Drupal\Tests\serialization\Unit\Normalizer\ComplexDataNormalizerTest::testNormalizeComplexData()
Tests normalizing complex data.
@covers ::normalize
File
-
core/
modules/ serialization/ tests/ src/ Unit/ Normalizer/ ComplexDataNormalizerTest.php, line 59
Class
- ComplexDataNormalizerTest
- @coversDefaultClass \Drupal\serialization\Normalizer\ComplexDataNormalizer @group serialization
Namespace
Drupal\Tests\serialization\Unit\NormalizerCode
public function testNormalizeComplexData() {
$serializer_prophecy = $this->prophesize(Serializer::class);
$non_internal_property = $this->getTypedDataProperty(FALSE);
$serializer_prophecy->normalize($non_internal_property, static::TEST_FORMAT, [])
->willReturn('A-normalized')
->shouldBeCalled();
$this->normalizer
->setSerializer($serializer_prophecy->reveal());
$complex_data = $this->prophesize(ComplexDataInterface::class);
$complex_data->getProperties(TRUE)
->willReturn([
'prop:a' => $non_internal_property,
'prop:internal' => $this->getTypedDataProperty(TRUE),
])
->shouldBeCalled();
$normalized = $this->normalizer
->normalize($complex_data->reveal(), static::TEST_FORMAT);
$this->assertEquals([
'prop:a' => 'A-normalized',
], $normalized);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.