protected function WebTestBase::drupalSetContent

Sets the raw HTML content. This can be useful when a page has been fetched outside of the internal browser and assertions need to be made on the returned page.

A good example would be when testing HTTP request made by Drupal. After fetching the page the content can be set and page elements can be checked to ensure that the function worked properly.

20 calls to WebTestBase::drupalSetContent()
AddFeedTest::testBasicFeedAddNoTitle in drupal/core/modules/system/lib/Drupal/system/Tests/Common/AddFeedTest.php
Tests drupal_add_feed() with paths, URLs, and titles.
AreaEntityTest::testEntityArea in drupal/core/modules/views/lib/Drupal/views/Tests/Handler/AreaEntityTest.php
Tests the area handler.
BrowserTest::testXPathEscaping in drupal/core/modules/simpletest/lib/Drupal/simpletest/Tests/BrowserTest.php
Tests XPath escaping.
DatetimeFieldTest::renderTestEntity in drupal/core/modules/datetime/lib/Drupal/datetime/Tests/DatetimeFieldTest.php
Renders a entity_test and sets the output in the internal browser.
DisplayTest::testReadMore in drupal/core/modules/views/lib/Drupal/views/Tests/Plugin/DisplayTest.php
Tests the readmore functionality.

... See full list

File

drupal/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php, line 2253
Definition of Drupal\simpletest\WebTestBase.

Class

WebTestBase
Test case for typical Drupal tests.

Namespace

Drupal\simpletest

Code

protected function drupalSetContent($content, $url = 'internal:') {
  $this->content = $content;
  $this->url = $url;
  $this->plainTextContent = FALSE;
  $this->elements = FALSE;
  $this->drupalSettings = array();
  if (preg_match('/var drupalSettings = (.*?);$/m', $content, $matches)) {
    $this->drupalSettings = drupal_json_decode($matches[1]);
  }
}