function SqlContentEntityStorageSchemaTest::providerTestRequiresEntityDataMigration

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

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,
        ],
    ];
}

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