Error message
You are browsing documentation for drupal 7.x, which is not supported anymore. Read the updated version of this page for drupal 11.x (the latest version).function JavaScriptTestCase::testLibraryRender
Adds a library to the page and tests for both its JavaScript and its CSS.
File
-
modules/
simpletest/ tests/ common.test, line 1952
Class
- JavaScriptTestCase
- Tests for the JavaScript system.
Code
function testLibraryRender() {
$result = drupal_add_library ('system', 'farbtastic');
$this->assertTrue ($result !== FALSE, 'Library was added without errors.');
$scripts = drupal_get_js ();
$styles = drupal_get_css ();
$this->assertTrue (strpos ($scripts, 'misc/farbtastic/farbtastic.js'), 'JavaScript of library was added to the page.');
$this->assertTrue (strpos ($styles, 'misc/farbtastic/farbtastic.css'), 'Stylesheet of library was added to the page.');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.