You are here

public function SqlContentEntityStorageSchemaTest::setUpStorageDefinition in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 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 1363
Contains \Drupal\Tests\Core\Entity\Sql\SqlContentEntityStorageSchemaTest.

Class

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

Namespace

Drupal\Tests\Core\Entity\Sql

Code

public function setUpStorageDefinition($field_name, array $schema) {
  $this->storageDefinitions[$field_name] = $this
    ->getMock('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 = array();
    foreach ($schema['columns'] as $column => $info) {
      $property_definitions[$column] = $this
        ->getMock('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));
  }
}