You are here

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

File

core/tests/Drupal/Tests/Core/Entity/Sql/SqlContentEntityStorageSchemaTest.php, line 1090
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 providerTestRequiresEntityDataMigration() {
  $updated_entity_type_definition = $this
    ->getMock('\\Drupal\\Core\\Entity\\EntityTypeInterface');
  $updated_entity_type_definition
    ->expects($this
    ->any())
    ->method('getStorageClass')
    ->willReturn('\\Drupal\\Core\\Entity\\Sql\\SqlContentEntityStorageSchema');
  $original_entity_type_definition = $this
    ->getMock('\\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
    ->getMock('\\Drupal\\Core\\Entity\\EntityTypeInterface');
  $original_entity_type_definition_other_nonexisting
    ->expects($this
    ->any())
    ->method('getStorageClass')
    ->willReturn('bar');
  $original_entity_type_definition_other_existing = $this
    ->getMock('\\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,
    ],
  ];
}