update core to 7.36

This commit is contained in:
Bachir Soussi Chiadmi
2015-04-19 19:33:23 +02:00
parent 6de56c702c
commit 802ec0c6f3
271 changed files with 4111 additions and 1227 deletions

View File

@@ -209,7 +209,16 @@ class CommonURLUnitTest extends DrupalWebTestCase {
// Test that drupal can recognize an absolute URL. Used to prevent attack vectors.
$this->assertTrue(url_is_external($url), 'Correctly identified an external URL.');
// External URL without an explicit protocol.
$url = '//drupal.org/foo/bar?foo=bar&bar=baz&baz#foo';
$this->assertTrue(url_is_external($url), 'Correctly identified an external URL without a protocol part.');
// Internal URL starting with a slash.
$url = '/drupal.org';
$this->assertFalse(url_is_external($url), 'Correctly identified an internal URL with a leading slash.');
// Test the parsing of absolute URLs.
$url = 'http://drupal.org/foo/bar?foo=bar&bar=baz&baz#foo';
$result = array(
'path' => 'http://drupal.org/foo/bar',
'query' => array('foo' => 'bar', 'bar' => 'baz', 'baz' => ''),
@@ -349,6 +358,17 @@ class CommonURLUnitTest extends DrupalWebTestCase {
$query = array($this->randomName(5) => $this->randomName(5));
$result = url($url, array('query' => $query));
$this->assertEqual($url . '&' . http_build_query($query, '', '&'), $result, 'External URL query string can be extended with a custom query string in $options.');
// Verify that an internal URL does not result in an external URL without
// protocol part.
$url = '/drupal.org';
$result = url($url);
$this->assertTrue(strpos($result, '//') === FALSE, 'Internal URL does not turn into an external URL.');
// Verify that an external URL without protocol part is recognized as such.
$url = '//drupal.org';
$result = url($url);
$this->assertEqual($url, $result, 'External URL without protocol is not altered.');
}
}
@@ -661,6 +681,10 @@ class CascadingStylesheetsTestCase extends DrupalWebTestCase {
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.
$query_string = variable_get('css_js_query_string', '0');
$css_processed = "<style type=\"text/css\" media=\"all\">\n@import url(\"" . check_plain(file_create_url($css)) . "?" . $query_string ."\");\n</style>";
$this->assertEqual(trim($styles), $css_processed, 'Rendered CSS includes newlines inside style tags for JavaScript use.');
}
/**
@@ -914,9 +938,10 @@ class CascadingStylesheetsUnitTest extends DrupalUnitTestCase {
* Tests basic CSS loading with and without optimization via drupal_load_stylesheet().
*
* Known tests:
* - Retain white-space in selectors. (http://drupal.org/node/472820)
* - Proper URLs in imported files. (http://drupal.org/node/265719)
* - Retain pseudo-selectors. (http://drupal.org/node/460448)
* - Retain white-space in selectors. (https://drupal.org/node/472820)
* - Proper URLs in imported files. (https://drupal.org/node/265719)
* - Retain pseudo-selectors. (https://drupal.org/node/460448)
* - Don't adjust data URIs. (https://drupal.org/node/2142441)
*/
function testLoadCssBasic() {
// Array of files to test living in 'simpletest/files/css_test_files/'.
@@ -1082,6 +1107,74 @@ class DrupalHTTPRequestTestCase extends DrupalWebTestCase {
}
}
/**
* Tests parsing of the HTTP response status line.
*/
class DrupalHTTPResponseStatusLineTest extends DrupalUnitTestCase {
public static function getInfo() {
return array(
'name' => 'Drupal HTTP request response status parsing',
'description' => 'Perform unit tests on _drupal_parse_response_status().',
'group' => 'System',
);
}
/**
* Tests parsing HTTP response status line.
*/
public function testStatusLine() {
// Grab the big array of test data from statusLineData().
$data = $this->statusLineData();
foreach($data as $test_case) {
$test_data = array_shift($test_case);
$expected = array_shift($test_case);
$outcome = _drupal_parse_response_status($test_data);
foreach(array_keys($expected) as $key) {
$this->assertIdentical($outcome[$key], $expected[$key]);
}
}
}
/**
* Data provider for testStatusLine().
*
* @return array
* Test data.
*/
protected function statusLineData() {
return array(
array(
'HTTP/1.1 200 OK',
array(
'http_version' => 'HTTP/1.1',
'response_code' => '200',
'reason_phrase' => 'OK',
),
),
// Data set with no reason phrase.
array(
'HTTP/1.1 200',
array(
'http_version' => 'HTTP/1.1',
'response_code' => '200',
'reason_phrase' => '',
),
),
// Arbitrary strings.
array(
'version code multi word explanation',
array(
'http_version' => 'version',
'response_code' => 'code',
'reason_phrase' => 'multi word explanation',
),
),
);
}
}
/**
* Testing drupal_add_region_content and drupal_get_region_content.
*/
@@ -1347,6 +1440,127 @@ class JavaScriptTestCase extends DrupalWebTestCase {
$this->assertTrue(strpos($javascript, $inline) > 0, 'Rendered JavaScript footer returns the inline code.');
}
/**
* Test the 'javascript_always_use_jquery' variable.
*/
function testJavaScriptAlwaysUseJQuery() {
// The default front page of the site should use jQuery and other standard
// scripts and settings.
$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.
variable_set('javascript_always_use_jquery', FALSE);
$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.
$this->resetStaticVariables();
drupal_add_js(array('testJavaScriptSetting' => 'test'), 'setting');
$javascript = drupal_get_js();
$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
// addded to the page without jQuery).
$this->resetStaticVariables();
variable_set('javascript_always_use_jquery', FALSE);
drupal_add_js(array('testJavaScriptSetting' => 'test'), 'setting');
$javascript = drupal_get_js();
$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.
$this->resetStaticVariables();
drupal_add_js('misc/collapse.js');
$javascript = drupal_get_js();
$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).
$this->resetStaticVariables();
variable_set('javascript_always_use_jquery', FALSE);
drupal_add_js('misc/collapse.js');
$javascript = drupal_get_js();
$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.
$this->resetStaticVariables();
drupal_add_js('misc/collapse.js', array('requires_jquery' => FALSE));
$javascript = drupal_get_js();
$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.
$this->resetStaticVariables();
variable_set('javascript_always_use_jquery', FALSE);
drupal_add_js('misc/collapse.js', array('requires_jquery' => FALSE));
$javascript = drupal_get_js();
$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.
$this->resetStaticVariables();
variable_set('javascript_always_use_jquery', FALSE);
drupal_add_js('misc/collapse.js', array('requires_jquery' => FALSE));
drupal_add_js('misc/ajax.js');
$javascript = drupal_get_js();
$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');
}
/**
* Test drupal_add_js() sets preproccess to false when cache is set to false.
*/
@@ -1575,6 +1789,15 @@ class JavaScriptTestCase extends DrupalWebTestCase {
$query_string = variable_get('css_js_query_string', '0');
$this->assertRaw(drupal_get_path('module', 'node') . '/node.js?' . $query_string, 'Query string was appended correctly to js.');
}
/**
* Resets static variables related to adding JavaScript to a page.
*/
function resetStaticVariables() {
drupal_static_reset('drupal_add_js');
drupal_static_reset('drupal_add_library');
drupal_static_reset('drupal_get_library');
}
}
/**