You are here

class AdvAggJavaScriptTestCase in Advanced CSS/JS Aggregation 7.2

Tests for the JavaScript system.

Hierarchy

Expanded class hierarchy of AdvAggJavaScriptTestCase

Related topics

File

tests/advagg.test, line 749
Tests for advagg.module.

View source
class AdvAggJavaScriptTestCase extends DrupalWebTestCase {

  /**
   * Store configured value for JavaScript preprocessing.
   *
   * @var bool
   */
  protected $preprocessJs = NULL;

  /**
   * Provide information to the UI for this test.
   */
  public static function getInfo() {
    return array(
      'name' => 'JavaScript',
      'description' => 'Tests the JavaScript system.',
      'group' => 'AdvAgg',
    );
  }

  /**
   * Install the advagg module and include needed files.
   */
  public function setUp() {

    // Enable Locale and SimpleTest in the test environment.
    parent::setUp(array(
      'locale',
      'locale_test',
      'simpletest',
      'common_test',
      'form_test',
      'advagg',
      'color',
    ));

    // Include the advagg.module file.
    drupal_load('module', 'advagg');
    module_load_include('inc', 'advagg', 'advagg');

    // Disable preprocessing.
    $this->preprocessJs = variable_get('preprocess_js', 0);
    variable_set('preprocess_js', 0);

    // Reset before each test.
    advagg_test_reset_statics();

    // Set settings for testing.
    $GLOBALS['conf']['advagg_convert_absolute_to_relative_path'] = FALSE;
    $GLOBALS['conf']['advagg_convert_absolute_to_protocol_relative_path'] = FALSE;
    $GLOBALS['conf']['advagg_force_https_path'] = FALSE;
    $GLOBALS['conf']['advagg_mod_js_footer'] = 0;
  }

  /**
   * Restore any variables we set.
   */
  public function tearDown() {

    // Restore configured value for JavaScript preprocessing.
    variable_set('preprocess_js', $this->preprocessJs);
    parent::tearDown();
  }

