You are here

protected function IntegrationTest::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.

Overrides IntegrationTestBase::logPageChange

See also

\Drupal\Tests\BrowserTestBase::drupalGet()

\Drupal\Tests\BrowserTestBase::setUp()

4 calls to IntegrationTest::logPageChange()
IntegrationTest::checkLiveResultsAutocomplete in tests/src/FunctionalJavascript/IntegrationTest.php
Tests autocomplete with the "Live results" suggester.
IntegrationTest::checkSearchAutocomplete in tests/src/FunctionalJavascript/IntegrationTest.php
Tests autocompletion in the search form.
IntegrationTest::configureSearch in tests/src/FunctionalJavascript/IntegrationTest.php
Configures the test search via the UI.
IntegrationTest::enableSearch in tests/src/FunctionalJavascript/IntegrationTest.php
Goes to the index's "Autocomplete" tab and creates/enables the test search.

File

tests/src/FunctionalJavascript/IntegrationTest.php, line 586

Class

IntegrationTest
Tests the functionality of the whole module from a user's perspective.

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);
}