function ContentEntityNormalizerTest::createMockForContentEntity
Same name in other branches
- 8.9.x core/modules/serialization/tests/src/Unit/Normalizer/ContentEntityNormalizerTest.php \Drupal\Tests\serialization\Unit\Normalizer\ContentEntityNormalizerTest::createMockForContentEntity()
- 10 core/modules/serialization/tests/src/Unit/Normalizer/ContentEntityNormalizerTest.php \Drupal\Tests\serialization\Unit\Normalizer\ContentEntityNormalizerTest::createMockForContentEntity()
- 11.x core/modules/serialization/tests/src/Unit/Normalizer/ContentEntityNormalizerTest.php \Drupal\Tests\serialization\Unit\Normalizer\ContentEntityNormalizerTest::createMockForContentEntity()
Creates a mock content entity.
Parameters
$definitions: The properties the will be returned.
Return value
\PHPUnit\Framework\MockObject\MockObject
2 calls to ContentEntityNormalizerTest::createMockForContentEntity()
- ContentEntityNormalizerTest::testNormalize in core/
modules/ serialization/ tests/ src/ Unit/ Normalizer/ ContentEntityNormalizerTest.php - Tests the normalize() method.
- ContentEntityNormalizerTest::testNormalizeWithAccountContext in core/
modules/ serialization/ tests/ src/ Unit/ Normalizer/ ContentEntityNormalizerTest.php - Tests the normalize() method with account context passed.
File
-
core/
modules/ serialization/ tests/ src/ Unit/ Normalizer/ ContentEntityNormalizerTest.php, line 129
Class
- ContentEntityNormalizerTest
- @coversDefaultClass \Drupal\serialization\Normalizer\ContentEntityNormalizer @group serialization
Namespace
Drupal\Tests\serialization\Unit\NormalizerCode
public function createMockForContentEntity($definitions) {
$content_entity_mock = $this->getMockBuilder('Drupal\\Core\\Entity\\ContentEntityBase')
->disableOriginalConstructor()
->onlyMethods([
'getTypedData',
])
->getMockForAbstractClass();
$typed_data = $this->prophesize(ComplexDataInterface::class);
$typed_data->getProperties(TRUE)
->willReturn($definitions)
->shouldBeCalled();
$content_entity_mock->expects($this->any())
->method('getTypedData')
->willReturn($typed_data->reveal());
return $content_entity_mock;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.