  /**
   * Test the 'javascript_always_use_jquery' variable.
   */
  public function testJavaScriptAlwaysUsejQuery() {

    // The default front page of the site should use jQuery and other standard
    // scripts and settings.
    advagg_test_reset_statics();
    $GLOBALS['conf']['advagg_convert_absolute_to_relative_path'] = FALSE;
    $GLOBALS['conf']['advagg_convert_absolute_to_protocol_relative_path'] = FALSE;
    $GLOBALS['conf']['advagg_force_https_path'] = FALSE;
    $GLOBALS['conf']['advagg_mod_js_footer'] = 0;
    $this
      ->drupalGet('');
    $this
      ->assertRaw('misc/jquery.js', 'Default behavior: The front page of the site includes jquery.js.');
    $this
      ->assertRaw('misc/drupal.js', 'Default behavior: The front page of the site includes drupal.js.');
    $this
      ->assertRaw('Drupal.settings', 'Default behavior: The front page of the site includes Drupal settings.');
    $this
      ->assertRaw('basePath', 'Default behavior: The front page of the site includes the basePath Drupal setting.');

    //
    // The default front page should not use jQuery and other standard scripts
    // and settings when the 'javascript_always_use_jquery' variable is set to
    // FALSE.
    advagg_test_reset_statics();
    variable_set('javascript_always_use_jquery', FALSE);
    $render_array = advagg_get_js();
    $javascript = drupal_render($render_array);
    $this
      ->drupalGet('');
    $this
      ->assertNoRaw('misc/jquery.js', 'When "javascript_always_use_jquery" is FALSE: The front page of the site does not include jquery.js.');
    $this
      ->assertNoRaw('misc/drupal.js', 'When "javascript_always_use_jquery" is FALSE: The front page of the site does not include drupal.js.');
    $this
      ->assertNoRaw('Drupal.settings', 'When "javascript_always_use_jquery" is FALSE: The front page of the site does not include Drupal settings.');
    $this
      ->assertNoRaw('basePath', 'When "javascript_always_use_jquery" is FALSE: The front page of the site does not include the basePath Drupal setting.');
    variable_del('javascript_always_use_jquery');

    //
    // When only settings have been added via drupal_add_js(), drupal_get_js()
    // should still return jQuery and other standard scripts and settings.
    advagg_test_reset_statics();
    drupal_add_js(array(
      'testJavaScriptSetting' => 'test',
    ), 'setting');
    $render_array = advagg_get_js();
    $javascript = drupal_render($render_array);
    $this
      ->assertTrue(strpos($javascript, 'misc/jquery.js') !== FALSE, 'Default behavior: The JavaScript returned by drupal_get_js() when only settings have been added includes jquery.js.');
    $this
      ->assertTrue(strpos($javascript, 'misc/drupal.js') !== FALSE, 'Default behavior: The JavaScript returned by drupal_get_js() when only settings have been added includes drupal.js.');
    $this
      ->assertTrue(strpos($javascript, 'Drupal.settings') !== FALSE, 'Default behavior: The JavaScript returned by drupal_get_js() when only settings have been added includes Drupal.settings.');
    $this
      ->assertTrue(strpos($javascript, 'basePath') !== FALSE, 'Default behavior: The JavaScript returned by drupal_get_js() when only settings have been added includes the basePath Drupal setting.');
    $this
      ->assertTrue(strpos($javascript, 'testJavaScriptSetting') !== FALSE, 'Default behavior: The JavaScript returned by drupal_get_js() when only settings have been added includes the added Drupal settings.');

    //
    // When only settings have been added via drupal_add_js() and the
    // 'javascript_always_use_jquery' variable is set to FALSE, drupal_get_js()
    // should not return jQuery and other standard scripts and settings, nor
    // should it return the requested settings (since they cannot actually be
    // added to the page without jQuery).
    advagg_test_reset_statics();
    variable_set('javascript_always_use_jquery', FALSE);
    drupal_add_js(array(
      'testJavaScriptSetting' => 'test',
    ), 'setting');
    $render_array = advagg_get_js();
    $javascript = drupal_render($render_array);
    $this
      ->assertTrue(strpos($javascript, 'misc/jquery.js') === FALSE, 'When "javascript_always_use_jquery" is FALSE: The JavaScript returned by drupal_get_js() when only settings have been added does not include jquery.js.');
    $this
      ->assertTrue(strpos($javascript, 'misc/drupal.js') === FALSE, 'When "javascript_always_use_jquery" is FALSE: The JavaScript returned by drupal_get_js() when only settings have been added does not include drupal.js.');
    $this
      ->assertTrue(strpos($javascript, 'Drupal.settings') === FALSE, 'When "javascript_always_use_jquery" is FALSE: The JavaScript returned by drupal_get_js() when only settings have been added does not include Drupal.settings.');
    $this
      ->assertTrue(strpos($javascript, 'basePath') === FALSE, 'When "javascript_always_use_jquery" is FALSE: The JavaScript returned by drupal_get_js() when only settings have been added does not include the basePath Drupal setting.');
    $this
      ->assertTrue(strpos($javascript, 'testJavaScriptSetting') === FALSE, 'When "javascript_always_use_jquery" is FALSE: The JavaScript returned by drupal_get_js() when only settings have been added does not include the added Drupal settings.');
    variable_del('javascript_always_use_jquery');

    //
    // When a regular file has been added via drupal_add_js(), drupal_get_js()
    // should return jQuery and other standard scripts and settings.
    advagg_test_reset_statics();
    drupal_add_js('misc/collapse.js');
    $render_array = advagg_get_js();
    $javascript = drupal_render($render_array);
    $this
      ->assertTrue(strpos($javascript, 'misc/jquery.js') !== FALSE, 'Default behavior: The JavaScript returned by drupal_get_js() when a custom JavaScript file has been added includes jquery.js.');
    $this
      ->assertTrue(strpos($javascript, 'misc/drupal.js') !== FALSE, 'Default behavior: The JavaScript returned by drupal_get_js() when a custom JavaScript file has been added includes drupal.js.');
    $this
      ->assertTrue(strpos($javascript, 'Drupal.settings') !== FALSE, 'Default behavior: The JavaScript returned by drupal_get_js() when a custom JavaScript file has been added includes Drupal.settings.');
    $this
      ->assertTrue(strpos($javascript, 'basePath') !== FALSE, 'Default behavior: The JavaScript returned by drupal_get_js() when a custom JavaScript file has been added includes the basePath Drupal setting.');
    $this
      ->assertTrue(strpos($javascript, 'misc/collapse.js') !== FALSE, 'Default behavior: The JavaScript returned by drupal_get_js() when a custom JavaScript file has been added includes the custom file.');

    //
    // When a regular file has been added via drupal_add_js() and the
    // 'javascript_always_use_jquery' variable is set to FALSE, drupal_get_js()
    // should still return jQuery and other standard scripts and settings
    // (since the file is assumed to require jQuery by default).
    advagg_test_reset_statics();
    variable_set('javascript_always_use_jquery', FALSE);
    drupal_add_js('misc/collapse.js');
    $render_array = advagg_get_js();
    $javascript = drupal_render($render_array);
    $this
      ->assertTrue(strpos($javascript, 'misc/jquery.js') !== FALSE, 'When "javascript_always_use_jquery" is FALSE: The JavaScript returned by drupal_get_js() when a custom JavaScript file has been added includes jquery.js.');
    $this
      ->assertTrue(strpos($javascript, 'misc/drupal.js') !== FALSE, 'When "javascript_always_use_jquery" is FALSE: The JavaScript returned by drupal_get_js() when a custom JavaScript file has been added includes drupal.js.');
    $this
      ->assertTrue(strpos($javascript, 'Drupal.settings') !== FALSE, 'When "javascript_always_use_jquery" is FALSE: The JavaScript returned by drupal_get_js() when a custom JavaScript file has been added includes Drupal.settings.');
    $this
      ->assertTrue(strpos($javascript, 'basePath') !== FALSE, 'When "javascript_always_use_jquery" is FALSE: The JavaScript returned by drupal_get_js() when a custom JavaScript file has been added includes the basePath Drupal setting.');
    $this
      ->assertTrue(strpos($javascript, 'misc/collapse.js') !== FALSE, 'When "javascript_always_use_jquery" is FALSE: The JavaScript returned by drupal_get_js() when a custom JavaScript file has been added includes the custom file.');
    variable_del('javascript_always_use_jquery');

    //
    // When a file that does not require jQuery has been added via
    // drupal_add_js(), drupal_get_js() should still return jQuery and other
    // standard scripts and settings by default.
    advagg_test_reset_statics();
    drupal_add_js('misc/collapse.js', array(
      'requires_jquery' => FALSE,
    ));
    $render_array = advagg_get_js();
    $javascript = drupal_render($render_array);
    $this
      ->assertTrue(strpos($javascript, 'misc/jquery.js') !== FALSE, 'Default behavior: The JavaScript returned by drupal_get_js() when a custom JavaScript file that does not require jQuery has been added includes jquery.js.');
    $this
      ->assertTrue(strpos($javascript, 'misc/drupal.js') !== FALSE, 'Default behavior: The JavaScript returned by drupal_get_js() when a custom JavaScript file that does not require jQuery has been added includes drupal.js.');
    $this
      ->assertTrue(strpos($javascript, 'Drupal.settings') !== FALSE, 'Default behavior: The JavaScript returned by drupal_get_js() when a custom JavaScript file that does not require jQuery has been added includes Drupal.settings.');
    $this
      ->assertTrue(strpos($javascript, 'basePath') !== FALSE, 'Default behavior: The JavaScript returned by drupal_get_js() when a custom JavaScript file that does not require jQuery has been added includes the basePath Drupal setting.');
    $this
      ->assertTrue(strpos($javascript, 'misc/collapse.js') !== FALSE, 'Default behavior: The JavaScript returned by drupal_get_js() when a custom JavaScript file that does not require jQuery has been added includes the custom file.');

    //
    // When a file that does not require jQuery has been added via
    // drupal_add_js() and the 'javascript_always_use_jquery' variable is set
    // to FALSE, drupal_get_js() should not return jQuery and other standard
    // scripts and setting, but it should still return the requested file.
    advagg_test_reset_statics();
    variable_set('javascript_always_use_jquery', FALSE);
    drupal_add_js('misc/collapse.js', array(
      'requires_jquery' => FALSE,
    ));
    $render_array = advagg_get_js();
    $javascript = drupal_render($render_array);
    $this
      ->assertTrue(strpos($javascript, 'misc/jquery.js') === FALSE, 'When "javascript_always_use_jquery" is FALSE: The JavaScript returned by drupal_get_js() when a custom JavaScript file that does not require jQuery has been added does not include jquery.js.');
    $this
      ->assertTrue(strpos($javascript, 'misc/drupal.js') === FALSE, 'When "javascript_always_use_jquery" is FALSE: The JavaScript returned by drupal_get_js() when a custom JavaScript file that does not require jQuery has been added does not include drupal.js.');
    $this
      ->assertTrue(strpos($javascript, 'Drupal.settings') === FALSE, 'When "javascript_always_use_jquery" is FALSE: The JavaScript returned by drupal_get_js() when a custom JavaScript file that does not require jQuery has been added does not include Drupal.settings.');
    $this
      ->assertTrue(strpos($javascript, 'basePath') === FALSE, 'When "javascript_always_use_jquery" is FALSE: The JavaScript returned by drupal_get_js() when a custom JavaScript file that does not require jQuery has been added does not include the basePath Drupal setting.');
    $this
      ->assertTrue(strpos($javascript, 'misc/collapse.js') !== FALSE, 'When "javascript_always_use_jquery" is FALSE: The JavaScript returned by drupal_get_js() when a custom JavaScript file that does not require jQuery has been added includes the custom file.');
    variable_del('javascript_always_use_jquery');

    //
    // When 'javascript_always_use_jquery' is set to FALSE and a file that does
    // not require jQuery is added, followed by one that does, drupal_get_js()
    // should return jQuery and other standard scripts and settings, in
    // addition to both of the requested files.
    advagg_test_reset_statics();
    variable_set('javascript_always_use_jquery', FALSE);
    drupal_add_js('misc/collapse.js', array(
      'requires_jquery' => FALSE,
    ));
    drupal_add_js('misc/ajax.js');
    $render_array = advagg_get_js();
    $javascript = drupal_render($render_array);
    $this
      ->assertTrue(strpos($javascript, 'misc/jquery.js') !== FALSE, 'When "javascript_always_use_jquery" is FALSE: The JavaScript returned by drupal_get_js() when at least one custom JavaScript file that requires jQuery has been added includes jquery.js.');
    $this
      ->assertTrue(strpos($javascript, 'misc/drupal.js') !== FALSE, 'When "javascript_always_use_jquery" is FALSE: The JavaScript returned by drupal_get_js() when at least one custom JavaScript file that requires jQuery has been added includes drupal.js.');
    $this
      ->assertTrue(strpos($javascript, 'Drupal.settings') !== FALSE, 'When "javascript_always_use_jquery" is FALSE: The JavaScript returned by drupal_get_js() when at least one custom JavaScript file that requires jQuery has been added includes Drupal.settings.');
    $this
      ->assertTrue(strpos($javascript, 'basePath') !== FALSE, 'When "javascript_always_use_jquery" is FALSE: The JavaScript returned by drupal_get_js() when at least one custom JavaScript file that requires jQuery has been added includes the basePath Drupal setting.');
    $this
      ->assertTrue(strpos($javascript, 'misc/collapse.js') !== FALSE, 'When "javascript_always_use_jquery" is FALSE: The JavaScript returned by drupal_get_js() when at least one custom JavaScript file that requires jQuery has been added includes the first custom file.');
    $this
      ->assertTrue(strpos($javascript, 'misc/ajax.js') !== FALSE, 'When "javascript_always_use_jquery" is FALSE: The JavaScript returned by drupal_get_js() when at least one custom JavaScript file that requires jQuery has been added includes the second custom file.');
    variable_del('javascript_always_use_jquery');

    //
    // Tests JavaScript aggregation when files are added to a different scope.
    advagg_test_reset_statics();

    // Enable JavaScript aggregation.
    variable_set('preprocess_js', 1);

    // Add two JavaScript files to the current request and build the cache.
    drupal_add_js('misc/ajax.js');
    drupal_add_js('misc/autocomplete.js');
    $js_items = drupal_add_js();
    drupal_build_js_cache(array(
      'misc/ajax.js' => $js_items['misc/ajax.js'],
      'misc/autocomplete.js' => $js_items['misc/autocomplete.js'],
    ));

    // Store the expected key for the first item in the cache.
    $cache = array_keys(variable_get('drupal_js_cache_files', array()));
    $expected_key = $cache[0];

    // Reset variables and add a file in a different scope first.
    variable_del('drupal_js_cache_files');
    advagg_test_reset_statics();
    drupal_add_js('some/custom/javascript_file.js', array(
      'scope' => 'footer',
    ));
    drupal_add_js('misc/ajax.js');
    drupal_add_js('misc/autocomplete.js');

    // Rebuild the cache.
    $js_items = drupal_add_js();
    drupal_build_js_cache(array(
      'misc/ajax.js' => $js_items['misc/ajax.js'],
      'misc/autocomplete.js' => $js_items['misc/autocomplete.js'],
    ));

    // Compare the expected key for the first file to the current one.
    $cache = array_keys(variable_get('drupal_js_cache_files', array()));
    $key = $cache[0];
    $this
      ->assertEqual($key, $expected_key, 'JavaScript aggregation is not affected by ordering in different scopes.');
    variable_set('preprocess_js', 0);

    //
    // Test JavaScript ordering.
    advagg_test_reset_statics();

    // Add a bunch of JavaScript in strange ordering.
    drupal_add_js('(function($){alert("Weight 5 #1");})(jQuery);', array(
      'type' => 'inline',
      'scope' => 'footer',
      'weight' => 5,
    ));
    drupal_add_js('(function($){alert("Weight 0 #1");})(jQuery);', array(
      'type' => 'inline',
      'scope' => 'footer',
    ));
    drupal_add_js('(function($){alert("Weight 0 #2");})(jQuery);', array(
      'type' => 'inline',
      'scope' => 'footer',
    ));
    drupal_add_js('(function($){alert("Weight -8 #1");})(jQuery);', array(
      'type' => 'inline',
      'scope' => 'footer',
      'weight' => -8,
    ));
    drupal_add_js('(function($){alert("Weight -8 #2");})(jQuery);', array(
      'type' => 'inline',
      'scope' => 'footer',
      'weight' => -8,
    ));
    drupal_add_js('(function($){alert("Weight -8 #3");})(jQuery);', array(
      'type' => 'inline',
      'scope' => 'footer',
      'weight' => -8,
    ));
    drupal_add_js('http://example.com/example.js?Weight -5 #1', array(
      'type' => 'external',
      'scope' => 'footer',
      'weight' => -5,
    ));
    drupal_add_js('(function($){alert("Weight -8 #4");})(jQuery);', array(
      'type' => 'inline',
      'scope' => 'footer',
      'weight' => -8,
    ));
    drupal_add_js('(function($){alert("Weight 5 #2");})(jQuery);', array(
      'type' => 'inline',
      'scope' => 'footer',
      'weight' => 5,
    ));
    drupal_add_js('(function($){alert("Weight 0 #3");})(jQuery);', array(
      'type' => 'inline',
      'scope' => 'footer',
    ));

    // Construct the expected result from the regex.
    $expected = array(
      "-8 #1",
      "-8 #2",
      "-8 #3",
      "-8 #4",
      // -5 #1: The external script.
      "-5 #1",
      "0 #1",
      "0 #2",
      "0 #3",
      "5 #1",
      "5 #2",
    );

    // Retrieve the rendered JavaScript and test against the regex.
    $render_array = advagg_get_js('footer');
    $js = drupal_render($render_array);
    $matches = array();
    if (preg_match_all('/Weight\\s([-0-9]+\\s[#0-9]+)/', $js, $matches)) {
      $result = $matches[1];
    }
    else {
      $result = array();
    }
    $this
      ->assertIdentical($result, $expected, 'JavaScript is added in the expected weight order.');

    //
    // Test default JavaScript is empty.
    advagg_test_reset_statics();
    $this
      ->assertEqual(array(), drupal_add_js(), 'Default JavaScript is empty.');

    //
    // Test drupal_get_js() for JavaScript settings.
    advagg_test_reset_statics();

    // Only the second of these two entries should appear in Drupal.settings.
    drupal_add_js(array(
      'commonTest' => 'commonTestShouldNotAppear',
    ), 'setting');
    drupal_add_js(array(
      'commonTest' => 'commonTestShouldAppear',
    ), 'setting');

    // All three of these entries should appear in Drupal.settings.
    drupal_add_js(array(
      'commonTestArray' => array(
        'commonTestValue0',
      ),
    ), 'setting');
    drupal_add_js(array(
      'commonTestArray' => array(
        'commonTestValue1',
      ),
    ), 'setting');
    drupal_add_js(array(
      'commonTestArray' => array(
        'commonTestValue2',
      ),
    ), 'setting');

    // Only the second of these two entries should appear in Drupal.settings.
    drupal_add_js(array(
      'commonTestArray' => array(
        'key' => 'commonTestOldValue',
      ),
    ), 'setting');
    drupal_add_js(array(
      'commonTestArray' => array(
        'key' => 'commonTestNewValue',
      ),
    ), 'setting');
    $render_array = advagg_get_js('header');
    $javascript = drupal_render($render_array);
    $this
      ->assertTrue(strpos($javascript, 'basePath') > 0, 'Rendered JavaScript header returns basePath setting.');
    $this
      ->assertTrue(strpos($javascript, 'misc/jquery.js') > 0, 'Rendered JavaScript header includes jQuery.');
    $this
      ->assertTrue(strpos($javascript, 'pathPrefix') > 0, 'Rendered JavaScript header returns pathPrefix setting.');

    // Test whether drupal_add_js can be used to override a previous setting.
    $this
      ->assertTrue(strpos($javascript, 'commonTestShouldAppear') > 0, 'Rendered JavaScript header returns custom setting.');
    $this
      ->assertTrue(strpos($javascript, 'commonTestShouldNotAppear') === FALSE, 'drupal_add_js() correctly overrides a custom setting.');

    // Test whether drupal_add_js can be used to add numerically indexed values
    // to an array.
    $array_values_appear = strpos($javascript, 'commonTestValue0') > 0 && strpos($javascript, 'commonTestValue1') > 0 && strpos($javascript, 'commonTestValue2') > 0;
    $this
      ->assertTrue($array_values_appear, 'drupal_add_js() correctly adds settings to the end of an indexed array.');

    // Test whether drupal_add_js can be used to override the entry for an
    // existing key in an associative array.
    $associative_array_override = strpos($javascript, 'commonTestNewValue') > 0 && strpos($javascript, 'commonTestOldValue') === FALSE;
    $this
      ->assertTrue($associative_array_override, 'drupal_add_js() correctly overrides settings within an associative array.');

    //
    // Test rendering an external JavaScript file.
    advagg_test_reset_statics();
    $GLOBALS['conf']['advagg_convert_absolute_to_relative_path'] = FALSE;
    $GLOBALS['conf']['advagg_convert_absolute_to_protocol_relative_path'] = FALSE;
    $GLOBALS['conf']['advagg_force_https_path'] = FALSE;
    $external = 'http://example.com/example.js';
    drupal_add_js($external, 'external');
    $render_array = advagg_get_js();
    $javascript = drupal_render($render_array);

    // Local files have a base_path() prefix, external files should not.
    $this
      ->assertTrue(strpos($javascript, 'src="' . $external) > 0, 'Rendering an external JavaScript file.');

    //
    // Test drupal_get_js() with a footer scope.
    advagg_test_reset_statics();
    $inline = 'jQuery(function () { });';
    drupal_add_js($inline, array(
      'type' => 'inline',
      'scope' => 'footer',
    ));
    $render_array = advagg_get_js('footer');
    $javascript = drupal_render($render_array);
    $this
      ->assertTrue(strpos($javascript, $inline) > 0, 'Rendered JavaScript footer returns the inline code.');

    //
    // Ensures that vertical-tabs.js is included before collapse.js.
    advagg_test_reset_statics();
    $this
      ->drupalGet('form_test/vertical-tabs');
    $position1 = strpos($this->content, 'misc/vertical-tabs.js');
    $position2 = strpos($this->content, 'misc/collapse.js');
    $this
      ->assertTrue($position1 !== FALSE && $position2 !== FALSE && $position1 < $position2, 'vertical-tabs.js is included before collapse.js');

    //
    // Test rendering the JavaScript with a file's weight above jQuery's.
    advagg_test_reset_statics();

    // JavaScript files are sorted first by group, then by the 'every_page'
    // flag, then by weight (see drupal_sort_css_js()), so to test the effect of
    // weight, we need the other two options to be the same.
    drupal_add_js('misc/collapse.js', array(
      'group' => JS_LIBRARY,
      'every_page' => TRUE,
      'weight' => -21,
    ));
    $render_array = advagg_get_js();
    $javascript = drupal_render($render_array);
    $this
      ->assertTrue(strpos($javascript, 'misc/collapse.js') < strpos($javascript, 'misc/jquery.js'), 'Rendering a JavaScript file above jQuery.');

    //
    // Test altering a JavaScript's weight via hook_js_alter().
    advagg_test_reset_statics();

    // Add both tableselect.js and simpletest.js, with a larger weight on
    // SimpleTest.
    drupal_add_js('misc/tableselect.js');
    drupal_add_js(drupal_get_path('module', 'simpletest') . '/simpletest.js', array(
      'weight' => 9999,
    ));

    // Render the JavaScript, testing if simpletest.js was altered to be before
    // tableselect.js. See simpletest_js_alter() to see where this alteration
    // takes place.
    $render_array = advagg_get_js();
    $javascript = drupal_render($render_array);
    $this
      ->assertTrue(strpos($javascript, 'simpletest.js') < strpos($javascript, 'misc/tableselect.js'), 'Altering JavaScript weight through the alter hook.');

    //
    // Adds a library to the page and tests for both its JavaScript and its CSS.
    advagg_test_reset_statics();
    $result = drupal_add_library('system', 'farbtastic');
    $this
      ->assertTrue($result !== FALSE, 'Library was added without errors.');
    $render_array = advagg_get_js();
    $scripts = drupal_render($render_array);
    $render_array = advagg_get_css();
    $styles = drupal_render($render_array);
    $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.');

    //
    // Adds a JavaScript library to the page and alters it.
    advagg_test_reset_statics();

    // Verify that common_test altered the title of Farbtastic.
    $library = drupal_get_library('system', 'farbtastic');
    $this
      ->assertEqual($library['title'], 'Farbtastic: Altered Library', 'Registered libraries were altered.');

    // common_test_library_alter() also added a dependency on jQuery Form.
    drupal_add_library('system', 'farbtastic');
    $render_array = advagg_get_js();
    $scripts = drupal_render($render_array);
    $this
      ->assertTrue(strpos($scripts, 'misc/jquery.form.js'), 'Altered library dependencies are added to the page.');

    //
    // Tests non-existing libraries.
    advagg_test_reset_statics();
    $result = drupal_get_library('unknown', 'unknown');
    $this
      ->assertFalse($result, 'Unknown library returned FALSE.');
    advagg_test_reset_statics();
    $result = drupal_add_library('unknown', 'unknown');
    $this
      ->assertFalse($result, 'Unknown library returned FALSE.');
    $render_array = advagg_get_js();
    $scripts = drupal_render($render_array);
    $this
      ->assertTrue(strpos($scripts, 'unknown') === FALSE, 'Unknown library was not added to the page.');

    //
    // Tests the addition of libraries through the #attached['library']
    // property.
    advagg_test_reset_statics();
    $element['#attached']['library'][] = array(
      'system',
      'farbtastic',
    );
    drupal_render($element);
    $render_array = advagg_get_js();
    $scripts = drupal_render($render_array);
    $this
      ->assertTrue(strpos($scripts, 'misc/farbtastic/farbtastic.js'), 'The attached_library property adds the additional libraries.');

    //
    // Test #attached functionality in children elements.
    advagg_test_reset_statics();

    // The cache system is turned off for POST requests.
    $request_method = $_SERVER['REQUEST_METHOD'];
    $_SERVER['REQUEST_METHOD'] = 'GET';

    // Create an element with a child and subchild.  Each element loads a
    // different JavaScript file using #attached.
    $parent_js = drupal_get_path('module', 'user') . '/user.js';
    $child_js = drupal_get_path('module', 'color') . '/color.js';
    $subchild_js = drupal_get_path('module', 'book') . '/book.js';
    $element = array(
      '#type' => 'fieldset',
      '#cache' => array(
        'keys' => array(
          'simpletest',
          'drupal_render',
          'children_attached',
        ),
      ),
      '#attached' => array(
        'js' => array(
          $parent_js,
        ),
      ),
      '#title' => 'Parent',
    );
    $element['child'] = array(
      '#type' => 'fieldset',
      '#attached' => array(
        'js' => array(
          $child_js,
        ),
      ),
      '#title' => 'Child',
    );
    $element['child']['subchild'] = array(
      '#attached' => array(
        'js' => array(
          $subchild_js,
        ),
      ),
      '#markup' => 'Subchild',
    );

    // Render the element and verify the presence of #attached JavaScript.
    drupal_render($element);
    $render_array = advagg_get_js();
    $scripts = drupal_render($render_array);
    $this
      ->assertTrue(strpos($scripts, $parent_js), 'The element #attached JavaScript was included.');
    $this
      ->assertTrue(strpos($scripts, $child_js), 'The child #attached JavaScript was included.');
    $this
      ->assertTrue(strpos($scripts, $subchild_js), 'The subchild #attached JavaScript was included.');

    // Load the element from cache and verify the presence of the #attached
    // JavaScript.
    advagg_test_reset_statics();
    $this
      ->assertTrue(drupal_render_cache_get($element), 'The element was retrieved from cache.');
    $render_array = advagg_get_js();
    $scripts = drupal_render($render_array);
    $this
      ->assertTrue(strpos($scripts, $parent_js), 'The element #attached JavaScript was included when loading from cache.');
    $this
      ->assertTrue(strpos($scripts, $child_js), 'The child #attached JavaScript was included when loading from cache.');
    $this
      ->assertTrue(strpos($scripts, $subchild_js), 'The subchild #attached JavaScript was included when loading from cache.');
    $_SERVER['REQUEST_METHOD'] = $request_method;

    //
    // Tests the localisation of JavaScript libraries. Verifies that the
    // datepicker can be localized.
    advagg_test_reset_statics();
    drupal_add_library('system', 'ui.datepicker');
    $GLOBALS['conf']['advagg_mod_js_footer'] = 0;
    $render_array = advagg_get_js();
    $javascript = drupal_render($render_array);
    $this
      ->assertTrue(strpos($javascript, 'locale.datepicker.js'), 'locale.datepicker.js added to scripts.');

    //
    // Functional tests for JavaScript parsing for translatable strings.
    // Tests parsing js files for translatable strings.
    advagg_test_reset_statics();
    $filename = drupal_get_path('module', 'locale_test') . '/locale_test.js';

    // Parse the file to look for source strings.
    _locale_parse_js_file($filename);

    // Get all of the source strings that were found.
    $source_strings = db_select('locales_source', 's')
      ->fields('s', array(
      'source',
      'context',
    ))
      ->condition('s.location', $filename)
      ->execute()
      ->fetchAllKeyed();

    // List of all strings that should be in the file.
    $test_strings = array(
      "Standard Call t" => '',
      "Whitespace Call t" => '',
      "Single Quote t" => '',
      "Single Quote \\'Escaped\\' t" => '',
      "Single Quote Concat strings t" => '',
      "Double Quote t" => '',
      "Double Quote \\\"Escaped\\\" t" => '',
      "Double Quote Concat strings t" => '',
      "Context !key Args t" => "Context string",
      "Context Unquoted t" => "Context string unquoted",
      "Context Single Quoted t" => "Context string single quoted",
      "Context Double Quoted t" => "Context string double quoted",
      "Standard Call plural" => '',
      "Standard Call @count plural" => '',
      "Whitespace Call plural" => '',
      "Whitespace Call @count plural" => '',
      "Single Quote plural" => '',
      "Single Quote @count plural" => '',
      "Single Quote \\'Escaped\\' plural" => '',
      "Single Quote \\'Escaped\\' @count plural" => '',
      "Double Quote plural" => '',
      "Double Quote @count plural" => '',
      "Double Quote \\\"Escaped\\\" plural" => '',
      "Double Quote \\\"Escaped\\\" @count plural" => '',
      "Context !key Args plural" => "Context string",
      "Context !key Args @count plural" => "Context string",
      "Context Unquoted plural" => "Context string unquoted",
      "Context Unquoted @count plural" => "Context string unquoted",
      "Context Single Quoted plural" => "Context string single quoted",
      "Context Single Quoted @count plural" => "Context string single quoted",
      "Context Double Quoted plural" => "Context string double quoted",
      "Context Double Quoted @count plural" => "Context string double quoted",
    );

    // Assert that all strings were found properly.
    foreach ($test_strings as $str => $context) {
      $args = array(
        '%source' => $str,
        '%context' => $context,
      );

      // Make sure that the string was found in the file.
      $this
        ->assertTrue(isset($source_strings[$str]), format_string('Found source string: %source', $args));

      // Make sure that the proper context was matched.
      $this
        ->assertTrue(isset($source_strings[$str]) && $source_strings[$str] === $context, strlen($context) > 0 ? format_string('Context for %source is %context', $args) : format_string('Context for %source is blank', $args));
    }
    $this
      ->assertEqual(count($source_strings), count($test_strings), 'Found correct number of source strings.');

    //
    // Adds a language and checks that the JavaScript translation files are
    // properly created and rebuilt on deletion.
    $user = $this
      ->drupalCreateUser(array(
      'translate interface',
      'administer languages',
      'access administration pages',
    ));
    $this
      ->drupalLogin($user);
    $langcode = 'xx';

    // The English name for the language. This will be translated.
    $name = $this
      ->randomName(16);

    // The native name for the language.
    $native = $this
      ->randomName(16);

    // The domain prefix.
    $prefix = $langcode;

    // Add custom language.
    $edit = array(
      'langcode' => $langcode,
      'name' => $name,
      'native' => $native,
      'prefix' => $prefix,
      'direction' => '0',
    );
    $this
      ->drupalPost('admin/config/regional/language/add', $edit, t('Add custom language'));
    drupal_static_reset('language_list');

    // Build the JavaScript translation file.
    $this
      ->drupalGet('admin/config/regional/translate/translate');

    // Retrieve the id of the first string available in the {locales_source}
    // table and translate it.
    $query = db_select('locales_source', 'l');
    $query
      ->addExpression('min(l.lid)', 'lid');
    $result = $query
      ->condition('l.location', '%.js%', 'LIKE')
      ->condition('l.textgroup', 'default')
      ->execute();
    $url = 'admin/config/regional/translate/edit/' . $result
      ->fetchObject()->lid;
    $edit = array(
      'translations[' . $langcode . ']' => $this
        ->randomName(),
    );
    $this
      ->drupalPost($url, $edit, t('Save translations'));

    // Trigger JavaScript translation parsing and building.
    require_once DRUPAL_ROOT . '/includes/locale.inc';
    _locale_rebuild_js($langcode);

    // Retrieve the JavaScript translation hash code for the custom language to
    // check that the translation file has been properly built.
    $file = db_select('languages', 'l')
      ->fields('l', array(
      'javascript',
    ))
      ->condition('language', $langcode)
      ->execute()
      ->fetchObject();
    $js_file = 'public://' . variable_get('locale_js_directory', 'languages') . '/' . $langcode . '_' . $file->javascript . '.js';
    $this
      ->assertTrue($result = file_exists($js_file), format_string('JavaScript file created: %file', array(
      '%file' => $result ? $js_file : 'not found',
    )));

    // Test JavaScript translation rebuilding.
    file_unmanaged_delete($js_file);
    $this
      ->assertTrue($result = !file_exists($js_file), format_string('JavaScript file deleted: %file', array(
      '%file' => $result ? $js_file : 'found',
    )));
    cache_clear_all();
    _locale_rebuild_js($langcode);
    $this
      ->assertTrue($result = file_exists($js_file), format_string('JavaScript file rebuilt: %file', array(
      '%file' => $result ? $js_file : 'not found',
    )));
  }

}

