function BlockContentRemoveConstraint::testRunUpdates

Same name and namespace in other branches
  1. 11.x core/modules/block_content/tests/src/Functional/Update/BlockContentRemoveConstraint.php \Drupal\Tests\block_content\Functional\Update\BlockContentRemoveConstraint::testRunUpdates()

Tests the upgrade path for moderation state reindexing.

File

core/modules/block_content/tests/src/Functional/Update/BlockContentRemoveConstraint.php, line 43

Class

BlockContentRemoveConstraint
Tests the upgrade path for removing unique constraint on blocks.

Namespace

Drupal\Tests\block_content\Functional\Update

Code

public function testRunUpdates() : void {
  $constraint = 'UniqueField';
  $constraints = $this->getFieldInfoConstraints();
  if (!isset($constraints[$constraint])) {
    $constraints[$constraint] = [];
    $field_storage_definition = $this->entityDefinitionUpdateManager
      ->getFieldStorageDefinition('info', 'block_content');
    $field_storage_definition->setConstraints($constraints);
    $this->entityDefinitionUpdateManager
      ->updateFieldStorageDefinition($field_storage_definition);
  }
  $this->assertCount(2, $this->getFieldInfoConstraints());
  $this->runUpdates();
  $this->assertCount(1, $this->getFieldInfoConstraints());
}

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