update core to 7.36
This commit is contained in:
@@ -143,15 +143,7 @@ abstract class DrupalTestCase {
|
||||
);
|
||||
|
||||
// Store assertion for display after the test has completed.
|
||||
try {
|
||||
$connection = Database::getConnection('default', 'simpletest_original_default');
|
||||
}
|
||||
catch (DatabaseConnectionNotDefinedException $e) {
|
||||
// If the test was not set up, the simpletest_original_default
|
||||
// connection does not exist.
|
||||
$connection = Database::getConnection('default', 'default');
|
||||
}
|
||||
$connection
|
||||
self::getDatabaseConnection()
|
||||
->insert('simpletest')
|
||||
->fields($assertion)
|
||||
->execute();
|
||||
@@ -166,6 +158,25 @@ abstract class DrupalTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the database connection to the site running Simpletest.
|
||||
*
|
||||
* @return DatabaseConnection
|
||||
* The database connection to use for inserting assertions.
|
||||
*/
|
||||
public static function getDatabaseConnection() {
|
||||
try {
|
||||
$connection = Database::getConnection('default', 'simpletest_original_default');
|
||||
}
|
||||
catch (DatabaseConnectionNotDefinedException $e) {
|
||||
// If the test was not set up, the simpletest_original_default
|
||||
// connection does not exist.
|
||||
$connection = Database::getConnection('default', 'default');
|
||||
}
|
||||
|
||||
return $connection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Store an assertion from outside the testing context.
|
||||
*
|
||||
@@ -205,7 +216,8 @@ abstract class DrupalTestCase {
|
||||
'file' => $caller['file'],
|
||||
);
|
||||
|
||||
return db_insert('simpletest')
|
||||
return self::getDatabaseConnection()
|
||||
->insert('simpletest')
|
||||
->fields($assertion)
|
||||
->execute();
|
||||
}
|
||||
@@ -221,7 +233,8 @@ abstract class DrupalTestCase {
|
||||
* @see DrupalTestCase::insertAssert()
|
||||
*/
|
||||
public static function deleteAssert($message_id) {
|
||||
return (bool) db_delete('simpletest')
|
||||
return (bool) self::getDatabaseConnection()
|
||||
->delete('simpletest')
|
||||
->condition('message_id', $message_id)
|
||||
->execute();
|
||||
}
|
||||
@@ -435,10 +448,10 @@ abstract class DrupalTestCase {
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs verbose message in a text file.
|
||||
* Logs a verbose message in a text file.
|
||||
*
|
||||
* The a link to the vebose message will be placed in the test results via
|
||||
* as a passing assertion with the text '[verbose message]'.
|
||||
* The link to the verbose message will be placed in the test results as a
|
||||
* passing assertion with the text '[verbose message]'.
|
||||
*
|
||||
* @param $message
|
||||
* The verbose message to be stored.
|
||||
@@ -1756,14 +1769,24 @@ class DrupalWebTestCase extends DrupalTestCase {
|
||||
protected function curlExec($curl_options, $redirect = FALSE) {
|
||||
$this->curlInitialize();
|
||||
|
||||
// cURL incorrectly handles URLs with a fragment by including the
|
||||
// fragment in the request to the server, causing some web servers
|
||||
// to reject the request citing "400 - Bad Request". To prevent
|
||||
// this, we strip the fragment from the request.
|
||||
// TODO: Remove this for Drupal 8, since fixed in curl 7.20.0.
|
||||
if (!empty($curl_options[CURLOPT_URL]) && strpos($curl_options[CURLOPT_URL], '#')) {
|
||||
$original_url = $curl_options[CURLOPT_URL];
|
||||
$curl_options[CURLOPT_URL] = strtok($curl_options[CURLOPT_URL], '#');
|
||||
if (!empty($curl_options[CURLOPT_URL])) {
|
||||
// Forward XDebug activation if present.
|
||||
if (isset($_COOKIE['XDEBUG_SESSION'])) {
|
||||
$options = drupal_parse_url($curl_options[CURLOPT_URL]);
|
||||
$options += array('query' => array());
|
||||
$options['query'] += array('XDEBUG_SESSION_START' => $_COOKIE['XDEBUG_SESSION']);
|
||||
$curl_options[CURLOPT_URL] = url($options['path'], $options);
|
||||
}
|
||||
|
||||
// cURL incorrectly handles URLs with a fragment by including the
|
||||
// fragment in the request to the server, causing some web servers
|
||||
// to reject the request citing "400 - Bad Request". To prevent
|
||||
// this, we strip the fragment from the request.
|
||||
// TODO: Remove this for Drupal 8, since fixed in curl 7.20.0.
|
||||
if (strpos($curl_options[CURLOPT_URL], '#')) {
|
||||
$original_url = $curl_options[CURLOPT_URL];
|
||||
$curl_options[CURLOPT_URL] = strtok($curl_options[CURLOPT_URL], '#');
|
||||
}
|
||||
}
|
||||
|
||||
$url = empty($curl_options[CURLOPT_URL]) ? curl_getinfo($this->curlHandle, CURLINFO_EFFECTIVE_URL) : $curl_options[CURLOPT_URL];
|
||||
@@ -2288,6 +2311,8 @@ class DrupalWebTestCase extends DrupalTestCase {
|
||||
break;
|
||||
case 'restripe':
|
||||
break;
|
||||
case 'add_css':
|
||||
break;
|
||||
}
|
||||
}
|
||||
$content = $dom->saveHTML();
|
||||
@@ -2624,8 +2649,6 @@ class DrupalWebTestCase extends DrupalTestCase {
|
||||
*
|
||||
* @param $label
|
||||
* Text between the anchor tags.
|
||||
* @param $index
|
||||
* Link position counting from zero.
|
||||
* @param $message
|
||||
* Message to display.
|
||||
* @param $group
|
||||
@@ -2684,28 +2707,26 @@ class DrupalWebTestCase extends DrupalTestCase {
|
||||
*
|
||||
* Will click the first link found with this link text by default, or a later
|
||||
* one if an index is given. Match is case sensitive with normalized space.
|
||||
* The label is translated label. There is an assert for successful click.
|
||||
* The label is translated label.
|
||||
*
|
||||
* If the link is discovered and clicked, the test passes. Fail otherwise.
|
||||
*
|
||||
* @param $label
|
||||
* Text between the anchor tags.
|
||||
* @param $index
|
||||
* Link position counting from zero.
|
||||
* @return
|
||||
* Page on success, or FALSE on failure.
|
||||
* Page contents on success, or FALSE on failure.
|
||||
*/
|
||||
protected function clickLink($label, $index = 0) {
|
||||
$url_before = $this->getUrl();
|
||||
$urls = $this->xpath('//a[normalize-space(text())=:label]', array(':label' => $label));
|
||||
|
||||
if (isset($urls[$index])) {
|
||||
$url_target = $this->getAbsoluteUrl($urls[$index]['href']);
|
||||
}
|
||||
|
||||
$this->assertTrue(isset($urls[$index]), t('Clicked link %label (@url_target) from @url_before', array('%label' => $label, '@url_target' => $url_target, '@url_before' => $url_before)), t('Browser'));
|
||||
|
||||
if (isset($url_target)) {
|
||||
$this->pass(t('Clicked link %label (@url_target) from @url_before', array('%label' => $label, '@url_target' => $url_target, '@url_before' => $url_before)), 'Browser');
|
||||
return $this->drupalGet($url_target);
|
||||
}
|
||||
$this->fail(t('Link %label does not exist on @url_before', array('%label' => $label, '@url_before' => $url_before)), 'Browser');
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -3189,7 +3210,7 @@ class DrupalWebTestCase extends DrupalTestCase {
|
||||
* @param $callback
|
||||
* The name of the theme function to invoke; e.g. 'links' for theme_links().
|
||||
* @param $variables
|
||||
* An array of variables to pass to the theme function.
|
||||
* (optional) An array of variables to pass to the theme function.
|
||||
* @param $expected
|
||||
* The expected themed output string.
|
||||
* @param $message
|
||||
@@ -3225,7 +3246,9 @@ class DrupalWebTestCase extends DrupalTestCase {
|
||||
* @param $xpath
|
||||
* XPath used to find the field.
|
||||
* @param $value
|
||||
* (optional) Value of the field to assert.
|
||||
* (optional) Value of the field to assert. You may pass in NULL (default)
|
||||
* to skip checking the actual value, while still checking that the field
|
||||
* exists.
|
||||
* @param $message
|
||||
* (optional) Message to display.
|
||||
* @param $group
|
||||
@@ -3293,12 +3316,14 @@ class DrupalWebTestCase extends DrupalTestCase {
|
||||
}
|
||||
|
||||
/**
|
||||
* Asserts that a field does not exist in the current page by the given XPath.
|
||||
* Asserts that a field doesn't exist or its value doesn't match, by XPath.
|
||||
*
|
||||
* @param $xpath
|
||||
* XPath used to find the field.
|
||||
* @param $value
|
||||
* (optional) Value of the field to assert.
|
||||
* (optional) Value for the field, to assert that the field's value on the
|
||||
* page doesn't match it. You may pass in NULL to skip checking the
|
||||
* value, while still checking that the field doesn't exist.
|
||||
* @param $message
|
||||
* (optional) Message to display.
|
||||
* @param $group
|
||||
@@ -3331,7 +3356,9 @@ class DrupalWebTestCase extends DrupalTestCase {
|
||||
* @param $name
|
||||
* Name of field to assert.
|
||||
* @param $value
|
||||
* Value of the field to assert.
|
||||
* (optional) Value of the field to assert. You may pass in NULL (default)
|
||||
* to skip checking the actual value, while still checking that the field
|
||||
* exists.
|
||||
* @param $message
|
||||
* Message to display.
|
||||
* @param $group
|
||||
@@ -3362,9 +3389,12 @@ class DrupalWebTestCase extends DrupalTestCase {
|
||||
* @param $name
|
||||
* Name of field to assert.
|
||||
* @param $value
|
||||
* Value of the field to assert.
|
||||
* (optional) Value for the field, to assert that the field's value on the
|
||||
* page doesn't match it. You may pass in NULL to skip checking the
|
||||
* value, while still checking that the field doesn't exist. However, the
|
||||
* default value ('') asserts that the field value is not an empty string.
|
||||
* @param $message
|
||||
* Message to display.
|
||||
* (optional) Message to display.
|
||||
* @param $group
|
||||
* The group this message belongs to.
|
||||
* @return
|
||||
@@ -3375,14 +3405,17 @@ class DrupalWebTestCase extends DrupalTestCase {
|
||||
}
|
||||
|
||||
/**
|
||||
* Asserts that a field exists in the current page with the given id and value.
|
||||
* Asserts that a field exists in the current page with the given ID and value.
|
||||
*
|
||||
* @param $id
|
||||
* Id of field to assert.
|
||||
* ID of field to assert.
|
||||
* @param $value
|
||||
* Value of the field to assert.
|
||||
* (optional) Value for the field to assert. You may pass in NULL to skip
|
||||
* checking the value, while still checking that the field exists.
|
||||
* However, the default value ('') asserts that the field value is an empty
|
||||
* string.
|
||||
* @param $message
|
||||
* Message to display.
|
||||
* (optional) Message to display.
|
||||
* @param $group
|
||||
* The group this message belongs to.
|
||||
* @return
|
||||
@@ -3393,14 +3426,17 @@ class DrupalWebTestCase extends DrupalTestCase {
|
||||
}
|
||||
|
||||
/**
|
||||
* Asserts that a field does not exist with the given id and value.
|
||||
* Asserts that a field does not exist with the given ID and value.
|
||||
*
|
||||
* @param $id
|
||||
* Id of field to assert.
|
||||
* ID of field to assert.
|
||||
* @param $value
|
||||
* Value of the field to assert.
|
||||
* (optional) Value for the field, to assert that the field's value on the
|
||||
* page doesn't match it. You may pass in NULL to skip checking the value,
|
||||
* while still checking that the field doesn't exist. However, the default
|
||||
* value ('') asserts that the field value is not an empty string.
|
||||
* @param $message
|
||||
* Message to display.
|
||||
* (optional) Message to display.
|
||||
* @param $group
|
||||
* The group this message belongs to.
|
||||
* @return
|
||||
@@ -3414,9 +3450,9 @@ class DrupalWebTestCase extends DrupalTestCase {
|
||||
* Asserts that a checkbox field in the current page is checked.
|
||||
*
|
||||
* @param $id
|
||||
* Id of field to assert.
|
||||
* ID of field to assert.
|
||||
* @param $message
|
||||
* Message to display.
|
||||
* (optional) Message to display.
|
||||
* @return
|
||||
* TRUE on pass, FALSE on fail.
|
||||
*/
|
||||
@@ -3429,9 +3465,9 @@ class DrupalWebTestCase extends DrupalTestCase {
|
||||
* Asserts that a checkbox field in the current page is not checked.
|
||||
*
|
||||
* @param $id
|
||||
* Id of field to assert.
|
||||
* ID of field to assert.
|
||||
* @param $message
|
||||
* Message to display.
|
||||
* (optional) Message to display.
|
||||
* @return
|
||||
* TRUE on pass, FALSE on fail.
|
||||
*/
|
||||
@@ -3444,11 +3480,11 @@ class DrupalWebTestCase extends DrupalTestCase {
|
||||
* Asserts that a select option in the current page is checked.
|
||||
*
|
||||
* @param $id
|
||||
* Id of select field to assert.
|
||||
* ID of select field to assert.
|
||||
* @param $option
|
||||
* Option to assert.
|
||||
* @param $message
|
||||
* Message to display.
|
||||
* (optional) Message to display.
|
||||
* @return
|
||||
* TRUE on pass, FALSE on fail.
|
||||
*
|
||||
@@ -3463,11 +3499,11 @@ class DrupalWebTestCase extends DrupalTestCase {
|
||||
* Asserts that a select option in the current page is not checked.
|
||||
*
|
||||
* @param $id
|
||||
* Id of select field to assert.
|
||||
* ID of select field to assert.
|
||||
* @param $option
|
||||
* Option to assert.
|
||||
* @param $message
|
||||
* Message to display.
|
||||
* (optional) Message to display.
|
||||
* @return
|
||||
* TRUE on pass, FALSE on fail.
|
||||
*/
|
||||
@@ -3477,12 +3513,12 @@ class DrupalWebTestCase extends DrupalTestCase {
|
||||
}
|
||||
|
||||
/**
|
||||
* Asserts that a field exists with the given name or id.
|
||||
* Asserts that a field exists with the given name or ID.
|
||||
*
|
||||
* @param $field
|
||||
* Name or id of field to assert.
|
||||
* Name or ID of field to assert.
|
||||
* @param $message
|
||||
* Message to display.
|
||||
* (optional) Message to display.
|
||||
* @param $group
|
||||
* The group this message belongs to.
|
||||
* @return
|
||||
@@ -3493,12 +3529,12 @@ class DrupalWebTestCase extends DrupalTestCase {
|
||||
}
|
||||
|
||||
/**
|
||||
* Asserts that a field does not exist with the given name or id.
|
||||
* Asserts that a field does not exist with the given name or ID.
|
||||
*
|
||||
* @param $field
|
||||
* Name or id of field to assert.
|
||||
* Name or ID of field to assert.
|
||||
* @param $message
|
||||
* Message to display.
|
||||
* (optional) Message to display.
|
||||
* @param $group
|
||||
* The group this message belongs to.
|
||||
* @return
|
||||
|
@@ -1,4 +1,4 @@
|
||||
ul,select{font:1em/160% Verdana,sans-serif;color:#494949;}.ui-icon{background-image:url(images/icon.png);}
|
||||
ul,select{font:1em/160% Verdana,sans-serif;color:#494949;}.ui-icon{background-image:url(images/icon.png);}.data .double-quote{background-image:url("data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7");}.data .single-quote{background-image:url('data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDACAWGBwYFCAcGhwkIiAmMFA0MCwsMGJGSjpQdGZ6eHJmcG6AkLicgIiuim5woNqirr7EztDOfJri8uDI8LjKzsb/2wBDASIkJDAqMF40NF7GhHCExsbGxsbGxsbGxsbGxsbGxsbGxsbGxsbGxsbGxsbGxsbGxsbGxsbGxsbGxsbGxsbGxsb/wAARCAABAAEDASIAAhEBAxEB/8QAFQABAQAAAAAAAAAAAAAAAAAAAAb/xAAUEAEAAAAAAAAAAAAAAAAAAAAA/8QAFAEBAAAAAAAAAAAAAAAAAAAAAP/EABQRAQAAAAAAAAAAAAAAAAAAAAD/2gAMAwEAAhEDEQA/AKAAH//Z');}.data .no-quote{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACEAAAAEAQAAAAAo/mtHAAAAIElEQVQIHWMRnWHwcRNLN8NZ7QYWwT8PlBlYsgqVBRsAankIMw5MtnoAAAAASUVORK5CYII=);}
|
||||
p,select{font:1em/160% Verdana,sans-serif;color:#494949;}
|
||||
body{margin:0;padding:0;background:#edf5fa;font:76%/170% Verdana,sans-serif;color:#494949;}.this .is .a .test{font:1em/100% Verdana,sans-serif;color:#494949;}.this
|
||||
.is
|
||||
|
@@ -7,6 +7,21 @@ ul, select {
|
||||
}
|
||||
.ui-icon{background-image: url(images/icon.png);}
|
||||
|
||||
/* Test data URI images with different quote styles. */
|
||||
.data .double-quote {
|
||||
/* http://stackoverflow.com/a/13139830/11023 */
|
||||
background-image: url("data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7");
|
||||
}
|
||||
|
||||
.data .single-quote {
|
||||
background-image: url('data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDACAWGBwYFCAcGhwkIiAmMFA0MCwsMGJGSjpQdGZ6eHJmcG6AkLicgIiuim5woNqirr7EztDOfJri8uDI8LjKzsb/2wBDASIkJDAqMF40NF7GhHCExsbGxsbGxsbGxsbGxsbGxsbGxsbGxsbGxsbGxsbGxsbGxsbGxsbGxsbGxsbGxsbGxsb/wAARCAABAAEDASIAAhEBAxEB/8QAFQABAQAAAAAAAAAAAAAAAAAAAAb/xAAUEAEAAAAAAAAAAAAAAAAAAAAA/8QAFAEBAAAAAAAAAAAAAAAAAAAAAP/EABQRAQAAAAAAAAAAAAAAAAAAAAD/2gAMAwEAAhEDEQA/AKAAH//Z');
|
||||
}
|
||||
|
||||
.data .no-quote {
|
||||
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACEAAAAEAQAAAAAo/mtHAAAAIElEQVQIHWMRnWHwcRNLN8NZ7QYWwT8PlBlYsgqVBRsAankIMw5MtnoAAAAASUVORK5CYII=);
|
||||
}
|
||||
|
||||
|
||||
p, select {
|
||||
font: 1em/160% Verdana, sans-serif;
|
||||
color: #494949;
|
||||
|
@@ -1,4 +1,4 @@
|
||||
ul,select{font:1em/160% Verdana,sans-serif;color:#494949;}.ui-icon{background-image:url(../images/icon.png);}
|
||||
ul,select{font:1em/160% Verdana,sans-serif;color:#494949;}.ui-icon{background-image:url(../images/icon.png);}.data .double-quote{background-image:url("data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7");}.data .single-quote{background-image:url('data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDACAWGBwYFCAcGhwkIiAmMFA0MCwsMGJGSjpQdGZ6eHJmcG6AkLicgIiuim5woNqirr7EztDOfJri8uDI8LjKzsb/2wBDASIkJDAqMF40NF7GhHCExsbGxsbGxsbGxsbGxsbGxsbGxsbGxsbGxsbGxsbGxsbGxsbGxsbGxsbGxsbGxsbGxsb/wAARCAABAAEDASIAAhEBAxEB/8QAFQABAQAAAAAAAAAAAAAAAAAAAAb/xAAUEAEAAAAAAAAAAAAAAAAAAAAA/8QAFAEBAAAAAAAAAAAAAAAAAAAAAP/EABQRAQAAAAAAAAAAAAAAAAAAAAD/2gAMAwEAAhEDEQA/AKAAH//Z');}.data .no-quote{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACEAAAAEAQAAAAAo/mtHAAAAIElEQVQIHWMRnWHwcRNLN8NZ7QYWwT8PlBlYsgqVBRsAankIMw5MtnoAAAAASUVORK5CYII=);}
|
||||
p,select{font:1em/160% Verdana,sans-serif;color:#494949;}
|
||||
body{margin:0;padding:0;background:#edf5fa;font:76%/170% Verdana,sans-serif;color:#494949;}.this .is .a .test{font:1em/100% Verdana,sans-serif;color:#494949;}.this
|
||||
.is
|
||||
|
@@ -7,6 +7,21 @@ ul, select {
|
||||
}
|
||||
.ui-icon{background-image: url(../images/icon.png);}
|
||||
|
||||
/* Test data URI images with different quote styles. */
|
||||
.data .double-quote {
|
||||
/* http://stackoverflow.com/a/13139830/11023 */
|
||||
background-image: url("data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7");
|
||||
}
|
||||
|
||||
.data .single-quote {
|
||||
background-image: url('data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDACAWGBwYFCAcGhwkIiAmMFA0MCwsMGJGSjpQdGZ6eHJmcG6AkLicgIiuim5woNqirr7EztDOfJri8uDI8LjKzsb/2wBDASIkJDAqMF40NF7GhHCExsbGxsbGxsbGxsbGxsbGxsbGxsbGxsbGxsbGxsbGxsbGxsbGxsbGxsbGxsbGxsbGxsb/wAARCAABAAEDASIAAhEBAxEB/8QAFQABAQAAAAAAAAAAAAAAAAAAAAb/xAAUEAEAAAAAAAAAAAAAAAAAAAAA/8QAFAEBAAAAAAAAAAAAAAAAAAAAAP/EABQRAQAAAAAAAAAAAAAAAAAAAAD/2gAMAwEAAhEDEQA/AKAAH//Z');
|
||||
}
|
||||
|
||||
.data .no-quote {
|
||||
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACEAAAAEAQAAAAAo/mtHAAAAIElEQVQIHWMRnWHwcRNLN8NZ7QYWwT8PlBlYsgqVBRsAankIMw5MtnoAAAAASUVORK5CYII=);
|
||||
}
|
||||
|
||||
|
||||
p, select {
|
||||
font: 1em/160% Verdana, sans-serif;
|
||||
color: #494949;
|
||||
|
@@ -3,4 +3,18 @@ ul, select {
|
||||
font: 1em/160% Verdana, sans-serif;
|
||||
color: #494949;
|
||||
}
|
||||
.ui-icon{background-image: url(images/icon.png);}
|
||||
.ui-icon{background-image: url(images/icon.png);}
|
||||
|
||||
/* Test data URI images with different quote styles. */
|
||||
.data .double-quote {
|
||||
/* http://stackoverflow.com/a/13139830/11023 */
|
||||
background-image: url("data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7");
|
||||
}
|
||||
|
||||
.data .single-quote {
|
||||
background-image: url('data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDACAWGBwYFCAcGhwkIiAmMFA0MCwsMGJGSjpQdGZ6eHJmcG6AkLicgIiuim5woNqirr7EztDOfJri8uDI8LjKzsb/2wBDASIkJDAqMF40NF7GhHCExsbGxsbGxsbGxsbGxsbGxsbGxsbGxsbGxsbGxsbGxsbGxsbGxsbGxsbGxsbGxsbGxsb/wAARCAABAAEDASIAAhEBAxEB/8QAFQABAQAAAAAAAAAAAAAAAAAAAAb/xAAUEAEAAAAAAAAAAAAAAAAAAAAA/8QAFAEBAAAAAAAAAAAAAAAAAAAAAP/EABQRAQAAAAAAAAAAAAAAAAAAAAD/2gAMAwEAAhEDEQA/AKAAH//Z');
|
||||
}
|
||||
|
||||
.data .no-quote {
|
||||
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACEAAAAEAQAAAAAo/mtHAAAAIElEQVQIHWMRnWHwcRNLN8NZ7QYWwT8PlBlYsgqVBRsAankIMw5MtnoAAAAASUVORK5CYII=);
|
||||
}
|
||||
|
BIN
modules/simpletest/files/image-test-transparent-out-of-range.gif
Normal file
BIN
modules/simpletest/files/image-test-transparent-out-of-range.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 183 B |
@@ -56,8 +56,8 @@ files[] = tests/upgrade/update.trigger.test
|
||||
files[] = tests/upgrade/update.field.test
|
||||
files[] = tests/upgrade/update.user.test
|
||||
|
||||
; Information added by Drupal.org packaging script on 2014-05-08
|
||||
version = "7.28"
|
||||
; Information added by Drupal.org packaging script on 2015-04-02
|
||||
version = "7.36"
|
||||
project = "drupal"
|
||||
datestamp = "1399522731"
|
||||
datestamp = "1427943826"
|
||||
|
||||
|
@@ -328,25 +328,32 @@ function simpletest_test_get_all() {
|
||||
// Also discover PSR-0 test classes, if the PHP version allows it.
|
||||
if (version_compare(PHP_VERSION, '5.3') > 0) {
|
||||
|
||||
// Select all PSR-0 classes in the Tests namespace of all modules.
|
||||
// Select all PSR-0 and PSR-4 classes in the Tests namespace of all
|
||||
// modules.
|
||||
$system_list = db_query("SELECT name, filename FROM {system}")->fetchAllKeyed();
|
||||
|
||||
foreach ($system_list as $name => $filename) {
|
||||
// Build directory in which the test files would reside.
|
||||
$tests_dir = DRUPAL_ROOT . '/' . dirname($filename) . '/lib/Drupal/' . $name . '/Tests';
|
||||
// Scan it for test files if it exists.
|
||||
if (is_dir($tests_dir)) {
|
||||
$files = file_scan_directory($tests_dir, '/.*\.php/');
|
||||
if (!empty($files)) {
|
||||
$basedir = DRUPAL_ROOT . '/' . dirname($filename) . '/lib/';
|
||||
foreach ($files as $file) {
|
||||
// Convert the file name into the namespaced class name.
|
||||
$replacements = array(
|
||||
'/' => '\\',
|
||||
$basedir => '',
|
||||
'.php' => '',
|
||||
);
|
||||
$classes[] = strtr($file->uri, $replacements);
|
||||
$module_dir = DRUPAL_ROOT . '/' . dirname($filename);
|
||||
// Search both the 'lib/Drupal/mymodule' directory (for PSR-0 classes)
|
||||
// and the 'src' directory (for PSR-4 classes).
|
||||
foreach(array('lib/Drupal/' . $name, 'src') as $subdir) {
|
||||
// Build directory in which the test files would reside.
|
||||
$tests_dir = $module_dir . '/' . $subdir . '/Tests';
|
||||
// Scan it for test files if it exists.
|
||||
if (is_dir($tests_dir)) {
|
||||
$files = file_scan_directory($tests_dir, '/.*\.php/');
|
||||
if (!empty($files)) {
|
||||
foreach ($files as $file) {
|
||||
// Convert the file name into the namespaced class name.
|
||||
$replacements = array(
|
||||
'/' => '\\',
|
||||
$module_dir . '/' => '',
|
||||
'lib/' => '',
|
||||
'src/' => 'Drupal\\' . $name . '\\',
|
||||
'.php' => '',
|
||||
);
|
||||
$classes[] = strtr($file->uri, $replacements);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -406,17 +413,20 @@ function simpletest_classloader_register() {
|
||||
|
||||
// Only register PSR-0 class loading if we are on PHP 5.3 or higher.
|
||||
if (version_compare(PHP_VERSION, '5.3') > 0) {
|
||||
spl_autoload_register('_simpletest_autoload_psr0');
|
||||
spl_autoload_register('_simpletest_autoload_psr4_psr0');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Autoload callback to find PSR-0 test classes.
|
||||
* Autoload callback to find PSR-4 and PSR-0 test classes.
|
||||
*
|
||||
* Looks in the 'src/Tests' and in the 'lib/Drupal/mymodule/Tests' directory of
|
||||
* modules for the class.
|
||||
*
|
||||
* This will only work on classes where the namespace is of the pattern
|
||||
* "Drupal\$extension\Tests\.."
|
||||
*/
|
||||
function _simpletest_autoload_psr0($class) {
|
||||
function _simpletest_autoload_psr4_psr0($class) {
|
||||
|
||||
// Static cache for extension paths.
|
||||
// This cache is lazily filled as soon as it is needed.
|
||||
@@ -446,14 +456,26 @@ function _simpletest_autoload_psr0($class) {
|
||||
$namespace = substr($class, 0, $nspos);
|
||||
$classname = substr($class, $nspos + 1);
|
||||
|
||||
// Build the filepath where we expect the class to be defined.
|
||||
$path = dirname($extensions[$extension]) . '/lib/' .
|
||||
str_replace('\\', '/', $namespace) . '/' .
|
||||
// Try the PSR-4 location first, and the PSR-0 location as a fallback.
|
||||
// Build the PSR-4 filepath where we expect the class to be defined.
|
||||
$psr4_path = dirname($extensions[$extension]) . '/src/' .
|
||||
str_replace('\\', '/', substr($namespace, strlen('Drupal\\' . $extension . '\\'))) . '/' .
|
||||
str_replace('_', '/', $classname) . '.php';
|
||||
|
||||
// Include the file, if it does exist.
|
||||
if (file_exists($path)) {
|
||||
include $path;
|
||||
if (file_exists($psr4_path)) {
|
||||
include $psr4_path;
|
||||
}
|
||||
else {
|
||||
// Build the PSR-0 filepath where we expect the class to be defined.
|
||||
$psr0_path = dirname($extensions[$extension]) . '/lib/' .
|
||||
str_replace('\\', '/', $namespace) . '/' .
|
||||
str_replace('_', '/', $classname) . '.php';
|
||||
|
||||
// Include the file, if it does exist.
|
||||
if (file_exists($psr0_path)) {
|
||||
include $psr0_path;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -703,7 +703,9 @@ class SimpleTestDiscoveryTestCase extends DrupalWebTestCase {
|
||||
$classes_all = simpletest_test_get_all();
|
||||
foreach (array(
|
||||
'Drupal\\simpletest\\Tests\\PSR0WebTest',
|
||||
'Drupal\\simpletest\\Tests\\PSR4WebTest',
|
||||
'Drupal\\psr_0_test\\Tests\\ExampleTest',
|
||||
'Drupal\\psr_4_test\\Tests\\ExampleTest',
|
||||
) as $class) {
|
||||
$this->assert(!empty($classes_all['SimpleTest'][$class]), t('Class @class must be discovered by simpletest_test_get_all().', array('@class' => $class)));
|
||||
}
|
||||
@@ -726,15 +728,20 @@ class SimpleTestDiscoveryTestCase extends DrupalWebTestCase {
|
||||
// Don't expect PSR-0 tests to be discovered on older PHP versions.
|
||||
return;
|
||||
}
|
||||
// This one is provided by simpletest itself via PSR-0.
|
||||
// These are provided by simpletest itself via PSR-0 and PSR-4.
|
||||
$this->assertText('PSR0 web test');
|
||||
$this->assertText('PSR4 web test');
|
||||
$this->assertText('PSR0 example test: PSR-0 in disabled modules.');
|
||||
$this->assertText('PSR4 example test: PSR-4 in disabled modules.');
|
||||
$this->assertText('PSR0 example test: PSR-0 in nested subfolders.');
|
||||
$this->assertText('PSR4 example test: PSR-4 in nested subfolders.');
|
||||
|
||||
// Test each test individually.
|
||||
foreach (array(
|
||||
'Drupal\\psr_0_test\\Tests\\ExampleTest',
|
||||
'Drupal\\psr_0_test\\Tests\\Nested\\NestedExampleTest',
|
||||
'Drupal\\psr_4_test\\Tests\\ExampleTest',
|
||||
'Drupal\\psr_4_test\\Tests\\Nested\\NestedExampleTest',
|
||||
) as $class) {
|
||||
$this->drupalGet('admin/config/development/testing');
|
||||
$edit = array($class => TRUE);
|
||||
|
18
modules/simpletest/src/Tests/PSR4WebTest.php
Normal file
18
modules/simpletest/src/Tests/PSR4WebTest.php
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\simpletest\Tests;
|
||||
|
||||
class PSR4WebTest extends \DrupalWebTestCase {
|
||||
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'PSR4 web test',
|
||||
'description' => 'We want to assert that this PSR-4 test case is being discovered.',
|
||||
'group' => 'SimpleTest',
|
||||
);
|
||||
}
|
||||
|
||||
function testArithmetics() {
|
||||
$this->assert(1 + 1 == 2, '1 + 1 == 2');
|
||||
}
|
||||
}
|
@@ -5,8 +5,8 @@ version = VERSION
|
||||
core = 7.x
|
||||
hidden = TRUE
|
||||
|
||||
; Information added by Drupal.org packaging script on 2014-05-08
|
||||
version = "7.28"
|
||||
; Information added by Drupal.org packaging script on 2015-04-02
|
||||
version = "7.36"
|
||||
project = "drupal"
|
||||
datestamp = "1399522731"
|
||||
datestamp = "1427943826"
|
||||
|
||||
|
@@ -293,7 +293,7 @@ class AJAXCommandsTestCase extends AJAXTestCase {
|
||||
$this->assertCommand($commands, $expected, "'changed' AJAX command (with asterisk) issued with correct selector");
|
||||
|
||||
// Tests the 'css' command.
|
||||
$commands = $this->drupalPostAJAX($form_path, $edit, array('op' => t("Set the the '#box' div to be blue.")));
|
||||
$commands = $this->drupalPostAJAX($form_path, $edit, array('op' => t("Set the '#box' div to be blue.")));
|
||||
$expected = array(
|
||||
'command' => 'css',
|
||||
'selector' => '#css_div',
|
||||
@@ -368,6 +368,14 @@ class AJAXCommandsTestCase extends AJAXTestCase {
|
||||
'settings' => array('ajax_forms_test' => array('foo' => 42)),
|
||||
);
|
||||
$this->assertCommand($commands, $expected, "'settings' AJAX command issued with correct data");
|
||||
|
||||
// Tests the 'add_css' command.
|
||||
$commands = $this->drupalPostAJAX($form_path, $edit, array('op' => t("AJAX 'add_css' command")));
|
||||
$expected = array(
|
||||
'command' => 'add_css',
|
||||
'data' => 'my/file.css',
|
||||
);
|
||||
$this->assertCommand($commands, $expected, "'add_css' AJAX command issued with correct data");
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -5,8 +5,8 @@ package = Testing
|
||||
version = VERSION
|
||||
hidden = TRUE
|
||||
|
||||
; Information added by Drupal.org packaging script on 2014-05-08
|
||||
version = "7.28"
|
||||
; Information added by Drupal.org packaging script on 2015-04-02
|
||||
version = "7.36"
|
||||
project = "drupal"
|
||||
datestamp = "1399522731"
|
||||
datestamp = "1427943826"
|
||||
|
||||
|
@@ -157,7 +157,7 @@ function ajax_forms_test_ajax_commands_form($form, &$form_state) {
|
||||
|
||||
// Shows the Ajax 'css' command.
|
||||
$form['css_command_example'] = array(
|
||||
'#value' => t("Set the the '#box' div to be blue."),
|
||||
'#value' => t("Set the '#box' div to be blue."),
|
||||
'#type' => 'submit',
|
||||
'#ajax' => array(
|
||||
'callback' => 'ajax_forms_test_advanced_commands_css_callback',
|
||||
@@ -254,6 +254,15 @@ function ajax_forms_test_ajax_commands_form($form, &$form_state) {
|
||||
),
|
||||
);
|
||||
|
||||
// Shows the Ajax 'add_css' command.
|
||||
$form['add_css_command_example'] = array(
|
||||
'#type' => 'submit',
|
||||
'#value' => t("AJAX 'add_css' command"),
|
||||
'#ajax' => array(
|
||||
'callback' => 'ajax_forms_test_advanced_commands_add_css_callback',
|
||||
),
|
||||
);
|
||||
|
||||
$form['submit'] = array(
|
||||
'#type' => 'submit',
|
||||
'#value' => t('Submit'),
|
||||
@@ -406,6 +415,15 @@ function ajax_forms_test_advanced_commands_settings_callback($form, $form_state)
|
||||
return array('#type' => 'ajax', '#commands' => $commands);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax callback for 'add_css'.
|
||||
*/
|
||||
function ajax_forms_test_advanced_commands_add_css_callback($form, $form_state) {
|
||||
$commands = array();
|
||||
$commands[] = ajax_command_add_css('my/file.css');
|
||||
return array('#type' => 'ajax', '#commands' => $commands);
|
||||
}
|
||||
|
||||
/**
|
||||
* This form and its related submit and callback functions demonstrate
|
||||
* not validating another form element when a single Ajax element is triggered.
|
||||
|
@@ -5,8 +5,8 @@ version = VERSION
|
||||
core = 7.x
|
||||
hidden = TRUE
|
||||
|
||||
; Information added by Drupal.org packaging script on 2014-05-08
|
||||
version = "7.28"
|
||||
; Information added by Drupal.org packaging script on 2015-04-02
|
||||
version = "7.36"
|
||||
project = "drupal"
|
||||
datestamp = "1399522731"
|
||||
datestamp = "1427943826"
|
||||
|
||||
|
@@ -5,8 +5,8 @@ version = VERSION
|
||||
core = 7.x
|
||||
hidden = TRUE
|
||||
|
||||
; Information added by Drupal.org packaging script on 2014-05-08
|
||||
version = "7.28"
|
||||
; Information added by Drupal.org packaging script on 2015-04-02
|
||||
version = "7.36"
|
||||
project = "drupal"
|
||||
datestamp = "1399522731"
|
||||
datestamp = "1427943826"
|
||||
|
||||
|
@@ -93,6 +93,11 @@ class BootstrapIPAddressTestCase extends DrupalWebTestCase {
|
||||
$this->assertFalse(drupal_valid_http_host('security\\.drupal.org:80'), 'HTTP_HOST with \\ is invalid');
|
||||
$this->assertFalse(drupal_valid_http_host('security<.drupal.org:80'), 'HTTP_HOST with < is invalid');
|
||||
$this->assertFalse(drupal_valid_http_host('security..drupal.org:80'), 'HTTP_HOST with .. is invalid');
|
||||
// Verifies that host names are shorter than 1000 characters.
|
||||
$this->assertFalse(drupal_valid_http_host(str_repeat('x', 1001)), 'HTTP_HOST with more than 1000 characters is invalid.');
|
||||
$this->assertFalse(drupal_valid_http_host(str_repeat('.', 101)), 'HTTP_HOST with more than 100 subdomains is invalid.');
|
||||
$this->assertFalse(drupal_valid_http_host(str_repeat(':', 101)), 'HTTP_HOST with more than 100 portseparators is invalid.');
|
||||
|
||||
// IPv6 loopback address
|
||||
$this->assertTrue(drupal_valid_http_host('[::1]:80'), 'HTTP_HOST containing IPv6 loopback is valid');
|
||||
}
|
||||
@@ -139,7 +144,7 @@ class BootstrapPageCacheTestCase extends DrupalWebTestCase {
|
||||
$this->assertResponse(200, 'Conditional request without If-None-Match returned 200 OK.');
|
||||
$this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'HIT', 'Page was cached.');
|
||||
|
||||
$this->drupalGet('', array(), array('If-Modified-Since: ' . gmdate(DATE_RFC1123, strtotime($last_modified) + 1), 'If-None-Match: ' . $etag));
|
||||
$this->drupalGet('', array(), array('If-Modified-Since: ' . gmdate(DATE_RFC7231, strtotime($last_modified) + 1), 'If-None-Match: ' . $etag));
|
||||
$this->assertResponse(200, 'Conditional request with new a If-Modified-Since date newer than Last-Modified returned 200 OK.');
|
||||
$this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'HIT', 'Page was cached.');
|
||||
|
||||
@@ -148,6 +153,8 @@ class BootstrapPageCacheTestCase extends DrupalWebTestCase {
|
||||
$this->drupalGet('', array(), array('If-Modified-Since: ' . $last_modified, 'If-None-Match: ' . $etag));
|
||||
$this->assertResponse(200, 'Conditional request returned 200 OK for authenticated user.');
|
||||
$this->assertFalse($this->drupalGetHeader('X-Drupal-Cache'), 'Absense of Page was not cached.');
|
||||
$this->assertFalse($this->drupalGetHeader('ETag'), 'ETag HTTP headers are not present for logged in users.');
|
||||
$this->assertFalse($this->drupalGetHeader('Last-Modified'), 'Last-Modified HTTP headers are not present for logged in users.');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -281,6 +288,35 @@ class BootstrapVariableTestCase extends DrupalWebTestCase {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the auto-loading behavior of the code registry.
|
||||
*/
|
||||
class BootstrapAutoloadTestCase extends DrupalWebTestCase {
|
||||
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Code registry',
|
||||
'description' => 'Test that the code registry functions correctly.',
|
||||
'group' => 'Bootstrap',
|
||||
);
|
||||
}
|
||||
|
||||
function setUp() {
|
||||
parent::setUp('drupal_autoload_test');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that autoloader name matching is not case sensitive.
|
||||
*/
|
||||
function testAutoloadCase() {
|
||||
// Test interface autoloader.
|
||||
$this->assertTrue(drupal_autoload_interface('drupalautoloadtestinterface'), 'drupal_autoload_interface() recognizes <em>DrupalAutoloadTestInterface</em> in lower case.');
|
||||
// Test class autoloader.
|
||||
$this->assertTrue(drupal_autoload_class('drupalautoloadtestclass'), 'drupal_autoload_class() recognizes <em>DrupalAutoloadTestClass</em> in lower case.');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Test hook_boot() and hook_exit().
|
||||
*/
|
||||
@@ -541,3 +577,85 @@ class BootstrapOverrideServerVariablesTestCase extends DrupalUnitTestCase {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests for $_GET['destination'] and $_REQUEST['destination'] validation.
|
||||
*/
|
||||
class BootstrapDestinationTestCase extends DrupalWebTestCase {
|
||||
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'URL destination validation',
|
||||
'description' => 'Test that $_GET[\'destination\'] and $_REQUEST[\'destination\'] cannot contain external URLs.',
|
||||
'group' => 'Bootstrap',
|
||||
);
|
||||
}
|
||||
|
||||
function setUp() {
|
||||
parent::setUp('system_test');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that $_GET/$_REQUEST['destination'] only contain internal URLs.
|
||||
*
|
||||
* @see _drupal_bootstrap_variables()
|
||||
* @see system_test_get_destination()
|
||||
* @see system_test_request_destination()
|
||||
*/
|
||||
public function testDestination() {
|
||||
$test_cases = array(
|
||||
array(
|
||||
'input' => 'node',
|
||||
'output' => 'node',
|
||||
'message' => "Standard internal example node path is present in the 'destination' parameter.",
|
||||
),
|
||||
array(
|
||||
'input' => '/example.com',
|
||||
'output' => '/example.com',
|
||||
'message' => 'Internal path with one leading slash is allowed.',
|
||||
),
|
||||
array(
|
||||
'input' => '//example.com/test',
|
||||
'output' => '',
|
||||
'message' => 'External URL without scheme is not allowed.',
|
||||
),
|
||||
array(
|
||||
'input' => 'example:test',
|
||||
'output' => 'example:test',
|
||||
'message' => 'Internal URL using a colon is allowed.',
|
||||
),
|
||||
array(
|
||||
'input' => 'http://example.com',
|
||||
'output' => '',
|
||||
'message' => 'External URL is not allowed.',
|
||||
),
|
||||
array(
|
||||
'input' => 'javascript:alert(0)',
|
||||
'output' => 'javascript:alert(0)',
|
||||
'message' => 'Javascript URL is allowed because it is treated as an internal URL.',
|
||||
),
|
||||
);
|
||||
foreach ($test_cases as $test_case) {
|
||||
// Test $_GET['destination'].
|
||||
$this->drupalGet('system-test/get-destination', array('query' => array('destination' => $test_case['input'])));
|
||||
$this->assertIdentical($test_case['output'], $this->drupalGetContent(), $test_case['message']);
|
||||
// Test $_REQUEST['destination']. There's no form to submit to, so
|
||||
// drupalPost() won't work here; this just tests a direct $_POST request
|
||||
// instead.
|
||||
$curl_parameters = array(
|
||||
CURLOPT_URL => $this->getAbsoluteUrl('system-test/request-destination'),
|
||||
CURLOPT_POST => TRUE,
|
||||
CURLOPT_POSTFIELDS => 'destination=' . urlencode($test_case['input']),
|
||||
CURLOPT_HTTPHEADER => array(),
|
||||
);
|
||||
$post_output = $this->curlExec($curl_parameters);
|
||||
$this->assertIdentical($test_case['output'], $post_output, $test_case['message']);
|
||||
}
|
||||
|
||||
// Make sure that 404 pages do not populate $_GET['destination'] with
|
||||
// external URLs.
|
||||
variable_set('site_404', 'system-test/get-destination');
|
||||
$this->drupalGet('http://example.com', array('external' => FALSE));
|
||||
$this->assertIdentical('', $this->drupalGetContent(), 'External URL is not allowed on 404 pages.');
|
||||
}
|
||||
}
|
||||
|
@@ -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');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -7,8 +7,8 @@ stylesheets[all][] = common_test.css
|
||||
stylesheets[print][] = common_test.print.css
|
||||
hidden = TRUE
|
||||
|
||||
; Information added by Drupal.org packaging script on 2014-05-08
|
||||
version = "7.28"
|
||||
; Information added by Drupal.org packaging script on 2015-04-02
|
||||
version = "7.36"
|
||||
project = "drupal"
|
||||
datestamp = "1399522731"
|
||||
datestamp = "1427943826"
|
||||
|
||||
|
@@ -5,8 +5,8 @@ version = VERSION
|
||||
core = 7.x
|
||||
hidden = TRUE
|
||||
|
||||
; Information added by Drupal.org packaging script on 2014-05-08
|
||||
version = "7.28"
|
||||
; Information added by Drupal.org packaging script on 2015-04-02
|
||||
version = "7.36"
|
||||
project = "drupal"
|
||||
datestamp = "1399522731"
|
||||
datestamp = "1427943826"
|
||||
|
||||
|
@@ -5,8 +5,8 @@ package = Testing
|
||||
version = VERSION
|
||||
hidden = TRUE
|
||||
|
||||
; Information added by Drupal.org packaging script on 2014-05-08
|
||||
version = "7.28"
|
||||
; Information added by Drupal.org packaging script on 2015-04-02
|
||||
version = "7.36"
|
||||
project = "drupal"
|
||||
datestamp = "1399522731"
|
||||
datestamp = "1427943826"
|
||||
|
||||
|
@@ -238,7 +238,7 @@ class DatabaseConnectionTestCase extends DatabaseTestCase {
|
||||
// Open the default target so we have an object to compare.
|
||||
$db1 = Database::getConnection('default', 'default');
|
||||
|
||||
// Try to close the the default connection, then open a new one.
|
||||
// Try to close the default connection, then open a new one.
|
||||
Database::closeConnection('default', 'default');
|
||||
$db2 = Database::getConnection('default', 'default');
|
||||
|
||||
@@ -1947,6 +1947,15 @@ class DatabaseSelectOrderedTestCase extends DatabaseTestCase {
|
||||
|
||||
$this->assertEqual($num_records, 4, 'Returned the correct number of rows.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that the sort direction is sanitized properly.
|
||||
*/
|
||||
function testOrderByEscaping() {
|
||||
$query = db_select('test')->orderBy('name', 'invalid direction');
|
||||
$order_bys = $query->getOrderBy();
|
||||
$this->assertEqual($order_bys['name'], 'ASC', 'Invalid order by direction is converted to ASC.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -3384,6 +3393,34 @@ class DatabaseQueryTestCase extends DatabaseTestCase {
|
||||
|
||||
$this->assertEqual(count($names), 3, 'Correct number of names returned');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test SQL injection via database query array arguments.
|
||||
*/
|
||||
public function testArrayArgumentsSQLInjection() {
|
||||
// Attempt SQL injection and verify that it does not work.
|
||||
$condition = array(
|
||||
"1 ;INSERT INTO {test} (name) VALUES ('test12345678'); -- " => '',
|
||||
'1' => '',
|
||||
);
|
||||
try {
|
||||
db_query("SELECT * FROM {test} WHERE name = :name", array(':name' => $condition))->fetchObject();
|
||||
$this->fail('SQL injection attempt via array arguments should result in a PDOException.');
|
||||
}
|
||||
catch (PDOException $e) {
|
||||
$this->pass('SQL injection attempt via array arguments should result in a PDOException.');
|
||||
}
|
||||
|
||||
// Test that the insert query that was used in the SQL injection attempt did
|
||||
// not result in a row being inserted in the database.
|
||||
$result = db_select('test')
|
||||
->condition('name', 'test12345678')
|
||||
->countQuery()
|
||||
->execute()
|
||||
->fetchField();
|
||||
$this->assertFalse($result, 'SQL injection attempt did not result in a row being inserted in the database table.');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -3417,12 +3454,14 @@ class DatabaseTransactionTestCase extends DatabaseTestCase {
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method for transaction unit test. This "outer layer" transaction
|
||||
* starts and then encapsulates the "inner layer" transaction. This nesting
|
||||
* is used to evaluate whether the the database transaction API properly
|
||||
* supports nesting. By "properly supports," we mean the outer transaction
|
||||
* continues to exist regardless of what functions are called and whether
|
||||
* those functions start their own transactions.
|
||||
* Helper method for transaction unit test.
|
||||
*
|
||||
* This "outer layer" transaction starts and then encapsulates the
|
||||
* "inner layer" transaction. This nesting is used to evaluate whether the
|
||||
* database transaction API properly supports nesting. By "properly supports,"
|
||||
* we mean the outer transaction continues to exist regardless of what
|
||||
* functions are called and whether those functions start their own
|
||||
* transactions.
|
||||
*
|
||||
* In contrast, a typical database would commit the outer transaction, start
|
||||
* a new transaction for the inner layer, commit the inner layer transaction,
|
||||
|
@@ -0,0 +1,14 @@
|
||||
name = "Drupal code registry test"
|
||||
description = "Support module for testing the code registry."
|
||||
files[] = drupal_autoload_test_interface.inc
|
||||
files[] = drupal_autoload_test_class.inc
|
||||
package = Testing
|
||||
version = VERSION
|
||||
core = 7.x
|
||||
hidden = TRUE
|
||||
|
||||
; Information added by Drupal.org packaging script on 2015-04-02
|
||||
version = "7.36"
|
||||
project = "drupal"
|
||||
datestamp = "1427943826"
|
||||
|
@@ -0,0 +1,6 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Test module to check code registry.
|
||||
*/
|
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Test classes for code registry testing.
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class is empty because we only care if Drupal can find it.
|
||||
*/
|
||||
class DrupalAutoloadTestClass implements DrupalAutoloadTestInterface {}
|
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Test interfaces for code registry testing.
|
||||
*/
|
||||
|
||||
/**
|
||||
* This interface is empty because we only care if Drupal can find it.
|
||||
*/
|
||||
interface DrupalAutoloadTestInterface {}
|
@@ -5,8 +5,8 @@ version = VERSION
|
||||
core = 7.x
|
||||
hidden = TRUE
|
||||
|
||||
; Information added by Drupal.org packaging script on 2014-05-08
|
||||
version = "7.28"
|
||||
; Information added by Drupal.org packaging script on 2015-04-02
|
||||
version = "7.36"
|
||||
project = "drupal"
|
||||
datestamp = "1399522731"
|
||||
datestamp = "1427943826"
|
||||
|
||||
|
@@ -5,8 +5,8 @@ version = VERSION
|
||||
core = 7.x
|
||||
hidden = TRUE
|
||||
|
||||
; Information added by Drupal.org packaging script on 2014-05-08
|
||||
version = "7.28"
|
||||
; Information added by Drupal.org packaging script on 2015-04-02
|
||||
version = "7.36"
|
||||
project = "drupal"
|
||||
datestamp = "1399522731"
|
||||
datestamp = "1427943826"
|
||||
|
||||
|
@@ -6,8 +6,8 @@ core = 7.x
|
||||
dependencies[] = entity_cache_test_dependency
|
||||
hidden = TRUE
|
||||
|
||||
; Information added by Drupal.org packaging script on 2014-05-08
|
||||
version = "7.28"
|
||||
; Information added by Drupal.org packaging script on 2015-04-02
|
||||
version = "7.36"
|
||||
project = "drupal"
|
||||
datestamp = "1399522731"
|
||||
datestamp = "1427943826"
|
||||
|
||||
|
@@ -5,8 +5,8 @@ version = VERSION
|
||||
core = 7.x
|
||||
hidden = TRUE
|
||||
|
||||
; Information added by Drupal.org packaging script on 2014-05-08
|
||||
version = "7.28"
|
||||
; Information added by Drupal.org packaging script on 2015-04-02
|
||||
version = "7.36"
|
||||
project = "drupal"
|
||||
datestamp = "1399522731"
|
||||
datestamp = "1427943826"
|
||||
|
||||
|
@@ -5,8 +5,8 @@ package = Testing
|
||||
version = VERSION
|
||||
hidden = TRUE
|
||||
|
||||
; Information added by Drupal.org packaging script on 2014-05-08
|
||||
version = "7.28"
|
||||
; Information added by Drupal.org packaging script on 2015-04-02
|
||||
version = "7.36"
|
||||
project = "drupal"
|
||||
datestamp = "1399522731"
|
||||
datestamp = "1427943826"
|
||||
|
||||
|
@@ -5,8 +5,8 @@ version = VERSION
|
||||
core = 7.x
|
||||
hidden = TRUE
|
||||
|
||||
; Information added by Drupal.org packaging script on 2014-05-08
|
||||
version = "7.28"
|
||||
; Information added by Drupal.org packaging script on 2015-04-02
|
||||
version = "7.36"
|
||||
project = "drupal"
|
||||
datestamp = "1399522731"
|
||||
datestamp = "1427943826"
|
||||
|
||||
|
@@ -5,8 +5,8 @@ version = VERSION
|
||||
core = 7.x
|
||||
hidden = TRUE
|
||||
|
||||
; Information added by Drupal.org packaging script on 2014-05-08
|
||||
version = "7.28"
|
||||
; Information added by Drupal.org packaging script on 2015-04-02
|
||||
version = "7.36"
|
||||
project = "drupal"
|
||||
datestamp = "1399522731"
|
||||
datestamp = "1427943826"
|
||||
|
||||
|
@@ -484,14 +484,6 @@ class FileValidatorTest extends DrupalWebTestCase {
|
||||
$original_user = $user;
|
||||
drupal_save_session(FALSE);
|
||||
|
||||
// Run these test as uid = 1.
|
||||
$user = user_load(1);
|
||||
|
||||
$file = new stdClass();
|
||||
$file->filesize = 999999;
|
||||
$errors = file_validate_size($file, 1, 1);
|
||||
$this->assertEqual(count($errors), 0, 'No size limits enforced on uid=1.', 'File');
|
||||
|
||||
// Run these tests as a regular user.
|
||||
$user = $this->drupalCreateUser();
|
||||
|
||||
@@ -2564,6 +2556,7 @@ class FileNameMungingTest extends FileTestCase {
|
||||
parent::setUp();
|
||||
$this->bad_extension = 'php';
|
||||
$this->name = $this->randomName() . '.' . $this->bad_extension . '.txt';
|
||||
$this->name_with_uc_ext = $this->randomName() . '.' . strtoupper($this->bad_extension) . '.txt';
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2601,9 +2594,13 @@ class FileNameMungingTest extends FileTestCase {
|
||||
* White listed extensions are ignored by file_munge_filename().
|
||||
*/
|
||||
function testMungeIgnoreWhitelisted() {
|
||||
// Declare our extension as whitelisted.
|
||||
$munged_name = file_munge_filename($this->name, $this->bad_extension);
|
||||
$this->assertIdentical($munged_name, $this->name, format_string('The new filename (%munged) matches the original (%original) once the extension has been whitelisted.', array('%munged' => $munged_name, '%original' => $this->name)));
|
||||
// Declare our extension as whitelisted. The declared extensions should
|
||||
// be case insensitive so test using one with a different case.
|
||||
$munged_name = file_munge_filename($this->name_with_uc_ext, $this->bad_extension);
|
||||
$this->assertIdentical($munged_name, $this->name_with_uc_ext, format_string('The new filename (%munged) matches the original (%original) once the extension has been whitelisted.', array('%munged' => $munged_name, '%original' => $this->name_with_uc_ext)));
|
||||
// The allowed extensions should also be normalized.
|
||||
$munged_name = file_munge_filename($this->name, strtoupper($this->bad_extension));
|
||||
$this->assertIdentical($munged_name, $this->name, format_string('The new filename (%munged) matches the original (%original) also when the whitelisted extension is in uppercase.', array('%munged' => $munged_name, '%original' => $this->name)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -6,8 +6,8 @@ core = 7.x
|
||||
files[] = file_test.module
|
||||
hidden = TRUE
|
||||
|
||||
; Information added by Drupal.org packaging script on 2014-05-08
|
||||
version = "7.28"
|
||||
; Information added by Drupal.org packaging script on 2015-04-02
|
||||
version = "7.36"
|
||||
project = "drupal"
|
||||
datestamp = "1399522731"
|
||||
datestamp = "1427943826"
|
||||
|
||||
|
@@ -5,8 +5,8 @@ version = VERSION
|
||||
core = 7.x
|
||||
hidden = TRUE
|
||||
|
||||
; Information added by Drupal.org packaging script on 2014-05-08
|
||||
version = "7.28"
|
||||
; Information added by Drupal.org packaging script on 2015-04-02
|
||||
version = "7.36"
|
||||
project = "drupal"
|
||||
datestamp = "1399522731"
|
||||
datestamp = "1427943826"
|
||||
|
||||
|
@@ -470,6 +470,64 @@ class FormsTestCase extends DrupalWebTestCase {
|
||||
$this->drupalPost(NULL, array('checkboxes[one]' => TRUE, 'checkboxes[two]' => TRUE), t('Submit'));
|
||||
$this->assertText('An illegal choice has been detected.', 'Input forgery was detected.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that submitted values are converted to scalar strings for textfields.
|
||||
*/
|
||||
public function testTextfieldStringValue() {
|
||||
// Check multivalued submissions.
|
||||
$multivalue = array('evil' => 'multivalue', 'not so' => 'good');
|
||||
$this->checkFormValue('textfield', $multivalue, '');
|
||||
$this->checkFormValue('password', $multivalue, '');
|
||||
$this->checkFormValue('textarea', $multivalue, '');
|
||||
$this->checkFormValue('machine_name', $multivalue, '');
|
||||
$this->checkFormValue('password_confirm', $multivalue, array('pass1' => '', 'pass2' => ''));
|
||||
// Check integer submissions.
|
||||
$integer = 5;
|
||||
$string = '5';
|
||||
$this->checkFormValue('textfield', $integer, $string);
|
||||
$this->checkFormValue('password', $integer, $string);
|
||||
$this->checkFormValue('textarea', $integer, $string);
|
||||
$this->checkFormValue('machine_name', $integer, $string);
|
||||
$this->checkFormValue('password_confirm', array('pass1' => $integer, 'pass2' => $integer), array('pass1' => $string, 'pass2' => $string));
|
||||
// Check that invalid array keys are ignored for password confirm elements.
|
||||
$this->checkFormValue('password_confirm', array('pass1' => 'test', 'pass2' => 'test', 'extra' => 'invalid'), array('pass1' => 'test', 'pass2' => 'test'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks that a given form input value is sanitized to the expected result.
|
||||
*
|
||||
* @param string $element_type
|
||||
* The form element type. Example: textfield.
|
||||
* @param mixed $input_value
|
||||
* The submitted user input value for the form element.
|
||||
* @param mixed $expected_value
|
||||
* The sanitized result value in the form state after calling
|
||||
* form_builder().
|
||||
*/
|
||||
protected function checkFormValue($element_type, $input_value, $expected_value) {
|
||||
$form_id = $this->randomName();
|
||||
$form = array();
|
||||
$form_state = form_state_defaults();
|
||||
$form['op'] = array('#type' => 'submit', '#value' => t('Submit'));
|
||||
$form[$element_type] = array(
|
||||
'#type' => $element_type,
|
||||
'#title' => 'test',
|
||||
);
|
||||
|
||||
$form_state['input'][$element_type] = $input_value;
|
||||
$form_state['input']['form_id'] = $form_id;
|
||||
$form_state['method'] = 'post';
|
||||
$form_state['values'] = array();
|
||||
drupal_prepare_form($form_id, $form, $form_state);
|
||||
|
||||
// This is the main function we want to test: it is responsible for
|
||||
// populating user supplied $form_state['input'] to sanitized
|
||||
// $form_state['values'].
|
||||
form_builder($form_id, $form, $form_state);
|
||||
|
||||
$this->assertIdentical($form_state['values'][$element_type], $expected_value, format_string('Form submission for the "@element_type" element type has been correctly sanitized.', array('@element_type' => $element_type)));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -5,8 +5,8 @@ version = VERSION
|
||||
core = 7.x
|
||||
hidden = TRUE
|
||||
|
||||
; Information added by Drupal.org packaging script on 2014-05-08
|
||||
version = "7.28"
|
||||
; Information added by Drupal.org packaging script on 2015-04-02
|
||||
version = "7.36"
|
||||
project = "drupal"
|
||||
datestamp = "1399522731"
|
||||
datestamp = "1427943826"
|
||||
|
||||
|
@@ -261,6 +261,7 @@ class ImageToolkitGdTestCase extends DrupalWebTestCase {
|
||||
*/
|
||||
function testManipulations() {
|
||||
// If GD isn't available don't bother testing this.
|
||||
module_load_include('inc', 'system', 'image.gd');
|
||||
if (!function_exists('image_gd_check_settings') || !image_gd_check_settings()) {
|
||||
$this->pass(t('Image manipulations for the GD toolkit were skipped because the GD toolkit is not available.'));
|
||||
return;
|
||||
@@ -379,7 +380,7 @@ class ImageToolkitGdTestCase extends DrupalWebTestCase {
|
||||
array_fill(0, 3, 76) + array(3 => 0),
|
||||
array_fill(0, 3, 149) + array(3 => 0),
|
||||
array_fill(0, 3, 29) + array(3 => 0),
|
||||
array_fill(0, 3, 0) + array(3 => 127)
|
||||
array_fill(0, 3, 225) + array(3 => 127)
|
||||
),
|
||||
),
|
||||
);
|
||||
@@ -394,11 +395,14 @@ class ImageToolkitGdTestCase extends DrupalWebTestCase {
|
||||
continue 2;
|
||||
}
|
||||
|
||||
// Transparent GIFs and the imagefilter function don't work together.
|
||||
// There is a todo in image.gd.inc to correct this.
|
||||
// All images should be converted to truecolor when loaded.
|
||||
$image_truecolor = imageistruecolor($image->resource);
|
||||
$this->assertTrue($image_truecolor, format_string('Image %file after load is a truecolor image.', array('%file' => $file)));
|
||||
|
||||
if ($image->info['extension'] == 'gif') {
|
||||
if ($op == 'desaturate') {
|
||||
$values['corners'][3] = $this->white;
|
||||
// Transparent GIFs and the imagefilter function don't work together.
|
||||
$values['corners'][3][3] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -451,7 +455,8 @@ class ImageToolkitGdTestCase extends DrupalWebTestCase {
|
||||
|
||||
$directory = file_default_scheme() . '://imagetests';
|
||||
file_prepare_directory($directory, FILE_CREATE_DIRECTORY);
|
||||
image_save($image, $directory . '/' . $op . '.' . $image->info['extension']);
|
||||
$file_path = $directory . '/' . $op . '.' . $image->info['extension'];
|
||||
image_save($image, $file_path);
|
||||
|
||||
$this->assertTrue($correct_dimensions_real, format_string('Image %file after %action action has proper dimensions.', array('%file' => $file, '%action' => $op)));
|
||||
$this->assertTrue($correct_dimensions_object, format_string('Image %file object after %action action is reporting the proper height and width values.', array('%file' => $file, '%action' => $op)));
|
||||
@@ -460,8 +465,37 @@ class ImageToolkitGdTestCase extends DrupalWebTestCase {
|
||||
$this->assertTrue($correct_colors, format_string('Image %file object after %action action has the correct color placement.', array('%file' => $file, '%action' => $op)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Check that saved image reloads without raising PHP errors.
|
||||
$image_reloaded = image_load($file_path);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests loading an image whose transparent color index is out of range.
|
||||
*/
|
||||
function testTransparentColorOutOfRange() {
|
||||
// This image was generated by taking an initial image with a palette size
|
||||
// of 6 colors, and setting the transparent color index to 6 (one higher
|
||||
// than the largest allowed index), as follows:
|
||||
// @code
|
||||
// $image = imagecreatefromgif('modules/simpletest/files/image-test.gif');
|
||||
// imagecolortransparent($image, 6);
|
||||
// imagegif($image, 'modules/simpletest/files/image-test-transparent-out-of-range.gif');
|
||||
// @endcode
|
||||
// This allows us to test that an image with an out-of-range color index
|
||||
// can be loaded correctly.
|
||||
$file = 'image-test-transparent-out-of-range.gif';
|
||||
$image = image_load(drupal_get_path('module', 'simpletest') . '/files/' . $file);
|
||||
|
||||
if (!$image) {
|
||||
$this->fail(format_string('Could not load image %file.', array('%file' => $file)));
|
||||
}
|
||||
else {
|
||||
// All images should be converted to truecolor when loaded.
|
||||
$image_truecolor = imageistruecolor($image->resource);
|
||||
$this->assertTrue($image_truecolor, format_string('Image %file after load is a truecolor image.', array('%file' => $file)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -5,8 +5,8 @@ version = VERSION
|
||||
core = 7.x
|
||||
hidden = TRUE
|
||||
|
||||
; Information added by Drupal.org packaging script on 2014-05-08
|
||||
version = "7.28"
|
||||
; Information added by Drupal.org packaging script on 2015-04-02
|
||||
version = "7.36"
|
||||
project = "drupal"
|
||||
datestamp = "1399522731"
|
||||
datestamp = "1427943826"
|
||||
|
||||
|
@@ -5,8 +5,8 @@ version = VERSION
|
||||
core = 7.x
|
||||
hidden = TRUE
|
||||
|
||||
; Information added by Drupal.org packaging script on 2014-05-08
|
||||
version = "7.28"
|
||||
; Information added by Drupal.org packaging script on 2015-04-02
|
||||
version = "7.36"
|
||||
project = "drupal"
|
||||
datestamp = "1399522731"
|
||||
datestamp = "1427943826"
|
||||
|
||||
|
@@ -5,8 +5,8 @@ version = VERSION
|
||||
core = 7.x
|
||||
hidden = TRUE
|
||||
|
||||
; Information added by Drupal.org packaging script on 2014-05-08
|
||||
version = "7.28"
|
||||
; Information added by Drupal.org packaging script on 2015-04-02
|
||||
version = "7.36"
|
||||
project = "drupal"
|
||||
datestamp = "1399522731"
|
||||
datestamp = "1427943826"
|
||||
|
||||
|
@@ -57,4 +57,25 @@ class PasswordHashingTest extends DrupalWebTestCase {
|
||||
$this->assertFalse(user_needs_new_hash($account), 'Re-hashed password does not need a new hash.');
|
||||
$this->assertTrue(user_check_password($password, $account), 'Password check succeeds with re-hashed password.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that passwords longer than 512 bytes are not hashed.
|
||||
*/
|
||||
public function testLongPassword() {
|
||||
$password = str_repeat('x', 512);
|
||||
$result = user_hash_password($password);
|
||||
$this->assertFalse(empty($result), '512 byte long password is allowed.');
|
||||
$password = str_repeat('x', 513);
|
||||
$result = user_hash_password($password);
|
||||
$this->assertFalse($result, '513 byte long password is not allowed.');
|
||||
// Check a string of 3-byte UTF-8 characters.
|
||||
$password = str_repeat('€', 170);
|
||||
$result = user_hash_password($password);
|
||||
$this->assertFalse(empty($result), '510 byte long password is allowed.');
|
||||
$password .= 'xx';
|
||||
$this->assertFalse(empty($result), '512 byte long password is allowed.');
|
||||
$password = str_repeat('€', 171);
|
||||
$result = user_hash_password($password);
|
||||
$this->assertFalse($result, '513 byte long password is not allowed.');
|
||||
}
|
||||
}
|
||||
|
@@ -5,8 +5,8 @@ version = VERSION
|
||||
core = 7.x
|
||||
hidden = TRUE
|
||||
|
||||
; Information added by Drupal.org packaging script on 2014-05-08
|
||||
version = "7.28"
|
||||
; Information added by Drupal.org packaging script on 2015-04-02
|
||||
version = "7.36"
|
||||
project = "drupal"
|
||||
datestamp = "1399522731"
|
||||
datestamp = "1427943826"
|
||||
|
||||
|
@@ -5,8 +5,8 @@ core = 7.x
|
||||
hidden = TRUE
|
||||
package = Testing
|
||||
|
||||
; Information added by Drupal.org packaging script on 2014-05-08
|
||||
version = "7.28"
|
||||
; Information added by Drupal.org packaging script on 2015-04-02
|
||||
version = "7.36"
|
||||
project = "drupal"
|
||||
datestamp = "1399522731"
|
||||
datestamp = "1427943826"
|
||||
|
||||
|
12
modules/simpletest/tests/psr_4_test/psr_4_test.info
Normal file
12
modules/simpletest/tests/psr_4_test/psr_4_test.info
Normal file
@@ -0,0 +1,12 @@
|
||||
name = PSR-4 Test cases
|
||||
description = Test classes to be discovered by simpletest.
|
||||
core = 7.x
|
||||
|
||||
hidden = TRUE
|
||||
package = Testing
|
||||
|
||||
; Information added by Drupal.org packaging script on 2015-04-02
|
||||
version = "7.36"
|
||||
project = "drupal"
|
||||
datestamp = "1427943826"
|
||||
|
1
modules/simpletest/tests/psr_4_test/psr_4_test.module
Normal file
1
modules/simpletest/tests/psr_4_test/psr_4_test.module
Normal file
@@ -0,0 +1 @@
|
||||
<?php
|
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\psr_4_test\Tests;
|
||||
|
||||
class ExampleTest extends \DrupalWebTestCase {
|
||||
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'PSR4 example test: PSR-4 in disabled modules.',
|
||||
'description' => 'We want to assert that this test case is being discovered.',
|
||||
'group' => 'SimpleTest',
|
||||
);
|
||||
}
|
||||
|
||||
function testArithmetics() {
|
||||
$this->assert(1 + 1 == 2, '1 + 1 == 2');
|
||||
}
|
||||
}
|
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\psr_4_test\Tests\Nested;
|
||||
|
||||
class NestedExampleTest extends \DrupalWebTestCase {
|
||||
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'PSR4 example test: PSR-4 in nested subfolders.',
|
||||
'description' => 'We want to assert that this PSR-4 test case is being discovered.',
|
||||
'group' => 'SimpleTest',
|
||||
);
|
||||
}
|
||||
|
||||
function testArithmetics() {
|
||||
$this->assert(1 + 1 == 2, '1 + 1 == 2');
|
||||
}
|
||||
}
|
@@ -5,8 +5,8 @@ version = VERSION
|
||||
core = 7.x
|
||||
hidden = TRUE
|
||||
|
||||
; Information added by Drupal.org packaging script on 2014-05-08
|
||||
version = "7.28"
|
||||
; Information added by Drupal.org packaging script on 2015-04-02
|
||||
version = "7.36"
|
||||
project = "drupal"
|
||||
datestamp = "1399522731"
|
||||
datestamp = "1427943826"
|
||||
|
||||
|
@@ -7,8 +7,8 @@ version = VERSION
|
||||
core = 7.x
|
||||
hidden = TRUE
|
||||
|
||||
; Information added by Drupal.org packaging script on 2014-05-08
|
||||
version = "7.28"
|
||||
; Information added by Drupal.org packaging script on 2015-04-02
|
||||
version = "7.36"
|
||||
project = "drupal"
|
||||
datestamp = "1399522731"
|
||||
datestamp = "1427943826"
|
||||
|
||||
|
@@ -5,8 +5,8 @@ version = VERSION
|
||||
core = 7.x
|
||||
hidden = TRUE
|
||||
|
||||
; Information added by Drupal.org packaging script on 2014-05-08
|
||||
version = "7.28"
|
||||
; Information added by Drupal.org packaging script on 2015-04-02
|
||||
version = "7.36"
|
||||
project = "drupal"
|
||||
datestamp = "1399522731"
|
||||
datestamp = "1427943826"
|
||||
|
||||
|
@@ -6,8 +6,8 @@ core = 7.x
|
||||
hidden = TRUE
|
||||
dependencies[] = _missing_dependency
|
||||
|
||||
; Information added by Drupal.org packaging script on 2014-05-08
|
||||
version = "7.28"
|
||||
; Information added by Drupal.org packaging script on 2015-04-02
|
||||
version = "7.36"
|
||||
project = "drupal"
|
||||
datestamp = "1399522731"
|
||||
datestamp = "1427943826"
|
||||
|
||||
|
@@ -6,8 +6,8 @@ core = 7.x
|
||||
hidden = TRUE
|
||||
dependencies[] = system_incompatible_core_version_test
|
||||
|
||||
; Information added by Drupal.org packaging script on 2014-05-08
|
||||
version = "7.28"
|
||||
; Information added by Drupal.org packaging script on 2015-04-02
|
||||
version = "7.36"
|
||||
project = "drupal"
|
||||
datestamp = "1399522731"
|
||||
datestamp = "1427943826"
|
||||
|
||||
|
@@ -5,8 +5,8 @@ version = VERSION
|
||||
core = 5.x
|
||||
hidden = TRUE
|
||||
|
||||
; Information added by Drupal.org packaging script on 2014-05-08
|
||||
version = "7.28"
|
||||
; Information added by Drupal.org packaging script on 2015-04-02
|
||||
version = "7.36"
|
||||
project = "drupal"
|
||||
datestamp = "1399522731"
|
||||
datestamp = "1427943826"
|
||||
|
||||
|
@@ -7,8 +7,8 @@ hidden = TRUE
|
||||
; system_incompatible_module_version_test declares version 1.0
|
||||
dependencies[] = system_incompatible_module_version_test (>2.0)
|
||||
|
||||
; Information added by Drupal.org packaging script on 2014-05-08
|
||||
version = "7.28"
|
||||
; Information added by Drupal.org packaging script on 2015-04-02
|
||||
version = "7.36"
|
||||
project = "drupal"
|
||||
datestamp = "1399522731"
|
||||
datestamp = "1427943826"
|
||||
|
||||
|
@@ -5,8 +5,8 @@ version = 1.0
|
||||
core = 7.x
|
||||
hidden = TRUE
|
||||
|
||||
; Information added by Drupal.org packaging script on 2014-05-08
|
||||
version = "7.28"
|
||||
; Information added by Drupal.org packaging script on 2015-04-02
|
||||
version = "7.36"
|
||||
project = "drupal"
|
||||
datestamp = "1399522731"
|
||||
datestamp = "1427943826"
|
||||
|
||||
|
@@ -6,8 +6,8 @@ core = 7.x
|
||||
files[] = system_test.module
|
||||
hidden = TRUE
|
||||
|
||||
; Information added by Drupal.org packaging script on 2014-05-08
|
||||
version = "7.28"
|
||||
; Information added by Drupal.org packaging script on 2015-04-02
|
||||
version = "7.36"
|
||||
project = "drupal"
|
||||
datestamp = "1399522731"
|
||||
datestamp = "1427943826"
|
||||
|
||||
|
@@ -78,6 +78,13 @@ function system_test_menu() {
|
||||
'type' => MENU_CALLBACK,
|
||||
);
|
||||
|
||||
$items['system-test/drupal-set-message'] = array(
|
||||
'title' => 'Set messages with drupal_set_message()',
|
||||
'page callback' => 'system_test_drupal_set_message',
|
||||
'access callback' => TRUE,
|
||||
'type' => MENU_CALLBACK,
|
||||
);
|
||||
|
||||
$items['system-test/main-content-handling'] = array(
|
||||
'title' => 'Test main content handling',
|
||||
'page callback' => 'system_test_main_content_fallback',
|
||||
@@ -106,6 +113,20 @@ function system_test_menu() {
|
||||
'type' => MENU_CALLBACK,
|
||||
);
|
||||
|
||||
$items['system-test/get-destination'] = array(
|
||||
'title' => 'Test $_GET[\'destination\']',
|
||||
'page callback' => 'system_test_get_destination',
|
||||
'access callback' => TRUE,
|
||||
'type' => MENU_CALLBACK,
|
||||
);
|
||||
|
||||
$items['system-test/request-destination'] = array(
|
||||
'title' => 'Test $_REQUEST[\'destination\']',
|
||||
'page callback' => 'system_test_request_destination',
|
||||
'access callback' => TRUE,
|
||||
'type' => MENU_CALLBACK,
|
||||
);
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
@@ -420,3 +441,41 @@ function system_test_authorize_init_page($page_title) {
|
||||
system_authorized_init('system_test_authorize_run', drupal_get_path('module', 'system_test') . '/system_test.module', array(), $page_title);
|
||||
drupal_goto($authorize_url);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets two messages and removes the first one before the messages are displayed.
|
||||
*/
|
||||
function system_test_drupal_set_message() {
|
||||
// Set two messages.
|
||||
drupal_set_message('First message (removed).');
|
||||
drupal_set_message('Second message (not removed).');
|
||||
|
||||
// Remove the first.
|
||||
unset($_SESSION['messages']['status'][0]);
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Page callback to print out $_GET['destination'] for testing.
|
||||
*/
|
||||
function system_test_get_destination() {
|
||||
if (isset($_GET['destination'])) {
|
||||
print $_GET['destination'];
|
||||
}
|
||||
// No need to render the whole page, we are just interested in this bit of
|
||||
// information.
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Page callback to print out $_REQUEST['destination'] for testing.
|
||||
*/
|
||||
function system_test_request_destination() {
|
||||
if (isset($_REQUEST['destination'])) {
|
||||
print $_REQUEST['destination'];
|
||||
}
|
||||
// No need to render the whole page, we are just interested in this bit of
|
||||
// information.
|
||||
exit;
|
||||
}
|
||||
|
@@ -6,8 +6,8 @@ core = 7.x
|
||||
hidden = TRUE
|
||||
dependencies[] = taxonomy
|
||||
|
||||
; Information added by Drupal.org packaging script on 2014-05-08
|
||||
version = "7.28"
|
||||
; Information added by Drupal.org packaging script on 2015-04-02
|
||||
version = "7.36"
|
||||
project = "drupal"
|
||||
datestamp = "1399522731"
|
||||
datestamp = "1427943826"
|
||||
|
||||
|
@@ -155,6 +155,15 @@ class ThemeTestCase extends DrupalWebTestCase {
|
||||
$this->assertNotEqual(theme_get_setting('subtheme_override', 'test_basetheme'), theme_get_setting('subtheme_override', 'test_subtheme'), 'Base theme\'s default settings values can be overridden by subtheme.');
|
||||
$this->assertIdentical(theme_get_setting('basetheme_only', 'test_subtheme'), 'base theme value', 'Base theme\'s default settings values are inherited by subtheme.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the drupal_add_region_content() function.
|
||||
*/
|
||||
function testDrupalAddRegionContent() {
|
||||
$this->drupalGet('theme-test/drupal-add-region-content');
|
||||
$this->assertText('Hello');
|
||||
$this->assertText('World');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -425,28 +434,100 @@ class ThemeFastTestCase extends DrupalWebTestCase {
|
||||
}
|
||||
|
||||
/**
|
||||
* Unit tests for theme_html_tag().
|
||||
* Tests the markup of core render element types passed to drupal_render().
|
||||
*/
|
||||
class ThemeHtmlTag extends DrupalUnitTestCase {
|
||||
class RenderElementTypesTestCase extends DrupalWebTestCase {
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Theme HTML Tag',
|
||||
'description' => 'Tests theme_html_tag() built-in theme functions.',
|
||||
'name' => 'Render element types',
|
||||
'description' => 'Tests the markup of core render element types passed to drupal_render().',
|
||||
'group' => 'Theme',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test function theme_html_tag()
|
||||
* Asserts that an array of elements is rendered properly.
|
||||
*
|
||||
* @param array $elements
|
||||
* An array of associative arrays describing render elements and their
|
||||
* expected markup. Each item in $elements must contain the following:
|
||||
* - 'name': This human readable description will be displayed on the test
|
||||
* results page.
|
||||
* - 'value': This is the render element to test.
|
||||
* - 'expected': This is the expected markup for the element in 'value'.
|
||||
*/
|
||||
function testThemeHtmlTag() {
|
||||
// Test auto-closure meta tag generation
|
||||
$tag['element'] = array('#tag' => 'meta', '#attributes' => array('name' => 'description', 'content' => 'Drupal test'));
|
||||
$this->assertEqual('<meta name="description" content="Drupal test" />'."\n", theme_html_tag($tag), 'Test auto-closure meta tag generation.');
|
||||
function assertElements($elements) {
|
||||
foreach($elements as $element) {
|
||||
$this->assertIdentical(drupal_render($element['value']), $element['expected'], '"' . $element['name'] . '" input rendered correctly by drupal_render().');
|
||||
}
|
||||
}
|
||||
|
||||
// Test title tag generation
|
||||
$tag['element'] = array('#tag' => 'title', '#value' => 'title test');
|
||||
$this->assertEqual('<title>title test</title>'."\n", theme_html_tag($tag), 'Test title tag generation.');
|
||||
/**
|
||||
* Tests system #type 'container'.
|
||||
*/
|
||||
function testContainer() {
|
||||
$elements = array(
|
||||
// Basic container with no attributes.
|
||||
array(
|
||||
'name' => "#type 'container' with no HTML attributes",
|
||||
'value' => array(
|
||||
'#type' => 'container',
|
||||
'child' => array(
|
||||
'#markup' => 'foo',
|
||||
),
|
||||
),
|
||||
'expected' => '<div>foo</div>',
|
||||
),
|
||||
// Container with a class.
|
||||
array(
|
||||
'name' => "#type 'container' with a class HTML attribute",
|
||||
'value' => array(
|
||||
'#type' => 'container',
|
||||
'child' => array(
|
||||
'#markup' => 'foo',
|
||||
),
|
||||
'#attributes' => array(
|
||||
'class' => 'bar',
|
||||
),
|
||||
),
|
||||
'expected' => '<div class="bar">foo</div>',
|
||||
),
|
||||
);
|
||||
|
||||
$this->assertElements($elements);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests system #type 'html_tag'.
|
||||
*/
|
||||
function testHtmlTag() {
|
||||
$elements = array(
|
||||
// Test auto-closure meta tag generation.
|
||||
array(
|
||||
'name' => "#type 'html_tag' auto-closure meta tag generation",
|
||||
'value' => array(
|
||||
'#type' => 'html_tag',
|
||||
'#tag' => 'meta',
|
||||
'#attributes' => array(
|
||||
'name' => 'description',
|
||||
'content' => 'Drupal test',
|
||||
),
|
||||
),
|
||||
'expected' => '<meta name="description" content="Drupal test" />' . "\n",
|
||||
),
|
||||
// Test title tag generation.
|
||||
array(
|
||||
'name' => "#type 'html_tag' title tag generation",
|
||||
'value' => array(
|
||||
'#type' => 'html_tag',
|
||||
'#tag' => 'title',
|
||||
'#value' => 'title test',
|
||||
),
|
||||
'expected' => '<title>title test</title>' . "\n",
|
||||
),
|
||||
);
|
||||
|
||||
$this->assertElements($elements);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -500,3 +581,68 @@ class ThemeRegistryTestCase extends DrupalWebTestCase {
|
||||
$this->assertTrue($registry['theme_test_template_test_2'], 'Offset was returned correctly from the theme registry');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests for theme debug markup.
|
||||
*/
|
||||
class ThemeDebugMarkupTestCase extends DrupalWebTestCase {
|
||||
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Theme debug markup',
|
||||
'description' => 'Tests theme debug markup output.',
|
||||
'group' => 'Theme',
|
||||
);
|
||||
}
|
||||
|
||||
function setUp() {
|
||||
parent::setUp('theme_test', 'node');
|
||||
theme_enable(array('test_theme'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests debug markup added to template output.
|
||||
*/
|
||||
function testDebugOutput() {
|
||||
variable_set('theme_default', 'test_theme');
|
||||
// Enable the debug output.
|
||||
variable_set('theme_debug', TRUE);
|
||||
|
||||
$registry = theme_get_registry();
|
||||
$extension = '.tpl.php';
|
||||
// Populate array of templates.
|
||||
$templates = drupal_find_theme_templates($registry, $extension, drupal_get_path('theme', 'test_theme'));
|
||||
$templates += drupal_find_theme_templates($registry, $extension, drupal_get_path('module', 'node'));
|
||||
|
||||
// Create a node and test different features of the debug markup.
|
||||
$node = $this->drupalCreateNode();
|
||||
$this->drupalGet('node/' . $node->nid);
|
||||
$this->assertRaw('<!-- THEME DEBUG -->', 'Theme debug markup found in theme output when debug is enabled.');
|
||||
$this->assertRaw("CALL: theme('node')", 'Theme call information found.');
|
||||
$this->assertRaw('x node--1' . $extension . PHP_EOL . ' * node--page' . $extension . PHP_EOL . ' * node' . $extension, 'Suggested template files found in order and node ID specific template shown as current template.');
|
||||
$template_filename = $templates['node__1']['path'] . '/' . $templates['node__1']['template'] . $extension;
|
||||
$this->assertRaw("BEGIN OUTPUT from '$template_filename'", 'Full path to current template file found.');
|
||||
|
||||
// Create another node and make sure the template suggestions shown in the
|
||||
// debug markup are correct.
|
||||
$node2 = $this->drupalCreateNode();
|
||||
$this->drupalGet('node/' . $node2->nid);
|
||||
$this->assertRaw('* node--2' . $extension . PHP_EOL . ' * node--page' . $extension . PHP_EOL . ' x node' . $extension, 'Suggested template files found in order and base template shown as current template.');
|
||||
|
||||
// Create another node and make sure the template suggestions shown in the
|
||||
// debug markup are correct.
|
||||
$node3 = $this->drupalCreateNode();
|
||||
$build = array('#theme' => 'node__foo__bar');
|
||||
$build += node_view($node3);
|
||||
$output = drupal_render($build);
|
||||
$this->assertTrue(strpos($output, "CALL: theme('node__foo__bar')") !== FALSE, 'Theme call information found.');
|
||||
$this->assertTrue(strpos($output, '* node--foo--bar' . $extension . PHP_EOL . ' * node--foo' . $extension . PHP_EOL . ' * node--3' . $extension . PHP_EOL . ' * node--page' . $extension . PHP_EOL . ' x node' . $extension) !== FALSE, 'Suggested template files found in order and base template shown as current template.');
|
||||
|
||||
// Disable theme debug.
|
||||
variable_set('theme_debug', FALSE);
|
||||
|
||||
$this->drupalGet('node/' . $node->nid);
|
||||
$this->assertNoRaw('<!-- THEME DEBUG -->', 'Theme debug markup not found in theme output when debug is disabled.');
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -5,8 +5,8 @@ version = VERSION
|
||||
core = 7.x
|
||||
hidden = TRUE
|
||||
|
||||
; Information added by Drupal.org packaging script on 2014-05-08
|
||||
version = "7.28"
|
||||
; Information added by Drupal.org packaging script on 2015-04-02
|
||||
version = "7.36"
|
||||
project = "drupal"
|
||||
datestamp = "1399522731"
|
||||
datestamp = "1427943826"
|
||||
|
||||
|
@@ -53,6 +53,11 @@ function theme_test_menu() {
|
||||
'access callback' => TRUE,
|
||||
'type' => MENU_CALLBACK,
|
||||
);
|
||||
$items['theme-test/drupal-add-region-content'] = array(
|
||||
'page callback' => '_theme_test_drupal_add_region_content',
|
||||
'access callback' => TRUE,
|
||||
'type' => MENU_CALLBACK,
|
||||
);
|
||||
return $items;
|
||||
}
|
||||
|
||||
@@ -126,6 +131,14 @@ function _theme_test_suggestion() {
|
||||
return theme(array('theme_test__suggestion', 'theme_test'), array());
|
||||
}
|
||||
|
||||
/**
|
||||
* Page callback, calls drupal_add_region_content.
|
||||
*/
|
||||
function _theme_test_drupal_add_region_content() {
|
||||
drupal_add_region_content('content', 'World');
|
||||
return 'Hello';
|
||||
}
|
||||
|
||||
/**
|
||||
* Theme function for testing theme('theme_test_foo').
|
||||
*/
|
||||
|
@@ -6,8 +6,8 @@ hidden = TRUE
|
||||
settings[basetheme_only] = base theme value
|
||||
settings[subtheme_override] = base theme value
|
||||
|
||||
; Information added by Drupal.org packaging script on 2014-05-08
|
||||
version = "7.28"
|
||||
; Information added by Drupal.org packaging script on 2015-04-02
|
||||
version = "7.36"
|
||||
project = "drupal"
|
||||
datestamp = "1399522731"
|
||||
datestamp = "1427943826"
|
||||
|
||||
|
@@ -6,8 +6,8 @@ hidden = TRUE
|
||||
|
||||
settings[subtheme_override] = subtheme value
|
||||
|
||||
; Information added by Drupal.org packaging script on 2014-05-08
|
||||
version = "7.28"
|
||||
; Information added by Drupal.org packaging script on 2015-04-02
|
||||
version = "7.36"
|
||||
project = "drupal"
|
||||
datestamp = "1399522731"
|
||||
datestamp = "1427943826"
|
||||
|
||||
|
@@ -0,0 +1,2 @@
|
||||
<!-- Output for Theme Debug Markup test -->
|
||||
Node Content Dummy
|
@@ -17,8 +17,8 @@ stylesheets[all][] = system.base.css
|
||||
|
||||
settings[theme_test_setting] = default value
|
||||
|
||||
; Information added by Drupal.org packaging script on 2014-05-08
|
||||
version = "7.28"
|
||||
; Information added by Drupal.org packaging script on 2015-04-02
|
||||
version = "7.36"
|
||||
project = "drupal"
|
||||
datestamp = "1399522731"
|
||||
datestamp = "1427943826"
|
||||
|
||||
|
@@ -5,8 +5,8 @@ version = VERSION
|
||||
core = 7.x
|
||||
hidden = TRUE
|
||||
|
||||
; Information added by Drupal.org packaging script on 2014-05-08
|
||||
version = "7.28"
|
||||
; Information added by Drupal.org packaging script on 2015-04-02
|
||||
version = "7.36"
|
||||
project = "drupal"
|
||||
datestamp = "1399522731"
|
||||
datestamp = "1427943826"
|
||||
|
||||
|
@@ -5,8 +5,8 @@ version = VERSION
|
||||
core = 7.x
|
||||
hidden = TRUE
|
||||
|
||||
; Information added by Drupal.org packaging script on 2014-05-08
|
||||
version = "7.28"
|
||||
; Information added by Drupal.org packaging script on 2015-04-02
|
||||
version = "7.36"
|
||||
project = "drupal"
|
||||
datestamp = "1399522731"
|
||||
datestamp = "1427943826"
|
||||
|
||||
|
@@ -5,8 +5,8 @@ version = VERSION
|
||||
core = 7.x
|
||||
hidden = TRUE
|
||||
|
||||
; Information added by Drupal.org packaging script on 2014-05-08
|
||||
version = "7.28"
|
||||
; Information added by Drupal.org packaging script on 2015-04-02
|
||||
version = "7.36"
|
||||
project = "drupal"
|
||||
datestamp = "1399522731"
|
||||
datestamp = "1427943826"
|
||||
|
||||
|
@@ -5,8 +5,8 @@ version = VERSION
|
||||
core = 7.x
|
||||
hidden = TRUE
|
||||
|
||||
; Information added by Drupal.org packaging script on 2014-05-08
|
||||
version = "7.28"
|
||||
; Information added by Drupal.org packaging script on 2015-04-02
|
||||
version = "7.36"
|
||||
project = "drupal"
|
||||
datestamp = "1399522731"
|
||||
datestamp = "1427943826"
|
||||
|
||||
|
@@ -5,8 +5,8 @@ package = Testing
|
||||
version = VERSION
|
||||
hidden = TRUE
|
||||
|
||||
; Information added by Drupal.org packaging script on 2014-05-08
|
||||
version = "7.28"
|
||||
; Information added by Drupal.org packaging script on 2015-04-02
|
||||
version = "7.36"
|
||||
project = "drupal"
|
||||
datestamp = "1399522731"
|
||||
datestamp = "1427943826"
|
||||
|
||||
|
@@ -211,6 +211,11 @@ class XMLRPCMessagesTestCase extends DrupalWebTestCase {
|
||||
* Make sure that XML-RPC can transfer large messages.
|
||||
*/
|
||||
function testSizedMessages() {
|
||||
// These tests can produce up to 128 x 160 words in the XML-RPC message
|
||||
// (see xmlrpc_test_message_sized_in_kb()) with 4 tags used to represent
|
||||
// each. Set a large enough tag limit to allow this to be tested.
|
||||
variable_set('xmlrpc_message_maximum_tag_count', 100000);
|
||||
|
||||
$xml_url = url(NULL, array('absolute' => TRUE)) . 'xmlrpc.php';
|
||||
$sizes = array(8, 80, 160);
|
||||
foreach ($sizes as $size) {
|
||||
|
@@ -5,8 +5,8 @@ version = VERSION
|
||||
core = 7.x
|
||||
hidden = TRUE
|
||||
|
||||
; Information added by Drupal.org packaging script on 2014-05-08
|
||||
version = "7.28"
|
||||
; Information added by Drupal.org packaging script on 2015-04-02
|
||||
version = "7.36"
|
||||
project = "drupal"
|
||||
datestamp = "1399522731"
|
||||
datestamp = "1427943826"
|
||||
|
||||
|
Reference in New Issue
Block a user