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
|
||||
|
Reference in New Issue
Block a user