Members

Namesort descending Modifiers Type Description Overrides
AdvAggJavaScriptTestCase::$preprocessJs protected property Store configured value for JavaScript preprocessing.
AdvAggJavaScriptTestCase::getInfo public static function Provide information to the UI for this test.
AdvAggJavaScriptTestCase::setUp public function Install the advagg module and include needed files. Overrides DrupalWebTestCase::setUp
AdvAggJavaScriptTestCase::tearDown public function Restore any variables we set. Overrides DrupalWebTestCase::tearDown
AdvAggJavaScriptTestCase::testJavaScriptAlwaysUsejQuery public function Test the 'javascript_always_use_jquery' variable.
DrupalTestCase::$assertions protected property Assertions thrown in that test case.
DrupalTestCase::$databasePrefix protected property The database prefix of this test run.
DrupalTestCase::$originalFileDirectory protected property The original file directory, before it was changed for testing purposes.
DrupalTestCase::$results public property Current results of this test case.
DrupalTestCase::$setup protected property Flag to indicate whether the test has been set up.
DrupalTestCase::$setupDatabasePrefix protected property
DrupalTestCase::$setupEnvironment protected property
DrupalTestCase::$skipClasses protected property This class is skipped when looking for the source of an assertion.
DrupalTestCase::$testId protected property The test run ID.
DrupalTestCase::$timeLimit protected property Time limit for the test.
DrupalTestCase::$useSetupInstallationCache public property Whether to cache the installation part of the setUp() method.
DrupalTestCase::$useSetupModulesCache public property Whether to cache the modules installation part of the setUp() method.
DrupalTestCase::$verboseDirectoryUrl protected property URL to the verbose output file directory.
DrupalTestCase::assert protected function Internal helper: stores the assert.
DrupalTestCase::assertEqual protected function Check to see if two values are equal.
DrupalTestCase::assertFalse protected function Check to see if a value is false (an empty string, 0, NULL, or FALSE).
DrupalTestCase::assertIdentical protected function Check to see if two values are identical.
DrupalTestCase::assertNotEqual protected function Check to see if two values are not equal.
DrupalTestCase::assertNotIdentical protected function Check to see if two values are not identical.
DrupalTestCase::assertNotNull protected function Check to see if a value is not NULL.
DrupalTestCase::assertNull protected function Check to see if a value is NULL.
DrupalTestCase::assertTrue protected function Check to see if a value is not false (not an empty string, 0, NULL, or FALSE).
DrupalTestCase::deleteAssert public static function Delete an assertion record by message ID.
DrupalTestCase::error protected function Fire an error assertion. 1
DrupalTestCase::errorHandler public function Handle errors during test runs. 1
DrupalTestCase::exceptionHandler protected function Handle exceptions.
DrupalTestCase::fail protected function Fire an assertion that is always negative.
DrupalTestCase::generatePermutations public static function Converts a list of possible parameters into a stack of permutations.
DrupalTestCase::getAssertionCall protected function Cycles through backtrace until the first non-assertion method is found.
DrupalTestCase::getDatabaseConnection public static function Returns the database connection to the site running Simpletest.
DrupalTestCase::insertAssert public static function Store an assertion from outside the testing context.
DrupalTestCase::pass protected function Fire an assertion that is always positive.
DrupalTestCase::randomName public static function Generates a random string containing letters and numbers.
DrupalTestCase::randomString public static function Generates a random string of ASCII characters of codes 32 to 126.
DrupalTestCase::run public function Run all tests in this class.
DrupalTestCase::verbose protected function Logs a verbose message in a text file.
DrupalWebTestCase::$additionalCurlOptions protected property Additional cURL options.
DrupalWebTestCase::$content protected property The content of the page currently loaded in the internal browser.
DrupalWebTestCase::$cookieFile protected property The current cookie file used by cURL.
DrupalWebTestCase::$cookies protected property The cookies of the page currently loaded in the internal browser.
DrupalWebTestCase::$curlHandle protected property The handle of the current cURL connection.
DrupalWebTestCase::$drupalSettings protected property The value of the Drupal.settings JavaScript variable for the page currently loaded in the internal browser.
DrupalWebTestCase::$elements protected property The parsed version of the page.
DrupalWebTestCase::$generatedTestFiles protected property Whether the files were copied to the test files directory.
DrupalWebTestCase::$headers protected property The headers of the page currently loaded in the internal browser.
DrupalWebTestCase::$httpauth_credentials protected property HTTP authentication credentials (<username>:<password>).
DrupalWebTestCase::$httpauth_method protected property HTTP authentication method
DrupalWebTestCase::$loggedInUser protected property The current user logged in using the internal browser.
DrupalWebTestCase::$originalShutdownCallbacks protected property The original shutdown handlers array, before it was cleaned for testing purposes.
DrupalWebTestCase::$originalUser protected property The original user, before it was changed to a clean uid = 1 for testing purposes.
DrupalWebTestCase::$plainTextContent protected property The content of the page currently loaded in the internal browser (plain text version).
DrupalWebTestCase::$profile protected property The profile to install as a basis for testing. 20
DrupalWebTestCase::$redirect_count protected property The number of redirects followed during the handling of a request.
DrupalWebTestCase::$session_id protected property The current session ID, if available.
DrupalWebTestCase::$session_name protected property The current session name, if available.
DrupalWebTestCase::$url protected property The URL currently loaded in the internal browser.
DrupalWebTestCase::assertField protected function Asserts that a field exists with the given name or ID.
DrupalWebTestCase::assertFieldById protected function Asserts that a field exists in the current page with the given ID and value.
DrupalWebTestCase::assertFieldByName protected function Asserts that a field exists in the current page with the given name and value.
DrupalWebTestCase::assertFieldByXPath protected function Asserts that a field exists in the current page by the given XPath.
DrupalWebTestCase::assertFieldChecked protected function Asserts that a checkbox field in the current page is checked.
DrupalWebTestCase::assertLink protected function Pass if a link with the specified label is found, and optional with the specified index.
DrupalWebTestCase::assertLinkByHref protected function Pass if a link containing a given href (part) is found.
DrupalWebTestCase::assertMail protected function Asserts that the most recently sent e-mail message has the given value.
DrupalWebTestCase::assertMailPattern protected function Asserts that the most recently sent e-mail message has the pattern in it.
DrupalWebTestCase::assertMailString protected function Asserts that the most recently sent e-mail message has the string in it.
DrupalWebTestCase::assertNoDuplicateIds protected function Asserts that each HTML ID is used for just a single element.
DrupalWebTestCase::assertNoField protected function Asserts that a field does not exist with the given name or ID.
DrupalWebTestCase::assertNoFieldById protected function Asserts that a field does not exist with the given ID and value.
DrupalWebTestCase::assertNoFieldByName protected function Asserts that a field does not exist with the given name and value.
DrupalWebTestCase::assertNoFieldByXPath protected function Asserts that a field doesn't exist or its value doesn't match, by XPath.
DrupalWebTestCase::assertNoFieldChecked protected function Asserts that a checkbox field in the current page is not checked.
DrupalWebTestCase::assertNoLink protected function Pass if a link with the specified label is not found.
DrupalWebTestCase::assertNoLinkByHref protected function Pass if a link containing a given href (part) is not found.
DrupalWebTestCase::assertNoOptionSelected protected function Asserts that a select option in the current page is not checked.
DrupalWebTestCase::assertNoPattern protected function Will trigger a pass if the perl regex pattern is not present in raw content.
DrupalWebTestCase::assertNoRaw protected function Pass if the raw text is NOT found on the loaded page, fail otherwise. Raw text refers to the raw HTML that the page generated.
DrupalWebTestCase::assertNoResponse protected function Asserts the page did not return the specified response code.
DrupalWebTestCase::assertNoText protected function Pass if the text is NOT found on the text version of the page. The text version is the equivalent of what a user would see when viewing through a web browser. In other words the HTML has been filtered out of the contents.
DrupalWebTestCase::assertNoTitle protected function Pass if the page title is not the given string.
DrupalWebTestCase::assertNoUniqueText protected function Pass if the text is found MORE THAN ONCE on the text version of the page.
DrupalWebTestCase::assertOptionSelected protected function Asserts that a select option in the current page is checked.
DrupalWebTestCase::assertPattern protected function Will trigger a pass if the Perl regex pattern is found in the raw content.
DrupalWebTestCase::assertRaw protected function Pass if the raw text IS found on the loaded page, fail otherwise. Raw text refers to the raw HTML that the page generated.
DrupalWebTestCase::assertResponse protected function Asserts the page responds with the specified response code.
DrupalWebTestCase::assertText protected function Pass if the text IS found on the text version of the page. The text version is the equivalent of what a user would see when viewing through a web browser. In other words the HTML has been filtered out of the contents.
DrupalWebTestCase::assertTextHelper protected function Helper for assertText and assertNoText.
DrupalWebTestCase::assertThemeOutput protected function Asserts themed output.
DrupalWebTestCase::assertTitle protected function Pass if the page title is the given string.
DrupalWebTestCase::assertUniqueText protected function Pass if the text is found ONLY ONCE on the text version of the page.
DrupalWebTestCase::assertUniqueTextHelper protected function Helper for assertUniqueText and assertNoUniqueText.
DrupalWebTestCase::assertUrl protected function Pass if the internal browser's URL matches the given path.
DrupalWebTestCase::buildXPathQuery protected function Builds an XPath query.
DrupalWebTestCase::changeDatabasePrefix protected function Changes the database connection to the prefixed one.
DrupalWebTestCase::checkForMetaRefresh protected function Check for meta refresh tag and if found call drupalGet() recursively. This function looks for the http-equiv attribute to be set to "Refresh" and is case-sensitive.
DrupalWebTestCase::checkPermissions protected function Check to make sure that the array of permissions are valid.
DrupalWebTestCase::clickLink protected function Follows a link by name.
DrupalWebTestCase::constructFieldXpath protected function Helper function: construct an XPath for the given set of attributes and value.
DrupalWebTestCase::copySetupCache protected function Copy the setup cache from/to another table and files directory.
DrupalWebTestCase::cronRun protected function Runs cron in the Drupal installed by Simpletest.
DrupalWebTestCase::curlClose protected function Close the cURL handler and unset the handler.
DrupalWebTestCase::curlExec protected function Initializes and executes a cURL request.
DrupalWebTestCase::curlHeaderCallback protected function Reads headers and registers errors received from the tested site.
DrupalWebTestCase::curlInitialize protected function Initializes the cURL connection.
DrupalWebTestCase::drupalCompareFiles protected function Compare two files based on size and file name.
DrupalWebTestCase::drupalCreateContentType protected function Creates a custom content type based on default settings.
DrupalWebTestCase::drupalCreateNode protected function Creates a node based on default settings.
DrupalWebTestCase::drupalCreateRole protected function Creates a role with specified permissions.
DrupalWebTestCase::drupalCreateUser protected function Create a user with a given set of permissions.
DrupalWebTestCase::drupalGet protected function Retrieves a Drupal path or an absolute path.
DrupalWebTestCase::drupalGetAJAX protected function Retrieve a Drupal path or an absolute path and JSON decode the result.
DrupalWebTestCase::drupalGetContent protected function Gets the current raw HTML of requested page.
DrupalWebTestCase::drupalGetHeader protected function Gets the value of an HTTP response header. If multiple requests were required to retrieve the page, only the headers from the last request will be checked by default. However, if TRUE is passed as the second argument, all requests will be processed…
DrupalWebTestCase::drupalGetHeaders protected function Gets the HTTP response headers of the requested page. Normally we are only interested in the headers returned by the last request. However, if a page is redirected or HTTP authentication is in use, multiple requests will be required to retrieve the…
DrupalWebTestCase::drupalGetMails protected function Gets an array containing all e-mails sent during this test case.
DrupalWebTestCase::drupalGetNodeByTitle function Get a node from the database based on its title.
DrupalWebTestCase::drupalGetSettings protected function Gets the value of the Drupal.settings JavaScript variable for the currently loaded page.
DrupalWebTestCase::drupalGetTestFiles protected function Get a list files that can be used in tests.
DrupalWebTestCase::drupalGetToken protected function Generate a token for the currently logged in user.
DrupalWebTestCase::drupalHead protected function Retrieves only the headers for a Drupal path or an absolute path.
DrupalWebTestCase::drupalLogin protected function Log in a user with the internal browser.
DrupalWebTestCase::drupalLogout protected function
DrupalWebTestCase::drupalPost protected function Execute a POST request on a Drupal page. It will be done as usual POST request with SimpleBrowser.
DrupalWebTestCase::drupalPostAJAX protected function Execute an Ajax submission.
DrupalWebTestCase::drupalSetContent protected function 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.
DrupalWebTestCase::drupalSetSettings protected function Sets the value of the Drupal.settings JavaScript variable for the currently loaded page.
DrupalWebTestCase::getAbsoluteUrl protected function Takes a path and returns an absolute path.
DrupalWebTestCase::getAllOptions protected function Get all option elements, including nested options, in a select.
DrupalWebTestCase::getSelectedItem protected function Get the selected value from a select field.
DrupalWebTestCase::getSetupCacheKey protected function Returns the cache key used for the setup caching.
DrupalWebTestCase::getUrl protected function Get the current URL from the cURL handler.
DrupalWebTestCase::handleForm protected function Handle form input related to drupalPost(). Ensure that the specified fields exist and attempt to create POST data in the correct manner for the particular field type.
DrupalWebTestCase::loadSetupCache protected function Copies the cached tables and files for a cached installation setup.
DrupalWebTestCase::parse protected function Parse content returned from curlExec using DOM and SimpleXML.
DrupalWebTestCase::preloadRegistry protected function Preload the registry from the testing site.
DrupalWebTestCase::prepareDatabasePrefix protected function Generates a database prefix for running tests.
DrupalWebTestCase::prepareEnvironment protected function Prepares the current environment for running the test.
DrupalWebTestCase::recursiveDirectoryCopy protected function Recursively copy one directory to another.
DrupalWebTestCase::refreshVariables protected function Refresh the in-memory set of variables. Useful after a page request is made that changes a variable in a different thread. 1
DrupalWebTestCase::resetAll protected function Reset all data structures after having enabled new modules.
DrupalWebTestCase::storeSetupCache protected function Store the installation setup to a cache.
DrupalWebTestCase::verboseEmail protected function Outputs to verbose the most recent $count emails sent.
DrupalWebTestCase::xpath protected function Perform an xpath search on the contents of the internal browser. The search is relative to the root element (HTML tag normally) of the page.
DrupalWebTestCase::__construct function Constructor for DrupalWebTestCase. Overrides DrupalTestCase::__construct 1