You are here

protected function SqlContentEntityStorageSchemaTest::setUpStorageSchema 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::setUpStorageSchema()

Sets up the storage schema object to test.

This uses the field definitions set in $this->storageDefinitions.

Parameters

array $expected: (optional) An associative array describing the expected entity schema to be created. Defaults to expecting nothing.

8 calls to SqlContentEntityStorageSchemaTest::setUpStorageSchema()
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.
SqlContentEntityStorageSchemaTest::testGetSchemaRevisionableTranslatable in core/tests/Drupal/Tests/Core/Entity/Sql/SqlContentEntityStorageSchemaTest.php
Tests the schema for revisionable, translatable entities.

... See full list

File

core/tests/Drupal/Tests/Core/Entity/Sql/SqlContentEntityStorageSchemaTest.php, line 1297
Contains \Drupal\Tests\Core\Entity\Sql\SqlContentEntityStorageSchemaTest.

Class

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

Namespace

Drupal\Tests\Core\Entity\Sql

Code

protected function setUpStorageSchema(array $expected = array()) {
  $this->entityManager
    ->expects($this
    ->any())
    ->method('getDefinition')
    ->with($this->entityType
    ->id())
    ->will($this
    ->returnValue($this->entityType));
  $this->entityManager
    ->expects($this
    ->any())
    ->method('getFieldStorageDefinitions')
    ->with($this->entityType
    ->id())
    ->will($this
    ->returnValue($this->storageDefinitions));
  $this->dbSchemaHandler = $this
    ->getMockBuilder('Drupal\\Core\\Database\\Schema')
    ->disableOriginalConstructor()
    ->getMock();
  if ($expected) {
    $invocation_count = 0;
    $expected_table_names = array_keys($expected);
    $expected_table_schemas = array_values($expected);
    $this->dbSchemaHandler
      ->expects($this
      ->any())
      ->method('createTable')
      ->with($this
      ->callback(function ($table_name) use (&$invocation_count, $expected_table_names) {
      return $expected_table_names[$invocation_count] == $table_name;
    }), $this
      ->callback(function ($table_schema) use (&$invocation_count, $expected_table_schemas) {
      return $expected_table_schemas[$invocation_count] == $table_schema;
    }))
      ->will($this
      ->returnCallback(function () use (&$invocation_count) {
      $invocation_count++;
    }));
  }
  $connection = $this
    ->getMockBuilder('Drupal\\Core\\Database\\Connection')
    ->disableOriginalConstructor()
    ->getMock();
  $connection
    ->expects($this
    ->any())
    ->method('schema')
    ->will($this
    ->returnValue($this->dbSchemaHandler));
  $key_value = $this
    ->getMock('Drupal\\Core\\KeyValueStore\\KeyValueStoreInterface');
  $this->storageSchema = $this
    ->getMockBuilder('Drupal\\Core\\Entity\\Sql\\SqlContentEntityStorageSchema')
    ->setConstructorArgs(array(
    $this->entityManager,
    $this->entityType,
    $this->storage,
    $connection,
  ))
    ->setMethods(array(
    'installedStorageSchema',
    'loadEntitySchemaData',
    'hasSharedTableNameChanges',
    'isTableEmpty',
  ))
    ->getMock();
  $this->storageSchema
    ->expects($this
    ->any())
    ->method('installedStorageSchema')
    ->will($this
    ->returnValue($key_value));
  $this->storageSchema
    ->expects($this
    ->any())
    ->method('isTableEmpty')
    ->willReturn(FALSE);
}