public function EntityNormalizerTest::testNormalize in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/serialization/tests/src/Unit/Normalizer/EntityNormalizerTest.php \Drupal\Tests\serialization\Unit\Normalizer\EntityNormalizerTest::testNormalize()
Tests the normalize() method.
@covers ::normalize
File
- core/
modules/ serialization/ tests/ src/ Unit/ Normalizer/ EntityNormalizerTest.php, line 53 - Contains \Drupal\Tests\serialization\Unit\Normalizer\EntityNormalizerTest.
Class
- EntityNormalizerTest
- @coversDefaultClass \Drupal\serialization\Normalizer\EntityNormalizer @group serialization
Namespace
Drupal\Tests\serialization\Unit\NormalizerCode
public function testNormalize() {
$list_item_1 = $this
->getMock('Drupal\\Core\\TypedData\\TypedDataInterface');
$list_item_2 = $this
->getMock('Drupal\\Core\\TypedData\\TypedDataInterface');
$definitions = array(
'field_1' => $list_item_1,
'field_2' => $list_item_2,
);
$content_entity = $this
->getMockBuilder('Drupal\\Core\\Entity\\ContentEntityBase')
->disableOriginalConstructor()
->setMethods(array(
'getFields',
))
->getMockForAbstractClass();
$content_entity
->expects($this
->once())
->method('getFields')
->will($this
->returnValue($definitions));
$serializer = $this
->getMockBuilder('Symfony\\Component\\Serializer\\Serializer')
->disableOriginalConstructor()
->setMethods(array(
'normalize',
))
->getMock();
$serializer
->expects($this
->at(0))
->method('normalize')
->with($list_item_1, 'test_format');
$serializer
->expects($this
->at(1))
->method('normalize')
->with($list_item_2, 'test_format');
$this->entityNormalizer
->setSerializer($serializer);
$this->entityNormalizer
->normalize($content_entity, 'test_format');
}