function SqlContentEntityStorageSchemaTest::providerTestRequiresEntityStorageSchemaChanges

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::providerTestRequiresEntityStorageSchemaChanges()
  2. 10 core/tests/Drupal/Tests/Core/Entity/Sql/SqlContentEntityStorageSchemaTest.php \Drupal\Tests\Core\Entity\Sql\SqlContentEntityStorageSchemaTest::providerTestRequiresEntityStorageSchemaChanges()
  3. 11.x core/tests/Drupal/Tests/Core/Entity/Sql/SqlContentEntityStorageSchemaTest.php \Drupal\Tests\Core\Entity\Sql\SqlContentEntityStorageSchemaTest::providerTestRequiresEntityStorageSchemaChanges()

Data provider for ::testRequiresEntityStorageSchemaChanges().

File

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

Class

SqlContentEntityStorageSchemaTest
@coversDefaultClass <a href="/api/drupal/core%21lib%21Drupal%21Core%21Entity%21Sql%21SqlContentEntityStorageSchema.php/class/SqlContentEntityStorageSchema/9" title="Defines a schema handler that supports revisionable, translatable entities." class="local">\Drupal\Core\Entity\Sql\SqlContentEntityStorageSchema</a> @group Entity

Namespace

Drupal\Tests\Core\Entity\Sql

Code

public function providerTestRequiresEntityStorageSchemaChanges() {
    $cases = [];
    $updated_entity_type_definition = $this->createMock('\\Drupal\\Core\\Entity\\ContentEntityTypeInterface');
    $original_entity_type_definition = $this->createMock('\\Drupal\\Core\\Entity\\ContentEntityTypeInterface');
    $updated_entity_type_definition->expects($this->any())
        ->method('id')
        ->willReturn('entity_test');
    $updated_entity_type_definition->expects($this->any())
        ->method('getKey')
        ->willReturn('id');
    $original_entity_type_definition->expects($this->any())
        ->method('id')
        ->willReturn('entity_test');
    $original_entity_type_definition->expects($this->any())
        ->method('getKey')
        ->willReturn('id');
    // Storage class changes should not impact this at all, and should not be
    // checked.
    $updated = clone $updated_entity_type_definition;
    $original = clone $original_entity_type_definition;
    $updated->expects($this->never())
        ->method('getStorageClass');
    $original->expects($this->never())
        ->method('getStorageClass');
    // Case 1: No shared table changes should not require change.
    $cases[] = [
        $updated,
        $original,
        FALSE,
        FALSE,
        FALSE,
    ];
    // Case 2: A change in the entity schema should result in required changes.
    $cases[] = [
        $updated,
        $original,
        TRUE,
        TRUE,
        FALSE,
    ];
    // Case 3: Has shared table changes should result in required changes.
    $cases[] = [
        $updated,
        $original,
        TRUE,
        FALSE,
        TRUE,
    ];
    // Case 4: Changing translation should result in required changes.
    $updated = clone $updated_entity_type_definition;
    $updated->expects($this->once())
        ->method('isTranslatable')
        ->willReturn(FALSE);
    $original = clone $original_entity_type_definition;
    $original->expects($this->once())
        ->method('isTranslatable')
        ->willReturn(TRUE);
    $cases[] = [
        $updated,
        $original,
        TRUE,
        FALSE,
        FALSE,
    ];
    // Case 5: Changing revisionable should result in required changes.
    $updated = clone $updated_entity_type_definition;
    $updated->expects($this->once())
        ->method('isRevisionable')
        ->willReturn(FALSE);
    $original = clone $original_entity_type_definition;
    $original->expects($this->once())
        ->method('isRevisionable')
        ->willReturn(TRUE);
    $cases[] = [
        $updated,
        $original,
        TRUE,
        FALSE,
        FALSE,
    ];
    return $cases;
}

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