summaryrefslogtreecommitdiffstats
path: root/core/modules/system/lib/Drupal/system/Tests
diff options
context:
space:
mode:
Diffstat (limited to 'core/modules/system/lib/Drupal/system/Tests')
-rw-r--r--core/modules/system/lib/Drupal/system/Tests/Ajax/FrameworkTest.php18
-rw-r--r--core/modules/system/lib/Drupal/system/Tests/Common/CascadingStylesheetsTest.php40
-rw-r--r--core/modules/system/lib/Drupal/system/Tests/Common/JavaScriptTest.php152
-rw-r--r--core/modules/system/lib/Drupal/system/Tests/Common/RenderTest.php26
-rw-r--r--core/modules/system/lib/Drupal/system/Tests/Theme/TableTest.php8
5 files changed, 122 insertions, 122 deletions
diff --git a/core/modules/system/lib/Drupal/system/Tests/Ajax/FrameworkTest.php b/core/modules/system/lib/Drupal/system/Tests/Ajax/FrameworkTest.php
index eced538..b70a1e6 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Ajax/FrameworkTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Ajax/FrameworkTest.php
@@ -31,10 +31,10 @@ class FrameworkTest extends AjaxTestBase {
*/
public function testAJAXRender() {
// Verify that settings command is generated when JavaScript settings are
- // set via drupal_add_js().
+ // set via _drupal_add_js().
$commands = $this->drupalGetAJAX('ajax-test/render');
$expected = new SettingsCommand(array('ajax' => 'test'), TRUE);
- $this->assertCommand($commands, $expected->render(), 'ajax_render() loads settings added with drupal_add_js().');
+ $this->assertCommand($commands, $expected->render(), 'ajax_render() loads settings added with _drupal_add_js().');
}
/**
@@ -46,7 +46,7 @@ class FrameworkTest extends AjaxTestBase {
// Expected commands, in a very specific order.
$expected_commands[0] = new SettingsCommand(array('ajax' => 'test'), TRUE);
- drupal_static_reset('drupal_add_css');
+ drupal_static_reset('_drupal_add_css');
$attached = array(
'#attached' => array(
'css' => array(
@@ -56,8 +56,8 @@ class FrameworkTest extends AjaxTestBase {
),
);
drupal_render($attached);
- $expected_commands[1] = new AddCssCommand(drupal_get_css(drupal_add_css(), TRUE));
- drupal_static_reset('drupal_add_js');
+ $expected_commands[1] = new AddCssCommand(drupal_get_css(_drupal_add_css(), TRUE));
+ drupal_static_reset('_drupal_add_js');
$attached = array(
'#attached' => array(
'js' => array(
@@ -66,8 +66,8 @@ class FrameworkTest extends AjaxTestBase {
),
);
drupal_render($attached);
- $expected_commands[2] = new PrependCommand('head', drupal_get_js('header', drupal_add_js(), TRUE));
- drupal_static_reset('drupal_add_js');
+ $expected_commands[2] = new PrependCommand('head', drupal_get_js('header', _drupal_add_js(), TRUE));
+ drupal_static_reset('_drupal_add_js');
$attached = array(
'#attached' => array(
'js' => array(
@@ -76,7 +76,7 @@ class FrameworkTest extends AjaxTestBase {
),
);
drupal_render($attached);
- $expected_commands[3] = new AppendCommand('body', drupal_get_js('footer', drupal_add_js(), TRUE));
+ $expected_commands[3] = new AppendCommand('body', drupal_get_js('footer', _drupal_add_js(), TRUE));
$expected_commands[4] = new HtmlCommand('body', 'Hello, world!');
// Load any page with at least one CSS file, at least one JavaScript file
@@ -123,7 +123,7 @@ class FrameworkTest extends AjaxTestBase {
'css' => drupal_get_path('module', 'system') . '/css/system.admin.css',
'js' => drupal_get_path('module', 'system') . '/system.js',
);
- // CSS files are stored by basename, see drupal_add_css().
+ // CSS files are stored by basename, see _drupal_add_css().
$expected_css_basename = drupal_basename($expected['css']);
// @todo D8: Add a drupal_css_defaults() helper function.
diff --git a/core/modules/system/lib/Drupal/system/Tests/Common/CascadingStylesheetsTest.php b/core/modules/system/lib/Drupal/system/Tests/Common/CascadingStylesheetsTest.php
index 052ea57..5c016ce 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Common/CascadingStylesheetsTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Common/CascadingStylesheetsTest.php
@@ -32,15 +32,15 @@ class CascadingStylesheetsTest extends DrupalUnitTestBase {
function setUp() {
parent::setUp();
- // Reset drupal_add_css() before each test.
- drupal_static_reset('drupal_add_css');
+ // Reset _drupal_add_css() before each test.
+ drupal_static_reset('_drupal_add_css');
}
/**
* Checks that default stylesheets are empty.
*/
function testDefault() {
- $this->assertEqual(array(), drupal_add_css(), 'Default CSS is empty.');
+ $this->assertEqual(array(), _drupal_add_css(), 'Default CSS is empty.');
}
/**
@@ -48,7 +48,7 @@ class CascadingStylesheetsTest extends DrupalUnitTestBase {
*/
function testAddFile() {
$path = drupal_get_path('module', 'simpletest') . '/css/simpletest.module.css';
- $css = drupal_add_css($path);
+ $css = _drupal_add_css($path);
$this->assertEqual($css['simpletest.module.css']['data'], $path);
}
@@ -57,7 +57,7 @@ class CascadingStylesheetsTest extends DrupalUnitTestBase {
*/
function testAddExternal() {
$path = 'http://example.com/style.css';
- $css = drupal_add_css($path, 'external');
+ $css = _drupal_add_css($path, 'external');
$this->assertEqual($css[$path]['type'], 'external', 'Adding an external CSS file caches it properly.');
}
@@ -65,8 +65,8 @@ class CascadingStylesheetsTest extends DrupalUnitTestBase {
* Makes sure that resetting the CSS empties the cache.
*/
function testReset() {
- drupal_static_reset('drupal_add_css');
- $this->assertEqual(array(), drupal_add_css(), 'Resetting the CSS empties the cache.');
+ drupal_static_reset('_drupal_add_css');
+ $this->assertEqual(array(), _drupal_add_css(), 'Resetting the CSS empties the cache.');
}
/**
@@ -74,7 +74,7 @@ class CascadingStylesheetsTest extends DrupalUnitTestBase {
*/
function testRenderFile() {
$css = drupal_get_path('module', 'simpletest') . '/css/simpletest.module.css';
- drupal_add_css($css);
+ _drupal_add_css($css);
$styles = drupal_get_css();
$this->assertTrue(strpos($styles, $css) > 0, 'Rendered CSS includes the added stylesheet.');
// Verify that newlines are properly added inside style tags.
@@ -88,7 +88,7 @@ class CascadingStylesheetsTest extends DrupalUnitTestBase {
*/
function testRenderExternal() {
$css = 'http://example.com/style.css';
- drupal_add_css($css, 'external');
+ _drupal_add_css($css, 'external');
$styles = drupal_get_css();
// Stylesheet URL may be the href of a LINK tag or in an @import statement
// of a STYLE tag.
@@ -105,7 +105,7 @@ class CascadingStylesheetsTest extends DrupalUnitTestBase {
$css = 'body { padding: 0px; }';
$css_preprocessed = '<style media="all">' . "\n/* <![CDATA[ */\n" . "body{padding:0px;}\n" . "\n/* ]]> */\n" . '</style>';
- drupal_add_css($css, array('type' => 'inline'));
+ _drupal_add_css($css, array('type' => 'inline'));
$styles = drupal_get_css();
$this->assertEqual(trim($styles), $css_preprocessed, 'Rendering preprocessed inline CSS adds it to the page.');
}
@@ -115,7 +115,7 @@ class CascadingStylesheetsTest extends DrupalUnitTestBase {
*/
function testRenderInlineNoPreprocess() {
$css = 'body { padding: 0px; }';
- drupal_add_css($css, array('type' => 'inline', 'preprocess' => FALSE));
+ _drupal_add_css($css, array('type' => 'inline', 'preprocess' => FALSE));
$styles = drupal_get_css();
$this->assertTrue(strpos($styles, $css) > 0, 'Rendering non-preprocessed inline CSS adds it to the page.');
}
@@ -125,12 +125,12 @@ class CascadingStylesheetsTest extends DrupalUnitTestBase {
*/
function testRenderOrder() {
// Load a module CSS file.
- drupal_add_css(drupal_get_path('module', 'simpletest') . '/css/simpletest.module.css');
+ _drupal_add_css(drupal_get_path('module', 'simpletest') . '/css/simpletest.module.css');
// Load a few system CSS files in a custom, early-loading aggregate group.
$test_aggregate_group = -100;
$system_path = drupal_get_path('module', 'system');
- drupal_add_css($system_path . '/css/system.module.css', array('group' => $test_aggregate_group, 'weight' => -10));
- drupal_add_css($system_path . '/css/system.theme.css', array('group' => $test_aggregate_group));
+ _drupal_add_css($system_path . '/css/system.module.css', array('group' => $test_aggregate_group, 'weight' => -10));
+ _drupal_add_css($system_path . '/css/system.theme.css', array('group' => $test_aggregate_group));
$expected = array(
$system_path . '/css/system.module.css',
@@ -157,16 +157,16 @@ class CascadingStylesheetsTest extends DrupalUnitTestBase {
function testRenderOverride() {
$system = drupal_get_path('module', 'system');
- drupal_add_css($system . '/css/system.module.css');
- drupal_add_css($system . '/tests/css/system.module.css');
+ _drupal_add_css($system . '/css/system.module.css');
+ _drupal_add_css($system . '/tests/css/system.module.css');
// The dummy stylesheet should be the only one included.
$styles = drupal_get_css();
$this->assert(strpos($styles, $system . '/tests/css/system.module.css') !== FALSE, 'The overriding CSS file is output.');
$this->assert(strpos($styles, $system . '/css/system.module.css') === FALSE, 'The overridden CSS file is not output.');
- drupal_add_css($system . '/tests/css/system.module.css');
- drupal_add_css($system . '/css/system.module.css');
+ _drupal_add_css($system . '/tests/css/system.module.css');
+ _drupal_add_css($system . '/css/system.module.css');
// The standard stylesheet should be the only one included.
$styles = drupal_get_css();
@@ -180,8 +180,8 @@ class CascadingStylesheetsTest extends DrupalUnitTestBase {
function testAddCssFileWithQueryString() {
$css_without_query_string = drupal_get_path('module', 'node') . '/css/node.admin.css';
$css_with_query_string = '/' . drupal_get_path('module', 'node') . '/node-fake.css?arg1=value1&arg2=value2';
- drupal_add_css($css_without_query_string);
- drupal_add_css($css_with_query_string);
+ _drupal_add_css($css_without_query_string);
+ _drupal_add_css($css_with_query_string);
$styles = drupal_get_css();
$query_string = $this->container->get('state')->get('system.css_js_query_string') ?: '0';
diff --git a/core/modules/system/lib/Drupal/system/Tests/Common/JavaScriptTest.php b/core/modules/system/lib/Drupal/system/Tests/Common/JavaScriptTest.php
index 3f584aa..2e529e4 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Common/JavaScriptTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Common/JavaScriptTest.php
@@ -47,8 +47,8 @@ class JavaScriptTest extends DrupalUnitTestBase {
$config->set('js.preprocess', 0);
$config->save();
- // Reset drupal_add_js() and drupal_add_library() statics before each test.
- drupal_static_reset('drupal_add_js');
+ // Reset _drupal_add_js() and drupal_add_library() statics before each test.
+ drupal_static_reset('_drupal_add_js');
drupal_static_reset('drupal_add_library');
}
@@ -64,14 +64,14 @@ class JavaScriptTest extends DrupalUnitTestBase {
* Tests that default JavaScript is empty.
*/
function testDefault() {
- $this->assertEqual(array(), drupal_add_js(), 'Default JavaScript is empty.');
+ $this->assertEqual(array(), _drupal_add_js(), 'Default JavaScript is empty.');
}
/**
* Tests adding a JavaScript file.
*/
function testAddFile() {
- $javascript = drupal_add_js('core/misc/collapse.js');
+ $javascript = _drupal_add_js('core/misc/collapse.js');
$this->assertTrue(array_key_exists('core/misc/collapse.js', $javascript), 'JavaScript files are correctly added.');
}
@@ -81,11 +81,11 @@ class JavaScriptTest extends DrupalUnitTestBase {
function testAddSetting() {
// Add a file in order to test default settings.
drupal_add_library('system', 'drupalSettings');
- $javascript = drupal_add_js();
+ $javascript = _drupal_add_js();
$last_settings = reset($javascript['settings']['data']);
$this->assertTrue(array_key_exists('currentPath', $last_settings), 'The current path JavaScript setting is set correctly.');
- $javascript = drupal_add_js(array('drupal' => 'rocks', 'dries' => 280342800), 'setting');
+ $javascript = _drupal_add_js(array('drupal' => 'rocks', 'dries' => 280342800), 'setting');
$last_settings = end($javascript['settings']['data']);
$this->assertEqual(280342800, $last_settings['dries'], 'JavaScript setting is set correctly.');
$this->assertEqual('rocks', $last_settings['drupal'], 'The other JavaScript setting is set correctly.');
@@ -96,7 +96,7 @@ class JavaScriptTest extends DrupalUnitTestBase {
*/
function testAddExternal() {
$path = 'http://example.com/script.js';
- $javascript = drupal_add_js($path, 'external');
+ $javascript = _drupal_add_js($path, 'external');
$this->assertTrue(array_key_exists('http://example.com/script.js', $javascript), 'Added an external JavaScript file.');
}
@@ -107,8 +107,8 @@ class JavaScriptTest extends DrupalUnitTestBase {
$default_query_string = $this->container->get('state')->get('system.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')));
+ _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>';
@@ -128,8 +128,8 @@ class JavaScriptTest extends DrupalUnitTestBase {
$default_query_string = $this->container->get('state')->get('system.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')));
+ _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>';
@@ -152,40 +152,40 @@ class JavaScriptTest extends DrupalUnitTestBase {
$this->assertTrue(strpos($javascript, 'currentPath') > 0, 'Rendered JavaScript header returns currentPath setting.');
// Only the second of these two entries should appear in drupalSettings.
- drupal_add_js(array('commonTest' => 'commonTestShouldNotAppear'), 'setting');
- drupal_add_js(array('commonTest' => 'commonTestShouldAppear'), 'setting');
+ _drupal_add_js(array('commonTest' => 'commonTestShouldNotAppear'), 'setting');
+ _drupal_add_js(array('commonTest' => 'commonTestShouldAppear'), 'setting');
// Only the second of these entries should appear in drupalSettings.
- drupal_add_js(array('commonTestJsArrayLiteral' => array('commonTestJsArrayLiteralOldValue')), 'setting');
- drupal_add_js(array('commonTestJsArrayLiteral' => array('commonTestJsArrayLiteralNewValue')), 'setting');
+ _drupal_add_js(array('commonTestJsArrayLiteral' => array('commonTestJsArrayLiteralOldValue')), 'setting');
+ _drupal_add_js(array('commonTestJsArrayLiteral' => array('commonTestJsArrayLiteralNewValue')), 'setting');
// Only the second of these two entries should appear in drupalSettings.
- drupal_add_js(array('commonTestJsObjectLiteral' => array('key' => 'commonTestJsObjectLiteralOldValue')), 'setting');
- drupal_add_js(array('commonTestJsObjectLiteral' => array('key' => 'commonTestJsObjectLiteralNewValue')), 'setting');
+ _drupal_add_js(array('commonTestJsObjectLiteral' => array('key' => 'commonTestJsObjectLiteralOldValue')), 'setting');
+ _drupal_add_js(array('commonTestJsObjectLiteral' => array('key' => 'commonTestJsObjectLiteralNewValue')), 'setting');
// Real world test case: multiple elements in a render array are adding the
// same (or nearly the same) JavaScript settings. When merged, they should
// contain all settings and not duplicate some settings.
$settings_one = array('moduleName' => array('ui' => array('button A', 'button B'), 'magical flag' => 3.14159265359));
- drupal_add_js(array('commonTestRealWorldIdentical' => $settings_one), 'setting');
- drupal_add_js(array('commonTestRealWorldIdentical' => $settings_one), 'setting');
+ _drupal_add_js(array('commonTestRealWorldIdentical' => $settings_one), 'setting');
+ _drupal_add_js(array('commonTestRealWorldIdentical' => $settings_one), 'setting');
$settings_two = array('moduleName' => array('ui' => array('button A', 'button B'), 'magical flag' => 3.14159265359, 'thingiesOnPage' => array('id1' => array())));
- drupal_add_js(array('commonTestRealWorldAlmostIdentical' => $settings_two), 'setting');
+ _drupal_add_js(array('commonTestRealWorldAlmostIdentical' => $settings_two), 'setting');
$settings_two = array('moduleName' => array('ui' => array('button C', 'button D'), 'magical flag' => 3.14, 'thingiesOnPage' => array('id2' => array())));
- drupal_add_js(array('commonTestRealWorldAlmostIdentical' => $settings_two), 'setting');
+ _drupal_add_js(array('commonTestRealWorldAlmostIdentical' => $settings_two), 'setting');
$javascript = drupal_get_js('header');
- // Test whether drupal_add_js can be used to override a previous 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.');
+ $this->assertTrue(strpos($javascript, 'commonTestShouldNotAppear') === FALSE, '_drupal_add_js() correctly overrides a custom setting.');
- // Test whether drupal_add_js can be used to add and override a JavaScript
+ // Test whether _drupal_add_js can be used to add and override a JavaScript
// array literal (an indexed PHP array) values.
$array_override = strpos($javascript, 'commonTestJsArrayLiteralNewValue') > 0 && strpos($javascript, 'commonTestJsArrayLiteralOldValue') === FALSE;
- $this->assertTrue($array_override, 'drupal_add_js() correctly overrides settings within an array literal (indexed array).');
+ $this->assertTrue($array_override, '_drupal_add_js() correctly overrides settings within an array literal (indexed array).');
- // Test whether drupal_add_js can be used to add and override a JavaScript
+ // Test whether _drupal_add_js can be used to add and override a JavaScript
// object literal (an associate PHP array) values.
$associative_array_override = strpos($javascript, 'commonTestJsObjectLiteralNewValue') > 0 && strpos($javascript, 'commonTestJsObjectLiteralOldValue') === FALSE;
- $this->assertTrue($associative_array_override, 'drupal_add_js() correctly overrides settings within an object literal (associative array).');
+ $this->assertTrue($associative_array_override, '_drupal_add_js() correctly overrides settings within an object literal (associative array).');
// Parse the generated drupalSettings <script> back to a PHP representation.
$startToken = 'drupalSettings = ';
@@ -197,8 +197,8 @@ class JavaScriptTest extends DrupalUnitTestBase {
// Test whether the two real world cases are handled correctly.
$settings_two['moduleName']['thingiesOnPage']['id1'] = array();
- $this->assertIdentical($settings_one, $parsed_settings['commonTestRealWorldIdentical'], 'drupal_add_js handled real world test case 1 correctly.');
- $this->assertEqual($settings_two, $parsed_settings['commonTestRealWorldAlmostIdentical'], 'drupal_add_js handled real world test case 2 correctly.');
+ $this->assertIdentical($settings_one, $parsed_settings['commonTestRealWorldIdentical'], '_drupal_add_js handled real world test case 1 correctly.');
+ $this->assertEqual($settings_two, $parsed_settings['commonTestRealWorldAlmostIdentical'], '_drupal_add_js handled real world test case 2 correctly.');
}
/**
@@ -206,9 +206,9 @@ class JavaScriptTest extends DrupalUnitTestBase {
*/
function testReset() {
drupal_add_library('system', 'drupal');
- drupal_add_js('core/misc/collapse.js');
- drupal_static_reset('drupal_add_js');
- $this->assertEqual(array(), drupal_add_js(), 'Resetting the JavaScript correctly empties the cache.');
+ _drupal_add_js('core/misc/collapse.js');
+ drupal_static_reset('_drupal_add_js');
+ $this->assertEqual(array(), _drupal_add_js(), 'Resetting the JavaScript correctly empties the cache.');
}
/**
@@ -217,7 +217,7 @@ class JavaScriptTest extends DrupalUnitTestBase {
function testAddInline() {
drupal_add_library('system', 'jquery');
$inline = 'jQuery(function () { });';
- $javascript = drupal_add_js($inline, array('type' => 'inline', 'scope' => 'footer'));
+ $javascript = _drupal_add_js($inline, array('type' => 'inline', 'scope' => 'footer'));
$this->assertTrue(array_key_exists('core/assets/vendor/jquery/jquery.js', $javascript), 'jQuery is added when inline scripts are added.');
$data = end($javascript);
$this->assertEqual($inline, $data['data'], 'Inline JavaScript is correctly added to the footer.');
@@ -229,7 +229,7 @@ class JavaScriptTest extends DrupalUnitTestBase {
function testRenderExternal() {
drupal_add_library('system', 'drupal');
$external = 'http://example.com/example.js';
- drupal_add_js($external, 'external');
+ _drupal_add_js($external, 'external');
$javascript = drupal_get_js();
// Local files have a base_path() prefix, external files should not.
$this->assertTrue(strpos($javascript, 'src="' . $external) > 0, 'Rendering an external JavaScript file.');
@@ -241,17 +241,17 @@ class JavaScriptTest extends DrupalUnitTestBase {
function testFooterHTML() {
drupal_add_library('system', 'drupal');
$inline = 'jQuery(function () { });';
- drupal_add_js($inline, array('type' => 'inline', 'scope' => 'footer'));
+ _drupal_add_js($inline, array('type' => 'inline', 'scope' => 'footer'));
$javascript = drupal_get_js('footer');
$this->assertTrue(strpos($javascript, $inline) > 0, 'Rendered JavaScript footer returns the inline code.');
}
/**
- * Tests drupal_add_js() sets preproccess to FALSE when cache is also FALSE.
+ * Tests _drupal_add_js() sets preproccess to FALSE when cache is also FALSE.
*/
function testNoCache() {
drupal_add_library('system', 'drupal');
- $javascript = drupal_add_js('core/misc/collapse.js', array('cache' => FALSE));
+ $javascript = _drupal_add_js('core/misc/collapse.js', array('cache' => FALSE));
$this->assertFalse($javascript['core/misc/collapse.js']['preprocess'], 'Setting cache to FALSE sets proprocess to FALSE when adding JavaScript.');
}
@@ -260,7 +260,7 @@ class JavaScriptTest extends DrupalUnitTestBase {
*/
function testDifferentGroup() {
drupal_add_library('system', 'drupal');
- $javascript = drupal_add_js('core/misc/collapse.js', array('group' => JS_THEME));
+ $javascript = _drupal_add_js('core/misc/collapse.js', array('group' => JS_THEME));
$this->assertEqual($javascript['core/misc/collapse.js']['group'], JS_THEME, 'Adding a JavaScript file with a different group caches the given group.');
}
@@ -268,7 +268,7 @@ class JavaScriptTest extends DrupalUnitTestBase {
* Tests adding a JavaScript file with a different weight.
*/
function testDifferentWeight() {
- $javascript = drupal_add_js('core/misc/collapse.js', array('weight' => 2));
+ $javascript = _drupal_add_js('core/misc/collapse.js', array('weight' => 2));
$this->assertEqual($javascript['core/misc/collapse.js']['weight'], 2, 'Adding a JavaScript file with a different weight caches the given weight.');
}
@@ -281,8 +281,8 @@ class JavaScriptTest extends DrupalUnitTestBase {
$default_query_string = $this->container->get('state')->get('system.css_js_query_string') ?: '0';
drupal_add_library('system', 'drupal');
- drupal_add_js('core/misc/collapse.js', array('browsers' => array('IE' => 'lte IE 8', '!IE' => FALSE)));
- drupal_add_js('jQuery(function () { });', array('type' => 'inline', 'browsers' => array('IE' => FALSE)));
+ _drupal_add_js('core/misc/collapse.js', array('browsers' => array('IE' => 'lte IE 8', '!IE' => FALSE)));
+ _drupal_add_js('jQuery(function () { });', array('type' => 'inline', 'browsers' => array('IE' => FALSE)));
$javascript = drupal_get_js();
$expected_1 = "<!--[if lte IE 8]>\n" . '<script src="' . file_create_url('core/misc/collapse.js') . '?' . $default_query_string . '"></script>' . "\n<![endif]-->";
@@ -297,8 +297,8 @@ class JavaScriptTest extends DrupalUnitTestBase {
*/
function testVersionQueryString() {
drupal_add_library('system', 'drupal');
- drupal_add_js('core/misc/collapse.js', array('version' => 'foo'));
- drupal_add_js('core/misc/ajax.js', array('version' => 'bar'));
+ _drupal_add_js('core/misc/collapse.js', array('version' => 'foo'));
+ _drupal_add_js('core/misc/ajax.js', array('version' => 'bar'));
$javascript = drupal_get_js();
$this->assertTrue(strpos($javascript, 'core/misc/collapse.js?v=foo') > 0 && strpos($javascript, 'core/misc/ajax.js?v=bar') > 0 , 'JavaScript version identifiers correctly appended to URLs');
}
@@ -314,10 +314,10 @@ class JavaScriptTest extends DrupalUnitTestBase {
// same regardless of whether aggregation is enabled, so ensure this
// expected order, first with aggregation off.
drupal_add_library('system', 'drupal');
- drupal_add_js('core/misc/ajax.js');
- drupal_add_js('core/misc/collapse.js', array('every_page' => TRUE));
- drupal_add_js('core/misc/autocomplete.js');
- drupal_add_js('core/misc/batch.js', array('every_page' => TRUE));
+ _drupal_add_js('core/misc/ajax.js');
+ _drupal_add_js('core/misc/collapse.js', array('every_page' => TRUE));
+ _drupal_add_js('core/misc/autocomplete.js');
+ _drupal_add_js('core/misc/batch.js', array('every_page' => TRUE));
$javascript = drupal_get_js();
$expected = implode("\n", array(
'<script src="' . file_create_url('core/misc/collapse.js') . '?' . $default_query_string . '"></script>',
@@ -329,16 +329,16 @@ class JavaScriptTest extends DrupalUnitTestBase {
// Now ensure that with aggregation on, one file is made for the
// 'every_page' files, and one file is made for the others.
- drupal_static_reset('drupal_add_js');
+ drupal_static_reset('_drupal_add_js');
$config = \Drupal::config('system.performance');
$config->set('js.preprocess', 1);
$config->save();
drupal_add_library('system', 'drupal');
- drupal_add_js('core/misc/ajax.js');
- drupal_add_js('core/misc/collapse.js', array('every_page' => TRUE));
- drupal_add_js('core/misc/autocomplete.js');
- drupal_add_js('core/misc/batch.js', array('every_page' => TRUE));
- $js_items = drupal_add_js();
+ _drupal_add_js('core/misc/ajax.js');
+ _drupal_add_js('core/misc/collapse.js', array('every_page' => TRUE));
+ _drupal_add_js('core/misc/autocomplete.js');
+ _drupal_add_js('core/misc/batch.js', array('every_page' => TRUE));
+ $js_items = _drupal_add_js();
$javascript = drupal_get_js();
$expected = implode("\n", array(
'<script src="' . $this->calculateAggregateFilename(array('core/misc/collapse.js' => $js_items['core/misc/collapse.js'], 'core/misc/batch.js' => $js_items['core/misc/batch.js'])) . '"></script>',
@@ -353,14 +353,14 @@ class JavaScriptTest extends DrupalUnitTestBase {
function testAggregationOrder() {
// Enable JavaScript aggregation.
\Drupal::config('system.performance')->set('js.preprocess', 1)->save();
- drupal_static_reset('drupal_add_js');
+ drupal_static_reset('_drupal_add_js');
// Add two JavaScript files to the current request and build the cache.
drupal_add_library('system', 'drupal');
- drupal_add_js('core/misc/ajax.js');
- drupal_add_js('core/misc/autocomplete.js');
+ _drupal_add_js('core/misc/ajax.js');
+ _drupal_add_js('core/misc/autocomplete.js');
- $js_items = drupal_add_js();
+ $js_items = _drupal_add_js();
$scripts_html = array(
'#type' => 'scripts',
'#items' => array(
@@ -376,14 +376,14 @@ class JavaScriptTest extends DrupalUnitTestBase {
// Reset variables and add a file in a different scope first.
\Drupal::state()->delete('system.js_cache_files');
- drupal_static_reset('drupal_add_js');
+ drupal_static_reset('_drupal_add_js');
drupal_add_library('system', 'drupal');
- drupal_add_js('some/custom/javascript_file.js', array('scope' => 'footer'));
- drupal_add_js('core/misc/ajax.js');
- drupal_add_js('core/misc/autocomplete.js');
+ _drupal_add_js('some/custom/javascript_file.js', array('scope' => 'footer'));
+ _drupal_add_js('core/misc/ajax.js');
+ _drupal_add_js('core/misc/autocomplete.js');
// Rebuild the cache.
- $js_items = drupal_add_js();
+ $js_items = _drupal_add_js();
$scripts_html = array(
'#type' => 'scripts',
'#items' => array(
@@ -404,16 +404,16 @@ class JavaScriptTest extends DrupalUnitTestBase {
*/
function testRenderOrder() {
// 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'));
+ _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(
@@ -449,7 +449,7 @@ class JavaScriptTest extends DrupalUnitTestBase {
// 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_library('system', 'jquery');
- drupal_add_js('core/misc/collapse.js', array('group' => JS_LIBRARY, 'every_page' => TRUE, 'weight' => -21));
+ _drupal_add_js('core/misc/collapse.js', array('group' => JS_LIBRARY, 'every_page' => TRUE, 'weight' => -21));
$javascript = drupal_get_js();
$this->assertTrue(strpos($javascript, 'core/misc/collapse.js') < strpos($javascript, 'core/assets/vendor/jquery/jquery.js'), 'Rendering a JavaScript file above jQuery.');
}
@@ -461,8 +461,8 @@ class JavaScriptTest extends DrupalUnitTestBase {
*/
function testAlter() {
// Add both tableselect.js and simpletest.js, with a larger weight on SimpleTest.
- drupal_add_js('core/misc/tableselect.js');
- drupal_add_js(drupal_get_path('module', 'simpletest') . '/simpletest.js', array('weight' => 9999));
+ _drupal_add_js('core/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
@@ -564,7 +564,7 @@ class JavaScriptTest extends DrupalUnitTestBase {
*/
function testAddJsFileWithQueryString() {
$js = drupal_get_path('module', 'node') . '/node.js';
- drupal_add_js($js);
+ _drupal_add_js($js);
$query_string = $this->container->get('state')->get('system.css_js_query_string') ?: '0';
$scripts = drupal_get_js();
diff --git a/core/modules/system/lib/Drupal/system/Tests/Common/RenderTest.php b/core/modules/system/lib/Drupal/system/Tests/Common/RenderTest.php
index 12d02b0..148dcdd 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Common/RenderTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Common/RenderTest.php
@@ -369,7 +369,7 @@ class RenderTest extends DrupalUnitTestBase {
// Load the element from cache and verify the presence of the #attached
// JavaScript.
- drupal_static_reset('drupal_add_js');
+ drupal_static_reset('_drupal_add_js');
$element = array('#cache' => array('keys' => array('simpletest', 'drupal_render', 'children_attached')));
$this->assertTrue(strlen(drupal_render($element)) > 0, 'The element was retrieved from cache.');
$scripts = drupal_get_js();
@@ -461,7 +461,7 @@ class RenderTest extends DrupalUnitTestBase {
);
// #cache disabled.
- drupal_static_reset('drupal_add_js');
+ drupal_static_reset('_drupal_add_js');
$element = $test_element;
$element['#markup'] = '<p>#cache disabled</p>';
$output = drupal_render($element);
@@ -477,7 +477,7 @@ class RenderTest extends DrupalUnitTestBase {
\Drupal::request()->setMethod('GET');
// GET request: #cache enabled, cache miss.
- drupal_static_reset('drupal_add_js');
+ drupal_static_reset('_drupal_add_js');
$element = $test_element;
$element['#cache'] = array('cid' => 'post_render_cache_test_GET');
$element['#markup'] = '<p>#cache enabled, GET</p>';
@@ -501,7 +501,7 @@ class RenderTest extends DrupalUnitTestBase {
$this->assertIdentical($cached_element, $expected_element, 'The correct data is cached: the stored #markup and #attached properties are not affected by #post_render_cache callbacks.');
// GET request: #cache enabled, cache hit.
- drupal_static_reset('drupal_add_js');
+ drupal_static_reset('_drupal_add_js');
$element['#cache'] = array('cid' => 'post_render_cache_test_GET');
$element['#markup'] = '<p>#cache enabled, GET</p>';
$output = drupal_render($element);
@@ -518,7 +518,7 @@ class RenderTest extends DrupalUnitTestBase {
\Drupal::request()->setMethod('POST');
// POST request: #cache enabled, cache miss.
- drupal_static_reset('drupal_add_js');
+ drupal_static_reset('_drupal_add_js');
$element = $test_element;
$element['#cache'] = array('cid' => 'post_render_cache_test_POST');
$element['#markup'] = '<p>#cache enabled, POST</p>';
@@ -551,7 +551,7 @@ class RenderTest extends DrupalUnitTestBase {
// Test case 1.
// Create an element with a child and subchild. Each element has the same
// #post_render_cache callback, but with different contexts.
- drupal_static_reset('drupal_add_js');
+ drupal_static_reset('_drupal_add_js');
$context_1 = array('foo' => $this->randomString());
$context_2 = array('bar' => $this->randomString());
$context_3 = array('baz' => $this->randomString());
@@ -621,7 +621,7 @@ class RenderTest extends DrupalUnitTestBase {
$this->assertIdentical($cached_element, $expected_element, 'The correct data is cached: the stored #markup and #attached properties are not affected by #post_render_cache callbacks.');
// GET request: #cache enabled, cache hit.
- drupal_static_reset('drupal_add_js');
+ drupal_static_reset('_drupal_add_js');
$element = $test_element;
$output = drupal_render($element);
$this->assertIdentical($output, '<p>overridden</p>', 'Output is overridden.');
@@ -639,7 +639,7 @@ class RenderTest extends DrupalUnitTestBase {
// #post_render_cache callbacks. I.e. the #post_render_cache callbacks may
// not yet have run, or otherwise the cached parent element would contain
// personalized data, thereby breaking the render cache.
- drupal_static_reset('drupal_add_js');
+ drupal_static_reset('_drupal_add_js');
$element = $test_element;
$element['#cache']['keys'] = array('simpletest', 'drupal_render', 'children_post_render_cache', 'nested_cache_parent');
$element['child']['#cache']['keys'] = array('simpletest', 'drupal_render', 'children_post_render_cache', 'nested_cache_child');
@@ -699,7 +699,7 @@ class RenderTest extends DrupalUnitTestBase {
$this->assertIdentical($cached_child_element, $expected_child_element, 'The correct data is cached for the child: the stored #markup and #attached properties are not affected by #post_render_cache callbacks.');
// GET request: #cache enabled, cache hit, parent element.
- drupal_static_reset('drupal_add_js');
+ drupal_static_reset('_drupal_add_js');
$element = $test_element;
$element['#cache']['keys'] = array('simpletest', 'drupal_render', 'children_post_render_cache', 'nested_cache_parent');
$output = drupal_render($element);
@@ -711,7 +711,7 @@ class RenderTest extends DrupalUnitTestBase {
$this->assertIdentical($settings['common_test'], $expected_settings, '#attached is modified; JavaScript settings for each #post_render_cache callback are added to page.');
// GET request: #cache enabled, cache hit, child element.
- drupal_static_reset('drupal_add_js');
+ drupal_static_reset('_drupal_add_js');
$element = $test_element;
$element['child']['#cache']['keys'] = array('simpletest', 'drupal_render', 'children_post_render_cache', 'nested_cache_child');
$element = $element['child'];
@@ -744,7 +744,7 @@ class RenderTest extends DrupalUnitTestBase {
$expected_output = '<foo><bar>' . $context['bar'] . '</bar></foo>';
// #cache disabled.
- drupal_static_reset('drupal_add_js');
+ drupal_static_reset('_drupal_add_js');
$element = $test_element;
$output = drupal_render($element);
$this->assertIdentical($output, $expected_output, 'Placeholder was replaced in output');
@@ -756,7 +756,7 @@ class RenderTest extends DrupalUnitTestBase {
\Drupal::request()->setMethod('GET');
// GET request: #cache enabled, cache miss.
- drupal_static_reset('drupal_add_js');
+ drupal_static_reset('_drupal_add_js');
$element = $test_element;
$element['#cache'] = array('cid' => 'render_cache_placeholder_test_GET');
$output = drupal_render($element);
@@ -785,7 +785,7 @@ class RenderTest extends DrupalUnitTestBase {
$this->assertIdentical($cached_element, $expected_element, 'The correct data is cached: the stored #markup and #attached properties are not affected by #post_render_cache callbacks.');
// GET request: #cache enabled, cache hit.
- drupal_static_reset('drupal_add_js');
+ drupal_static_reset('_drupal_add_js');
$element = $test_element;
$element['#cache'] = array('cid' => 'render_cache_placeholder_test_GET');
$output = drupal_render($element);
diff --git a/core/modules/system/lib/Drupal/system/Tests/Theme/TableTest.php b/core/modules/system/lib/Drupal/system/Tests/Theme/TableTest.php
index 1cea46a..1a9d3d1 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Theme/TableTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Theme/TableTest.php
@@ -28,10 +28,10 @@ class TableTest extends WebTestBase {
$header = array('one', 'two', 'three');
$rows = array(array(1,2,3), array(4,5,6), array(7,8,9));
$this->content = theme('table', array('header' => $header, 'rows' => $rows, 'sticky' => TRUE));
- $js = drupal_add_js();
+ $js = _drupal_add_js();
$this->assertTrue(isset($js['core/misc/tableheader.js']), 'tableheader.js was included when $sticky = TRUE.');
$this->assertRaw('sticky-enabled', 'Table has a class of sticky-enabled when $sticky = TRUE.');
- drupal_static_reset('drupal_add_js');
+ drupal_static_reset('_drupal_add_js');
}
/**
@@ -44,10 +44,10 @@ class TableTest extends WebTestBase {
$caption = NULL;
$colgroups = array();
$this->content = theme('table', array('header' => $header, 'rows' => $rows, 'attributes' => $attributes, 'caption' => $caption, 'colgroups' => $colgroups, 'sticky' => FALSE));
- $js = drupal_add_js();
+ $js = _drupal_add_js();
$this->assertFalse(isset($js['core/misc/tableheader.js']), 'tableheader.js was not included because $sticky = FALSE.');
$this->assertNoRaw('sticky-enabled', 'Table does not have a class of sticky-enabled because $sticky = FALSE.');
- drupal_static_reset('drupal_add_js');
+ drupal_static_reset('_drupal_add_js');
}
/**