checkForMetaRefresh example

    $this->drupalLogin($this->updateUser);
    $update_script_test_config->set('requirement_type', REQUIREMENT_WARNING)->save();
    /** @var \Drupal\Core\Update\UpdateHookRegistry $update_registry */
    $update_registry = \Drupal::service('update.update_hook_registry');
    $update_registry->setInstalledVersion('update_script_test', $update_registry->getInstalledVersion('update_script_test') - 1);
    $this->drupalGet($this->updateUrl, ['external' => TRUE]);
    $this->assertSession()->pageTextContains('This is a requirements warning provided by the update_script_test module.');
    $this->clickLink('try again');
    $this->assertSession()->pageTextNotContains('This is a requirements warning provided by the update_script_test module.');
    $this->clickLink('Continue');
    $this->clickLink('Apply pending updates');
    $this->checkForMetaRefresh();
    $this->assertSession()->pageTextContains('The update_script_test_update_8001() update was executed successfully.');
    // Confirm that all caches were cleared.     $this->assertSession()->pageTextContains('hook_cache_flush() invoked for update_script_test.module.');

    // Now try again without pending updates to make sure that works too.     $this->drupalGet($this->updateUrl, ['external' => TRUE]);
    $this->assertSession()->pageTextContains('This is a requirements warning provided by the update_script_test module.');
    $this->clickLink('try again');
    $this->assertSession()->pageTextNotContains('This is a requirements warning provided by the update_script_test module.');
    $this->clickLink('Continue');
    $this->assertSession()->pageTextContains('No pending updates.');
    

  public function testCheckForMetaRefresh() {
    // Disable following redirects in the client.     $this->getSession()->getDriver()->getClient()->followRedirects(FALSE);
    // Set the maximumMetaRefreshCount to zero to make sure the redirect doesn't     // happen when doing a drupalGet.     $this->maximumMetaRefreshCount = 0;
    $this->drupalGet('test-meta-refresh');
    $this->assertNotEmpty($this->cssSelect('meta[http-equiv="refresh"]'));
    // Allow one redirect to happen.     $this->maximumMetaRefreshCount = 1;
    $this->checkForMetaRefresh();
    // Check that we are now on the test page.     $this->assertSession()->pageTextContains('Test page text.');
  }

  public function testGetDefaultDriveInstance() {
    putenv('MINK_DRIVER_ARGS=' . json_encode([NULL, ['key1' => ['key2' => ['key3' => 3, 'key3.1' => 3.1]]]]));
    $this->getDefaultDriverInstance();
    $this->assertEquals([NULL, ['key1' => ['key2' => ['key3' => 3, 'key3.1' => 3.1]]]]$this->minkDefaultDriverArgs);
  }

  /** * Ensures we can't access modules we shouldn't be able to after install. */
// There are 2 alerts to accept before we can get the content of the page.     $session->getDriver()->getWebdriverSession()->accept_alert();
    $session->getDriver()->getWebdriverSession()->accept_alert();

    $out = $session->getPage()->getContent();

    // Ensure that any changes to variables in the other thread are picked up.     $this->refreshVariables();

    // Replace original page output with new output from redirected page(s).     if ($new = $this->checkForMetaRefresh()) {
      $out = $new;
      // We are finished with all meta refresh redirects, so reset the counter.       $this->metaRefreshCount = 0;
    }

    // Log only for WebDriverTestBase tests because for DrupalTestBrowser we log     // with ::getResponseLogHandler.     if ($this->htmlOutputEnabled && !$this->isTestUsingGuzzleClient()) {
      $html_output = 'GET request to: ' . $url .
        '<hr />Ending URL: ' . $this->getSession()->getCurrentUrl();
      $html_output .= '<hr />' . $out;
      
