public function SqlContentEntityStorageSchemaTest::setUpStorageDefinition in Drupal 8
Sets up a field definition.
Parameters
string $field_name: The field name.
array $schema: The schema array of the field definition, as returned from FieldStorageDefinitionInterface::getSchema().
8 calls to SqlContentEntityStorageSchemaTest::setUpStorageDefinition()
- SqlContentEntityStorageSchemaTest::setUp in core/
tests/ Drupal/ Tests/ Core/ Entity/ Sql/ SqlContentEntityStorageSchemaTest.php - SqlContentEntityStorageSchemaTest::testDedicatedTableSchema in core/
tests/ Drupal/ Tests/ Core/ Entity/ Sql/ SqlContentEntityStorageSchemaTest.php - Tests the schema for a field dedicated table.
- SqlContentEntityStorageSchemaTest::testDedicatedTableSchemaForEntityWithStringIdentifier in core/
tests/ Drupal/ Tests/ Core/ Entity/ Sql/ SqlContentEntityStorageSchemaTest.php - Tests the schema for a field dedicated table for an entity with a string identifier.
- SqlContentEntityStorageSchemaTest::testGetSchemaBase in core/
tests/ Drupal/ Tests/ Core/ Entity/ Sql/ SqlContentEntityStorageSchemaTest.php - Tests the schema for non-revisionable, non-translatable entities.
- SqlContentEntityStorageSchemaTest::testGetSchemaRevisionable in core/
tests/ Drupal/ Tests/ Core/ Entity/ Sql/ SqlContentEntityStorageSchemaTest.php - Tests the schema for revisionable, non-translatable entities.
File
- core/
tests/ Drupal/ Tests/ Core/ Entity/ Sql/ SqlContentEntityStorageSchemaTest.php, line 1444
Class
- SqlContentEntityStorageSchemaTest
- @coversDefaultClass \Drupal\Core\Entity\Sql\SqlContentEntityStorageSchema @group Entity
Namespace
Drupal\Tests\Core\Entity\SqlCode
public function setUpStorageDefinition($field_name, array $schema) {
$this->storageDefinitions[$field_name] = $this
->createMock('Drupal\\Tests\\Core\\Field\\TestBaseFieldDefinitionInterface');
$this->storageDefinitions[$field_name]
->expects($this
->any())
->method('isBaseField')
->will($this
->returnValue(TRUE));
// getName() is called once for each table.
$this->storageDefinitions[$field_name]
->expects($this
->any())
->method('getName')
->will($this
->returnValue($field_name));
// getSchema() is called once for each table.
$this->storageDefinitions[$field_name]
->expects($this
->any())
->method('getSchema')
->will($this
->returnValue($schema));
$this->storageDefinitions[$field_name]
->expects($this
->any())
->method('getColumns')
->will($this
->returnValue($schema['columns']));
// Add property definitions.
if (!empty($schema['columns'])) {
$property_definitions = [];
foreach ($schema['columns'] as $column => $info) {
$property_definitions[$column] = $this
->createMock('Drupal\\Core\\TypedData\\DataDefinitionInterface');
$property_definitions[$column]
->expects($this
->any())
->method('isRequired')
->will($this
->returnValue(!empty($info['not null'])));
}
$this->storageDefinitions[$field_name]
->expects($this
->any())
->method('getPropertyDefinitions')
->will($this
->returnValue($property_definitions));
}
}