public function ContentEntityNormalizerTest::createMockForContentEntity in Drupal 8
Same name and namespace in other branches
- 9 core/modules/serialization/tests/src/Unit/Normalizer/ContentEntityNormalizerTest.php \Drupal\Tests\serialization\Unit\Normalizer\ContentEntityNormalizerTest::createMockForContentEntity()
Creates a mock content entity.
Parameters
$definitions:
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 128
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()
->setMethods([
'getTypedData',
])
->getMockForAbstractClass();
$typed_data = $this
->prophesize(ComplexDataInterface::class);
$typed_data
->getProperties(TRUE)
->willReturn($definitions)
->shouldBeCalled();
$content_entity_mock
->expects($this
->any())
->method('getTypedData')
->will($this
->returnValue($typed_data
->reveal()));
return $content_entity_mock;
}