<?php
-namespace Drupal\system\Tests\Update;
+namespace Drupal\Tests\system\Functional\Update;
use Drupal\Core\Url;
use Drupal\language\Entity\ConfigurableLanguage;
-use Drupal\simpletest\WebTestBase;
+use Drupal\Tests\BrowserTestBase;
/**
* Tests the update script access and functionality.
*
* @group Update
*/
-class UpdateScriptTest extends WebTestBase {
+class UpdateScriptTest extends BrowserTestBase {
/**
* Modules to enable.
$this->assertNoText('This is a requirements warning provided by the update_script_test module.');
$this->clickLink(t('Continue'));
$this->clickLink(t('Apply pending updates'));
+ $this->checkForMetaRefresh();
$this->assertText(t('The update_script_test_update_8001() update was executed successfully.'), 'End of update process was reached.');
// Confirm that all caches were cleared.
$this->assertText(t('hook_cache_flush() invoked for update_script_test.module.'), 'Caches were cleared after resolving a requirements warning and applying updates.');
$this->clickLink(t('Continue'));
$this->assertText(t('No pending updates.'));
$this->assertNoLink('Administration pages');
- $this->assertNoLinkByHrefInMainRegion('update.php', 0);
+ $this->assertEmpty($this->xpath('//main//a[contains(@href, :href)]', [':href' => 'update.php']));
$this->clickLink('Front page');
$this->assertResponse(200);
$this->clickLink(t('Continue'));
$this->assertText(t('No pending updates.'));
$this->assertLink('Administration pages');
- $this->assertNoLinkByHrefInMainRegion('update.php', 1);
+ $this->assertEmpty($this->xpath('//main//a[contains(@href, :href)]', [':href' => 'update.php']));
$this->clickLink('Administration pages');
$this->assertResponse(200);
}
public function testSuccessfulUpdateFunctionality() {
$initial_maintenance_mode = $this->container->get('state')->get('system.maintenance_mode');
$this->assertFalse($initial_maintenance_mode, 'Site is not in maintenance mode.');
- $this->updateScriptTest($initial_maintenance_mode);
+ $this->runUpdates($initial_maintenance_mode);
$final_maintenance_mode = $this->container->get('state')->get('system.maintenance_mode');
$this->assertEqual($final_maintenance_mode, $initial_maintenance_mode, 'Maintenance mode should not have changed after database updates.');
$this->drupalGet($this->updateUrl, ['external' => TRUE]);
$this->clickLink(t('Continue'));
$this->clickLink(t('Apply pending updates'));
+ $this->checkForMetaRefresh();
$this->assertText('Updates were attempted.');
$this->assertLink('logged');
$this->assertLink('Administration pages');
- $this->assertNoLinkByHrefInMainRegion('update.php', 1);
+ $this->assertEmpty($this->xpath('//main//a[contains(@href, :href)]', [':href' => 'update.php']));
$this->clickLink('Administration pages');
$this->assertResponse(200);
}
$initial_maintenance_mode = $this->container->get('state')
->get('system.maintenance_mode');
$this->assertTrue($initial_maintenance_mode, 'Site is in maintenance mode.');
- $this->updateScriptTest($initial_maintenance_mode);
+ $this->runUpdates($initial_maintenance_mode);
$final_maintenance_mode = $this->container->get('state')
->get('system.maintenance_mode');
$this->assertEqual($final_maintenance_mode, $initial_maintenance_mode, 'Maintenance mode should not have changed after database updates.');
$this->drupalGet($this->updateUrl, ['external' => TRUE]);
$this->clickLink(t('Continue'));
$this->clickLink(t('Apply pending updates'));
+ $this->checkForMetaRefresh();
$this->assertText('Updates were attempted.');
$this->assertLink('logged');
$this->assertLink('Administration pages');
- $this->assertNoLinkByHrefInMainRegion('update.php', 1);
+ $this->assertEmpty($this->xpath('//main//a[contains(@href, :href)]', [':href' => 'update.php']));
$this->clickLink('Administration pages');
$this->assertResponse(200);
}
/**
* Helper function to run updates via the browser.
*/
- protected function updateScriptTest($maintenance_mode) {
+ protected function runUpdates($maintenance_mode) {
$schema_version = drupal_get_installed_schema_version('update_script_test');
$this->assertEqual($schema_version, 8001, 'update_script_test is initially installed with schema version 8001.');
$this->drupalGet($this->updateUrl, ['external' => TRUE]);
$this->clickLink(t('Continue'));
$this->clickLink(t('Apply pending updates'));
+ $this->checkForMetaRefresh();
// Verify that updates were completed successfully.
$this->assertText('Updates were attempted.');
// Verify that there are no links to different parts of the workflow.
$this->assertNoLink('Administration pages');
- $this->assertNoLinkByHrefInMainRegion('update.php', 0);
+ $this->assertEmpty($this->xpath('//main//a[contains(@href, :href)]', [':href' => 'update.php']));
$this->assertNoLink('logged');
// Verify the front page can be visited following the upgrade.