protected function ContentEntityNormalizerTest::createMockFieldListItem in Acquia Content Hub 8
Creates a mock field list item.
Parameters
string $name: Name of the mock field.
string $type: Type of the mock field.
bool $access: Defines whether anyone has access to this field or not.
bool $user_context: The user context used to view the field.
array $return_value: Expected return value.
Return value
\Drupal\Core\Field\FieldItemListInterface|\PHPUnit_Framework_MockObject_MockObject The mocked field items.
11 calls to ContentEntityNormalizerTest::createMockFieldListItem()
- ContentEntityNormalizerTest::testGetFieldTypeMapping in tests/
src/ Unit/ Normalizer/ ContentEntityNormalizerTest.php - Test the getFieldTypeMapping method.
- ContentEntityNormalizerTest::testNormalizeOneField in tests/
src/ Unit/ Normalizer/ ContentEntityNormalizerTest.php - Tests the normalize() method.
- ContentEntityNormalizerTest::testNormalizeOneFieldMultiValued in tests/
src/ Unit/ Normalizer/ ContentEntityNormalizerTest.php - Tests the normalize() method.
- ContentEntityNormalizerTest::testNormalizeWithAccountContext in tests/
src/ Unit/ Normalizer/ ContentEntityNormalizerTest.php - Tests the normalize() method.
- ContentEntityNormalizerTest::testNormalizeWithComplexFieldValues in tests/
src/ Unit/ Normalizer/ ContentEntityNormalizerTest.php - Tests the normalize() method.
File
- tests/
src/ Unit/ Normalizer/ ContentEntityNormalizerTest.php, line 981
Class
- ContentEntityNormalizerTest
- PHPUnit test for the ContentEntityNormalizer class.
Namespace
Drupal\Tests\acquia_contenthub\Unit\NormalizerCode
protected function createMockFieldListItem($name, $type = 'string', $access = TRUE, $user_context = NULL, array $return_value = []) {
$mock = $this
->createMock('Drupal\\Core\\Field\\FieldItemListInterface');
$mock
->method('access')
->with('view', $user_context)
->will($this
->returnValue($access));
$field_def = $this
->createMock('\\Drupal\\Core\\Field\\FieldDefinitionInterface');
$field_def
->method('getName')
->willReturn($name);
$field_def
->method('getType')
->willReturn($type);
$mock
->method('getValue')
->willReturn($return_value);
$mock
->method('getFieldDefinition')
->willReturn($field_def);
return $mock;
}