protected function DrupalWebTestCase::drupalSetContent
7.x drupal_web_test_case.php | protected DrupalWebTestCase::drupalSetContent($content, $url = 'internal:') |
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.
12 calls to DrupalWebTestCase::drupalSetContent()
- BootstrapPageCacheTestCase::testPageCompression in drupal-7.x/
modules/ simpletest/ tests/ bootstrap.test - Test page compression.
- DrupalAddFeedTestCase::testBasicFeedAddNoTitle in drupal-7.x/
modules/ simpletest/ tests/ common.test - Test drupal_add_feed() with paths, URLs, and titles.
- DrupalHTTPRequestTestCase::testDrupalHTTPRequest in drupal-7.x/
modules/ simpletest/ tests/ common.test - DrupalHTTPRequestTestCase::testDrupalHTTPRequestBasicAuth in drupal-7.x/
modules/ simpletest/ tests/ common.test - DrupalRenderTestCase::assertRenderedElement in drupal-7.x/
modules/ simpletest/ tests/ common.test
File
- drupal-7.x/
modules/ simpletest/ drupal_web_test_case.php, line 2870
Class
- DrupalWebTestCase
- Test case for typical Drupal tests.
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('/jQuery\.extend\(Drupal\.settings, (.*?)\);/', $content, $matches)) {
$this->drupalSettings = drupal_json_decode($matches[1]);
}
}