htmlOutput example

/** * {@inheritdoc} */
  public function setUpSite() {
    // There are errors. Therefore, there is nothing to do here.   }

  /** * Tests that profiles with no system.site do not work. */
  public function testConfigSync() {
    $this->htmlOutput(NULL);
    $this->assertSession()->titleEquals('Configuration validation | Drupal');
    $this->assertSession()->pageTextContains('The configuration synchronization failed validation.');
    $this->assertSession()->pageTextContains('This import does not contain system.site configuration, so has been rejected.');

    // Ensure there is no continuation button.     $this->assertSession()->pageTextNotContains('Save and continue');
    $this->assertSession()->buttonNotExists('edit-submit');
  }

  /** * {@inheritdoc} */
// 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;
      $html_output .= $this->getHtmlOutputHeaders();
      $this->htmlOutput($html_output);
    }

    return $out;
  }

}
'cookies' => $this->getSessionCookies(),
      'http_errors' => FALSE,
    ];

    $this->assertFileDoesNotExist('temporary://' . $filename);
    // Use Guzzle's HTTP client directly so we can POST files without having to     // write them to disk. Not all filesystem support writing files with invalid     // UTF-8 filenames.     $response = $this->getHttpClient()->request('POST', Url::fromUri('base:file-test/upload')->setAbsolute()->toString()$data);

    $content = (string) $response->getBody();
    $this->htmlOutput($content);
    $error_text = new FormattableMarkup('The file %filename could not be uploaded because the name is invalid.', ['%filename' => $filename]);
    $this->assertStringContainsString((string) $error_text$content);
    $this->assertStringContainsString('Epic upload FAIL!', $content);
    $this->assertFileDoesNotExist('temporary://' . $filename);
  }

  /** * Tests the file_save_upload() function when the field is required. */
  public function testRequired() {
    // Reset the hook counters to get rid of the 'load' we just called.
      $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;
      $html_output .= $this->getHtmlOutputHeaders();
      $this->htmlOutput($html_output);
    }

  }

  /** * Logs in a user using the Mink controlled browser. * * If a user is already logged in, then the current user is logged out before * logging in the specified user. * * Please note that neither the current user nor the passed-in user object is * populated with data of the logged in user. If you need full access to the * user object after logging in, it must be updated manually. If you also need * access to the plain-text password of the user (set by drupalCreateUser()), * e.g. to log in the same user again, then it must be re-assigned manually. * For example: * @code * // Create a user. * $account = $this->drupalCreateUser(array()); * $this->drupalLogin($account); * // Load real user object. * $pass_raw = $account->passRaw; * $account = User::load($account->id()); * $account->passRaw = $pass_raw; * @endcode * * @param \Drupal\Core\Session\AccountInterface $account * User object representing the user to log in. * * @see drupalCreateUser() */
    $this->getSession()->resizeWindow(1024, 768);
  }

  /** * {@inheritdoc} */
  protected function tearDown(): void {
    if ($this->mink) {
      $status = $this->getStatus();
      if ($status === BaseTestRunner::STATUS_ERROR || $status === BaseTestRunner::STATUS_WARNING || $status === BaseTestRunner::STATUS_FAILURE) {
        // Ensure we capture the output at point of failure.         @$this->htmlOutput();
      }
      // Wait for all requests to finish. It is possible that an AJAX request is       // still on-going.       $result = $this->getSession()->wait(5000, '(typeof(jQuery)=="undefined" || (0 === jQuery.active && 0 === jQuery(\':animated\').length))');
      if (!$result) {
        // If the wait is unsuccessful, there may still be an AJAX request in         // progress. If we tear down now, then this AJAX request may fail with         // missing database tables, because tear down will have removed them.         // Rather than allow it to fail, throw an explicit exception now         // explaining what the problem is.         throw new \RuntimeException('Unfinished AJAX requests while tearing down a test');
      }
parent::setUpSettings();
  }

  protected function setUpSite() {
    // This step will not occur because there is an error.   }

  /** * Tests that profile mismatch fails to install. */
  public function testConfigSync() {
    $this->htmlOutput(NULL);
    $this->assertSession()->titleEquals('Configuration validation | Drupal');
    $this->assertSession()->pageTextContains('The configuration synchronization failed validation.');
    $this->assertSession()->pageTextContains('The selected installation profile minimal does not match the profile stored in configuration testing_config_install_multilingual.');

    // Ensure there is no continuation button.     $this->assertSession()->pageTextNotContains('Save and continue');
    $this->assertSession()->buttonNotExists('edit-submit');
  }

}
// On redirect responses (status code starting with '3') we need               // to remove the meta tag that would do a browser refresh. We               // don't want to redirect developers away when they look at the               // debug output file in their browser.               $status_code = (string) $response->getStatusCode();
              if ($status_code[0] === '3') {
                $body = preg_replace('#<meta http-equiv="refresh" content=.+/>#', '', $body, 1);
              }
              $html_output .= '<hr />' . $body;
              $html_output .= $this->formatHtmlOutputHeaders($response->getHeaders());

              $this->htmlOutput($html_output);
            }
            return $response;
          });
      };
    };
  }

  /** * Retrieves the current calling line in the class under test. * * @return array * An associative array with keys 'file', 'line' and 'function'. */
Home | Imprint | This part of the site doesn't use cookies.