You are here

public function SqlContentEntityStorageSchemaTest::providerTestRequiresEntityDataMigration in Drupal 8

File

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

Class

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

Namespace

Drupal\Tests\Core\Entity\Sql

Code

public function providerTestRequiresEntityDataMigration() {
  $updated_entity_type_definition = $this
    ->createMock('\\Drupal\\Core\\Entity\\EntityTypeInterface');
  $updated_entity_type_definition
    ->expects($this
    ->any())
    ->method('getStorageClass')
    ->willReturn('\\Drupal\\Core\\Entity\\Sql\\SqlContentEntityStorageSchema');
  $original_entity_type_definition = $this
    ->createMock('\\Drupal\\Core\\Entity\\EntityTypeInterface');
  $original_entity_type_definition
    ->expects($this
    ->any())
    ->method('getStorageClass')
    ->willReturn('\\Drupal\\Core\\Entity\\Sql\\SqlContentEntityStorageSchema');
  $original_entity_type_definition_other_nonexisting = $this
    ->createMock('\\Drupal\\Core\\Entity\\EntityTypeInterface');
  $original_entity_type_definition_other_nonexisting
    ->expects($this
    ->any())
    ->method('getStorageClass')
    ->willReturn('bar');
  $original_entity_type_definition_other_existing = $this
    ->createMock('\\Drupal\\Core\\Entity\\EntityTypeInterface');
  $original_entity_type_definition_other_existing
    ->expects($this
    ->any())
    ->method('getStorageClass')
    ->willReturn('\\Drupal\\Core\\Entity\\Sql\\SqlContentEntityStorageSchema');
  return [
    // Case 1: same storage class, ::hasData() === TRUE.
    [
      $updated_entity_type_definition,
      $original_entity_type_definition,
      TRUE,
      TRUE,
      TRUE,
    ],
    // Case 2: same storage class, ::hasData() === FALSE.
    [
      $updated_entity_type_definition,
      $original_entity_type_definition,
      FALSE,
      TRUE,
      FALSE,
    ],
    // Case 3: different storage class, original storage class does not exist.
    [
      $updated_entity_type_definition,
      $original_entity_type_definition_other_nonexisting,
      NULL,
      TRUE,
      TRUE,
    ],
    // Case 4: different storage class, original storage class exists,
    // ::hasData() === TRUE.
    [
      $updated_entity_type_definition,
      $original_entity_type_definition_other_existing,
      TRUE,
      TRUE,
      TRUE,
    ],
    // Case 5: different storage class, original storage class exists,
    // ::hasData() === FALSE.
    [
      $updated_entity_type_definition,
      $original_entity_type_definition_other_existing,
      FALSE,
      TRUE,
      FALSE,
    ],
    // Case 6: same storage class, ::hasData() === TRUE, no structure changes.
    [
      $updated_entity_type_definition,
      $original_entity_type_definition,
      TRUE,
      FALSE,
      FALSE,
    ],
    // Case 7: different storage class, original storage class exists,
    // ::hasData() === TRUE, no structure changes.
    [
      $updated_entity_type_definition,
      $original_entity_type_definition_other_existing,
      TRUE,
      FALSE,
      FALSE,
    ],
  ];
}