function SqlContentEntityStorageSchemaTest::testRequiresEntityStorageSchemaChanges

Same name and namespace in other branches
  1. 8.9.x core/tests/Drupal/Tests/Core/Entity/Sql/SqlContentEntityStorageSchemaTest.php \Drupal\Tests\Core\Entity\Sql\SqlContentEntityStorageSchemaTest::testRequiresEntityStorageSchemaChanges()
  2. 10 core/tests/Drupal/Tests/Core/Entity/Sql/SqlContentEntityStorageSchemaTest.php \Drupal\Tests\Core\Entity\Sql\SqlContentEntityStorageSchemaTest::testRequiresEntityStorageSchemaChanges()
  3. 11.x 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 1306

Class

SqlContentEntityStorageSchemaTest
@coversDefaultClass \Drupal\Core\Entity\Sql\SqlContentEntityStorageSchema[[api-linebreak]] @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([
    'id' => 'entity_test',
    'entity_keys' => [
      'id' => 'id',
    ],
  ]);
  $this->setUpStorageSchema();
  $table_mapping = new TestSqlContentDefaultTableMapping($this->entityType, $this->storageDefinitions);
  $table_mapping->setFieldNames('entity_test', array_keys($this->storageDefinitions));
  $table_mapping->setExtraColumns('entity_test', [
    'default_langcode',
  ]);
  $this->storageSchema
    ->expects($this->any())
    ->method('getTableMapping')
    ->willReturn($table_mapping);
  // Setup storage schema.
  if ($change_schema) {
    $this->storageSchema
      ->expects($this->once())
      ->method('loadEntitySchemaData')
      ->willReturn([]);
  }
  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));
}

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