function ContentEntityNormalizerTest::createMockFieldListItem
Same name in other branches
- 9 core/modules/serialization/tests/src/Unit/Normalizer/ContentEntityNormalizerTest.php \Drupal\Tests\serialization\Unit\Normalizer\ContentEntityNormalizerTest::createMockFieldListItem()
- 10 core/modules/serialization/tests/src/Unit/Normalizer/ContentEntityNormalizerTest.php \Drupal\Tests\serialization\Unit\Normalizer\ContentEntityNormalizerTest::createMockFieldListItem()
- 11.x core/modules/serialization/tests/src/Unit/Normalizer/ContentEntityNormalizerTest.php \Drupal\Tests\serialization\Unit\Normalizer\ContentEntityNormalizerTest::createMockFieldListItem()
Creates a mock field list item.
Parameters
bool $access:
bool $internal:
\Drupal\Core\Session\AccountInterface $user_context:
Return value
\Drupal\Core\Field\FieldItemListInterface|\PHPUnit\Framework\MockObject\MockObject
2 calls to ContentEntityNormalizerTest::createMockFieldListItem()
- 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 153
Class
- ContentEntityNormalizerTest
- @coversDefaultClass \Drupal\serialization\Normalizer\ContentEntityNormalizer @group serialization
Namespace
Drupal\Tests\serialization\Unit\NormalizerCode
protected function createMockFieldListItem($access, $internal, AccountInterface $user_context = NULL) {
$data_definition = $this->prophesize(DataDefinitionInterface::class);
$mock = $this->createMock('Drupal\\Core\\Field\\FieldItemListInterface');
$mock->expects($this->once())
->method('getDataDefinition')
->will($this->returnValue($data_definition->reveal()));
$data_definition->isInternal()
->willReturn($internal)
->shouldBeCalled();
if (!$internal) {
$mock->expects($this->once())
->method('access')
->with('view', $user_context)
->will($this->returnValue($access));
}
return $mock;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.