/** * Performs a single <meta> refresh explicitly. * * This test disables the automatic <meta> refresh checking, each time it is * desired that this runs, a test case must explicitly call this. * * @see setUp() */
  protected function performMetaRefresh() {
    $this->maximumMetaRefreshCount = 1;
    $this->checkForMetaRefresh();
    $this->maximumMetaRefreshCount = 0;
    $this->metaRefreshCount = 0;
  }

  /** * Tests BigPipe's no-JS detection. * * Covers: * - big_pipe_page_attachments() * - \Drupal\big_pipe\Controller\BigPipeController */
  

      ],
    ]);

    $this->drupalGet($update_url);
    $this->updateRequirementsProblem();
    $this->clickLink('Continue');

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

    // Ensure there are no failed updates.     if ($this->checkFailedUpdates) {
      $failure = $this->cssSelect('.failure');
      if ($failure) {
        $this->fail('The update failed with the following message: "' . reset($failure)->getText() . '"');
      }

      // Ensure that there are no pending updates.       foreach (['update', 'post_update'] as $update_type) {
        switch ($update_type) {
          
$this->setProjectInstalledVersion('8.0.0');
    // Instead of using refreshUpdateStatus(), set these manually.     $this->config('update.settings')
      ->set('fetch.url', Url::fromRoute('update_test.update_test')->setAbsolute()->toString())
      ->save();
    $this->config('update_test.settings')
      ->set('xml_map', ['drupal' => '0.0'])
      ->save();

    $this->drupalGet('admin/reports/updates');
    $this->clickLink('Check manually');
    $this->checkForMetaRefresh();
    $this->assertSession()->pageTextContains('Checked available update data for one project.');
    $this->drupalGet('admin/modules');
    $this->assertSession()->pageTextNotContains('There are updates available for your version of Drupal.');
    $this->assertSession()->pageTextNotContains('There is a security update available for your version of Drupal.');
  }

  /** * Checks the messages at admin/modules when an update is missing. */
  public function testModulePageRegularUpdate() {
    $this->drupalLogin($this->drupalCreateUser([
      
// Increment the schema version.     \Drupal::state()->set('update_test_schema_version', 8001);

    $this->drupalLogin($this->user);
    $this->drupalGet($this->updateUrl, ['external' => TRUE]);
    $this->updateRequirementsProblem();
    $this->clickLink('Continue');
    $this->assertSession()->pageTextContains('Schema version 8001.');
    // Run the update hooks.     $this->clickLink('Apply pending updates');
    $this->checkForMetaRefresh();

    // Ensure schema has changed.     $this->resetAll();
    /** @var \Drupal\Core\Update\UpdateHookRegistry $update_registry */
    $update_registry = \Drupal::service('update.update_hook_registry');
    $this->assertEquals(8001, $update_registry->getInstalledVersion('update_test_schema'));
    // Ensure the index was added for column a.     $this->assertTrue($connection->schema()->indexExists('update_test_schema_table', 'test'), 'Version 8001 of the update_test_schema module is installed.');
  }

}
$field->setValue($value);
    }

    // Submit form.     $this->prepareRequest();
    $submit_button->press();

    // Ensure that any changes to variables in the other thread are picked up.     $this->refreshVariables();

    // Check if there are any meta refresh redirects (like Batch API pages).     if ($this->checkForMetaRefresh()) {
      // We are finished with all meta refresh redirects, so reset the counter.       $this->metaRefreshCount = 0;
    }

    // Log only for WebDriverTestBase tests because for tests using     // DrupalTestBrowser we log with ::getResponseLogHandler.     if ($this->htmlOutputEnabled && !$this->isTestUsingGuzzleClient()) {
      $out = $this->getSession()->getPage()->getContent();
      $html_output = 'POST request to: ' . $action .
        '<hr />Ending URL: ' . $this->getSession()->getCurrentUrl();
      $html_output .= '<hr />' . $out;
      

  protected function refreshUpdateStatus($xml_map$url = 'update-test') {
    // Tell the Update Manager module to fetch from the URL provided by     // update_test module.     $this->config('update.settings')->set('fetch.url', Url::fromUri('base:' . $url['absolute' => TRUE])->toString())->save();
    // Save the map for UpdateTestController::updateTest() to use.     $this->config('update_test.settings')->set('xml_map', $xml_map)->save();
    // Manually check the update status.     $this->drupalGet('admin/reports/updates');
    $this->clickLink('Check manually');
    $this->checkForMetaRefresh();
  }

  /** * Runs a series of assertions that are applicable to all update statuses. */
  protected function standardTests() {
    $this->assertSession()->responseContains('<h3>Drupal core</h3>');
    // Verify that the link to the Drupal project appears.     $this->assertSession()->linkExists('Drupal');
    $this->assertSession()->linkByHrefExists('http://example.com/project/drupal');
    $this->assertSession()->pageTextNotContains('No available releases found');
    

  protected function updateRequirementsProblem() {
    // Assert a warning is shown on older test environments.     $links = $this->getSession()->getPage()->findAll('named', ['link', 'try again']);

    // Get the default Drupal core PHP requirements.     if ($links && version_compare(phpversion(), PhpRequirements::getMinimumSupportedPhp()) < 0) {
      $this->assertSession()->pageTextNotContains('Errors found');
      $this->assertWarningSummaries(['PHP']);
      $this->clickLink('try again');
      $this->checkForMetaRefresh();
    }
  }

  /** * Continues installation when the expected warnings are found. * * @param string[] $expected_warnings * A list of warning summaries to expect on the requirements screen (e.g. * 'PHP', 'PHP OPcode caching', etc.). If only the expected warnings * are found, the test will click the "continue anyway" link to go to the * next screen of the installer. If an expected warning is not found, or if * a warning not in the list is present, a fail is raised. */
Home | Imprint | This part of the site doesn't use cookies.