You are here

protected function IntegrationTestBase::logPageChange in Search API Autocomplete 8

Logs a page change, if HTML output logging is enabled.

The base class only logs requests when the drupalGet() or drupalPost() methods are used, so we need to implement this ourselves for other page changes.

To enable HTML output logging, create some file where links to the logged pages should be placed and set the "BROWSERTEST_OUTPUT_FILE" environment variable to that file's path.

Parameters

string|null $url: (optional) The URL requested, if not the current URL.

string $method: (optional) The HTTP method used for the request.

See also

\Drupal\Tests\BrowserTestBase::drupalGet()

\Drupal\Tests\BrowserTestBase::setUp()

2 calls to IntegrationTestBase::logPageChange()
IntegrationTestBase::getAutocompleteSuggestions in tests/src/FunctionalJavascript/IntegrationTestBase.php
Retrieves autocomplete suggestions from a field on the current page.
PagesIntegrationTest::enableSearch in tests/src/FunctionalJavascript/PagesIntegrationTest.php
Enables the search.
1 method overrides IntegrationTestBase::logPageChange()
IntegrationTest::logPageChange in tests/src/FunctionalJavascript/IntegrationTest.php
Logs a page change, if HTML output logging is enabled.

File

tests/src/FunctionalJavascript/IntegrationTestBase.php, line 119

Class

IntegrationTestBase
Provides a base class for integration tests of this module.

Namespace

Drupal\Tests\search_api_autocomplete\FunctionalJavascript

Code

protected function logPageChange($url = NULL, $method = 'GET') {
  $session = $this
    ->getSession();
  $driver = $session
    ->getDriver();
  if (!$this->htmlOutputEnabled || $driver instanceof GoutteDriver) {
    return;
  }
  $current_url = $session
    ->getCurrentUrl();
  $url = $url ?: $current_url;
  $html_output = "{$method} request to: {$url}<hr />Ending URL: {$current_url}";
  $html_output .= '<hr />' . $session
    ->getPage()
    ->getContent();
  $html_output .= $this
    ->getHtmlOutputHeaders();
  $this
    ->htmlOutput($html_output);
}