function EntityNormalizerTest::testDenormalizeWithNoFieldableEntityType
Same name in other branches
- 8.9.x core/modules/serialization/tests/src/Unit/Normalizer/EntityNormalizerTest.php \Drupal\Tests\serialization\Unit\Normalizer\EntityNormalizerTest::testDenormalizeWithNoFieldableEntityType()
- 10 core/modules/serialization/tests/src/Unit/Normalizer/EntityNormalizerTest.php \Drupal\Tests\serialization\Unit\Normalizer\EntityNormalizerTest::testDenormalizeWithNoFieldableEntityType()
- 11.x core/modules/serialization/tests/src/Unit/Normalizer/EntityNormalizerTest.php \Drupal\Tests\serialization\Unit\Normalizer\EntityNormalizerTest::testDenormalizeWithNoFieldableEntityType()
Tests the denormalize method with no bundle defined.
@covers ::denormalize
File
-
core/
modules/ serialization/ tests/ src/ Unit/ Normalizer/ EntityNormalizerTest.php, line 388
Class
- EntityNormalizerTest
- @coversDefaultClass \Drupal\serialization\Normalizer\EntityNormalizer @group serialization
Namespace
Drupal\Tests\serialization\Unit\NormalizerCode
public function testDenormalizeWithNoFieldableEntityType() {
$test_data = [
'key_1' => 'value_1',
'key_2' => 'value_2',
];
$entity_type = $this->createMock('Drupal\\Core\\Entity\\EntityTypeInterface');
$entity_type->expects($this->once())
->method('entityClassImplements')
->with(FieldableEntityInterface::class)
->willReturn(FALSE);
$entity_type->expects($this->never())
->method('getKey');
$this->entityTypeManager
->expects($this->once())
->method('getDefinition')
->with('test')
->willReturn($entity_type);
$storage = $this->createMock('Drupal\\Core\\Entity\\EntityStorageInterface');
$storage->expects($this->once())
->method('create')
->with($test_data)
->willReturn($this->createMock('Drupal\\Core\\Entity\\EntityInterface'));
$this->entityTypeManager
->expects($this->once())
->method('getStorage')
->with('test')
->willReturn($storage);
$this->entityFieldManager
->expects($this->never())
->method('getBaseFieldDefinitions');
$this->assertNotNull($this->entityNormalizer
->denormalize($test_data, 'Drupal\\Core\\Entity\\ContentEntityBase', NULL, [
'entity_type' => 'test',
]));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.