function SqlContentEntityStorageSchemaTest::setUpStorageDefinition

Same name in other branches
  1. 9 core/tests/Drupal/Tests/Core/Entity/Sql/SqlContentEntityStorageSchemaTest.php \Drupal\Tests\Core\Entity\Sql\SqlContentEntityStorageSchemaTest::setUpStorageDefinition()
  2. 8.9.x core/tests/Drupal/Tests/Core/Entity/Sql/SqlContentEntityStorageSchemaTest.php \Drupal\Tests\Core\Entity\Sql\SqlContentEntityStorageSchemaTest::setUpStorageDefinition()
  3. 10 core/tests/Drupal/Tests/Core/Entity/Sql/SqlContentEntityStorageSchemaTest.php \Drupal\Tests\Core\Entity\Sql\SqlContentEntityStorageSchemaTest::setUpStorageDefinition()

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.

... See full list

File

core/tests/Drupal/Tests/Core/Entity/Sql/SqlContentEntityStorageSchemaTest.php, line 1422

Class

SqlContentEntityStorageSchemaTest
@coversDefaultClass \Drupal\Core\Entity\Sql\SqlContentEntityStorageSchema @group Entity

Namespace

Drupal\Tests\Core\Entity\Sql

Code

public function setUpStorageDefinition($field_name, array $schema) : void {
    $this->storageDefinitions[$field_name] = $this->createMock('Drupal\\Tests\\Core\\Field\\TestBaseFieldDefinitionInterface');
    $this->storageDefinitions[$field_name]
        ->expects($this->any())
        ->method('isBaseField')
        ->willReturn(TRUE);
    // getName() is called once for each table.
    $this->storageDefinitions[$field_name]
        ->expects($this->any())
        ->method('getName')
        ->willReturn($field_name);
    // getSchema() is called once for each table.
    $this->storageDefinitions[$field_name]
        ->expects($this->any())
        ->method('getSchema')
        ->willReturn($schema);
    $this->storageDefinitions[$field_name]
        ->expects($this->any())
        ->method('getColumns')
        ->willReturn($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')
                ->willReturn(!empty($info['not null']));
        }
        $this->storageDefinitions[$field_name]
            ->expects($this->any())
            ->method('getPropertyDefinitions')
            ->willReturn($property_definitions);
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.