You are here

public function SqlContentEntityStorageSchemaTest::testRequiresEntityStorageSchemaChanges 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::testRequiresEntityStorageSchemaChanges()

@covers ::requiresEntityStorageSchemaChanges

@dataProvider providerTestRequiresEntityStorageSchemaChanges

File

core/tests/Drupal/Tests/Core/Entity/Sql/SqlContentEntityStorageSchemaTest.php, line 1247
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 testRequiresEntityStorageSchemaChanges(ContentEntityTypeInterface $updated, ContentEntityTypeInterface $original, $requires_change, $change_schema, $change_shared_table) {
  $this->entityType = new ContentEntityType(array(
    'id' => 'entity_test',
    'entity_keys' => array(
      'id' => 'id',
    ),
  ));
  $this
    ->setUpStorageSchema();
  $table_mapping = new DefaultTableMapping($this->entityType, $this->storageDefinitions);
  $table_mapping
    ->setFieldNames('entity_test', array_keys($this->storageDefinitions));
  $table_mapping
    ->setExtraColumns('entity_test', array(
    'default_langcode',
  ));
  $this->storage
    ->expects($this
    ->any())
    ->method('getTableMapping')
    ->will($this
    ->returnValue($table_mapping));

  // Setup storage schema.
  if ($change_schema) {
    $this->storageSchema
      ->expects($this
      ->once())
      ->method('loadEntitySchemaData')
      ->willReturn(array());
  }
  else {
    $expected = [
      'entity_test' => [
        'primary key' => [
          'id',
        ],
      ],
    ];
    $this->storageSchema
      ->expects($this
      ->any())
      ->method('loadEntitySchemaData')
      ->willReturn($expected);
  }
  if ($change_shared_table) {
    $this->storageSchema
      ->expects($this
      ->once())
      ->method('hasSharedTableNameChanges')
      ->willReturn(TRUE);
  }
  $this
    ->assertEquals($requires_change, $this->storageSchema
    ->requiresEntityStorageSchemaChanges($updated, $original));
}