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 drupal_http_request(). After fetching the page the content can be set and page elements can be checked to ensure that the function worked properly.

17 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.
BrowserTest::testXPathEscaping in drupal/core/modules/simpletest/lib/Drupal/simpletest/Tests/BrowserTest.php
Tests XPath escaping.
DisplayApiTest::testFieldViewField in drupal/core/modules/field/lib/Drupal/field/Tests/DisplayApiTest.php
Test the field_view_field() function.
DisplayApiTest::testFieldViewValue in drupal/core/modules/field/lib/Drupal/field/Tests/DisplayApiTest.php
Test the field_view_value() function.
EmailFieldTest::testEmailField in drupal/core/modules/field/modules/email/lib/Drupal/email/Tests/EmailFieldTest.php
Tests e-mail field.

... See full list

File

drupal/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php, line 2046
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 = (.*?);/', $content, $matches)) {
    $this->drupalSettings = drupal_json_decode($matches[1]);
  }
}