You are here

protected function UpdateTestBase::runUpdate in Taxonomy access fix 8.2

Applies an update hook and runs basic schema assertions.

Parameters

int $previous_schema: Schema version to reset to before the update.

int $target_schema: Schema version to assert during and after the update.

string $raw_message: Raw message to assert on update selection screen. Usually the comment used for the update hook. Some characters may be HTML encoded.

1 call to UpdateTestBase::runUpdate()
Update8202Test::testUpdateHook in tests/src/Functional/Update/Update8202Test.php
Tests that update hook 8202 is properly run.

File

tests/src/Functional/Update/UpdateTestBase.php, line 68

Class

UpdateTestBase
Provides an abstract base class to test Taxonomy Access Fix update hooks.

Namespace

Drupal\Tests\taxonomy_access_fix\Functional\Update

Code

protected function runUpdate(int $previous_schema, int $target_schema, string $raw_message) {

  // Set schema to previous schema.
  drupal_set_installed_schema_version('taxonomy_access_fix', $previous_schema);
  $this
    ->assertIdentical((int) drupal_get_installed_schema_version('taxonomy_access_fix', TRUE), $previous_schema, new FormattableMarkup('Schema of taxonomy_access_fix is @schema', [
    '@schema' => $previous_schema,
  ]));

  // Login and call update.php. Go to available updates step.
  $this
    ->drupalLogin($this->user);
  $this
    ->drupalGet($this->updateUrl, [
    'external' => TRUE,
  ]);
  $this
    ->updateRequirementsProblem();
  $this
    ->clickLink(t('Continue'));

  // Assert target update is available.
  $this
    ->assertRaw('taxonomy_access_fix module');
  $this
    ->assertRaw((string) $target_schema . ' - ');
  $this
    ->assertRaw($raw_message);

  // Run the update hooks.
  $this
    ->clickLink(t('Apply pending updates'));
  $this
    ->checkForMetaRefresh();

  // Ensure schema has changed.
  $this
    ->assertIdentical((int) drupal_get_installed_schema_version('taxonomy_access_fix', TRUE), $target_schema, new FormattableMarkup('Schema of taxonomy_access_fix is @schema', [
    '@schema' => $target_schema,
  ]));
}