Tests adding JavaScript files with additional attributes.
function testAttributes() {
$default_query_string = variable_get('css_js_query_string', '0');
drupal_add_library('system', 'drupal');
drupal_add_js('http://example.com/script.js', array(
'attributes' => array(
'defer' => 'defer',
),
));
drupal_add_js('core/misc/collapse.js', array(
'attributes' => array(
'defer' => 'defer',
),
));
$javascript = drupal_get_js();
$expected_1 = '<script src="http://example.com/script.js?' . $default_query_string . '" defer="defer"></script>';
$expected_2 = '<script src="' . file_create_url('core/misc/collapse.js') . '?' . $default_query_string . '" defer="defer"></script>';
$this
->assertTrue(strpos($javascript, $expected_1) > 0, 'Rendered external JavaScript with correct defer attribute.');
$this
->assertTrue(strpos($javascript, $expected_2) > 0, 'Rendered internal JavaScript with correct defer attribute.');
}