Security update for Core, with self-updated composer
[yaffs-website] / web / core / modules / system / tests / src / Functional / Update / UpdateScriptTest.php
similarity index 94%
rename from web/core/modules/system/src/Tests/Update/UpdateScriptTest.php
rename to web/core/modules/system/tests/src/Functional/Update/UpdateScriptTest.php
index ed076b8156799e5eb7baa68b5d185db11444288b..29d4d08e238b5e720f568517555a6793b2176578 100644 (file)
@@ -1,17 +1,17 @@
 <?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.
@@ -119,6 +119,7 @@ class UpdateScriptTest extends WebTestBase {
     $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.');
@@ -167,7 +168,7 @@ class UpdateScriptTest extends WebTestBase {
     $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);
 
@@ -178,7 +179,7 @@ class UpdateScriptTest extends WebTestBase {
     $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);
   }
@@ -189,7 +190,7 @@ class UpdateScriptTest extends WebTestBase {
   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.');
 
@@ -209,10 +210,11 @@ class UpdateScriptTest extends WebTestBase {
     $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);
   }
@@ -226,7 +228,7 @@ class UpdateScriptTest extends WebTestBase {
     $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.');
@@ -275,10 +277,11 @@ class UpdateScriptTest extends WebTestBase {
     $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);
   }
@@ -286,7 +289,7 @@ class UpdateScriptTest extends WebTestBase {
   /**
    * 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.');
 
@@ -306,6 +309,7 @@ class UpdateScriptTest extends WebTestBase {
     $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.');
@@ -318,7 +322,7 @@ class UpdateScriptTest extends WebTestBase {
 
     // 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.