protected function SqlContentEntityStorageTest::mockFieldDefinitions in Drupal 9
Same name and namespace in other branches
- 8 core/tests/Drupal/Tests/Core/Entity/Sql/SqlContentEntityStorageTest.php \Drupal\Tests\Core\Entity\Sql\SqlContentEntityStorageTest::mockFieldDefinitions()
Returns a set of mock field definitions for the given names.
Parameters
array $field_names: An array of field names.
array $methods: (optional) An associative array of mock method return values keyed by method name.
Return value
\Drupal\Tests\Core\Field\TestBaseFieldDefinitionInterface[]|\PHPUnit\Framework\MockObject\MockObject[] An array of mock base field definitions.
8 calls to SqlContentEntityStorageTest::mockFieldDefinitions()
- SqlContentEntityStorageTest::testCleanIds in core/
tests/ Drupal/ Tests/ Core/ Entity/ Sql/ SqlContentEntityStorageTest.php - Tests entity ID sanitization.
- SqlContentEntityStorageTest::testGetTableMappingRevisionableTranslatable in core/
tests/ Drupal/ Tests/ Core/ Entity/ Sql/ SqlContentEntityStorageTest.php - Tests getTableMapping() with a revisionable, translatable entity type.
- SqlContentEntityStorageTest::testGetTableMappingRevisionableTranslatableWithFields in core/
tests/ Drupal/ Tests/ Core/ Entity/ Sql/ SqlContentEntityStorageTest.php - Tests getTableMapping() with a complex entity type with fields.
- SqlContentEntityStorageTest::testGetTableMappingRevisionableWithFields in core/
tests/ Drupal/ Tests/ Core/ Entity/ Sql/ SqlContentEntityStorageTest.php - Tests getTableMapping() with a revisionable entity type with fields.
- SqlContentEntityStorageTest::testGetTableMappingSimpleWithDedicatedStorageFields in core/
tests/ Drupal/ Tests/ Core/ Entity/ Sql/ SqlContentEntityStorageTest.php - Tests getTableMapping() with a base field that requires a dedicated table.
File
- core/
tests/ Drupal/ Tests/ Core/ Entity/ Sql/ SqlContentEntityStorageTest.php, line 1127 - Contains \Drupal\Tests\Core\Entity\Sql\SqlContentEntityStorageTest.
Class
- SqlContentEntityStorageTest
- @coversDefaultClass \Drupal\Core\Entity\Sql\SqlContentEntityStorage @group Entity
Namespace
Drupal\Tests\Core\Entity\SqlCode
protected function mockFieldDefinitions(array $field_names, $methods = []) {
$field_definitions = [];
$definition = $this
->createMock('Drupal\\Tests\\Core\\Field\\TestBaseFieldDefinitionInterface');
// Assign common method return values.
$methods += [
'isBaseField' => TRUE,
];
foreach ($methods as $method => $result) {
$definition
->expects($this
->any())
->method($method)
->will($this
->returnValue($result));
}
// Assign field names to mock definitions.
foreach ($field_names as $field_name) {
$field_definitions[$field_name] = clone $definition;
$field_definitions[$field_name]
->expects($this
->any())
->method('getName')
->will($this
->returnValue($field_name));
}
return $field_definitions;
}