updated core to 7.80
This commit is contained in:
@@ -1677,15 +1677,12 @@ class DrupalWebTestCase extends DrupalTestCase {
|
||||
file_unmanaged_delete_recursive($this->originalFileDirectory . '/simpletest/' . substr($this->databasePrefix, 10));
|
||||
|
||||
// Remove all prefixed tables.
|
||||
$tables = db_find_tables($this->databasePrefix . '%');
|
||||
$connection_info = Database::getConnectionInfo('default');
|
||||
$tables = db_find_tables($connection_info['default']['prefix']['default'] . '%');
|
||||
$tables = db_find_tables_d8('%');
|
||||
if (empty($tables)) {
|
||||
$this->fail('Failed to find test tables to drop.');
|
||||
}
|
||||
$prefix_length = strlen($connection_info['default']['prefix']['default']);
|
||||
foreach ($tables as $table) {
|
||||
if (db_drop_table(substr($table, $prefix_length))) {
|
||||
if (db_drop_table($table)) {
|
||||
unset($tables[$table]);
|
||||
}
|
||||
}
|
||||
@@ -1693,8 +1690,14 @@ class DrupalWebTestCase extends DrupalTestCase {
|
||||
$this->fail('Failed to drop all prefixed tables.');
|
||||
}
|
||||
|
||||
// In PHP 8 some tests encounter problems when shutdown code tries to
|
||||
// access the database connection after it's been explicitly closed, for
|
||||
// example the destructor of DrupalCacheArray. We avoid this by not fully
|
||||
// destroying the test database connection.
|
||||
$close = \PHP_VERSION_ID < 80000;
|
||||
|
||||
// Get back to the original connection.
|
||||
Database::removeConnection('default');
|
||||
Database::removeConnection('default', $close);
|
||||
Database::renameConnection('simpletest_original_default', 'default');
|
||||
|
||||
// Restore original shutdown callbacks array to prevent original
|
||||
@@ -3087,7 +3090,7 @@ class DrupalWebTestCase extends DrupalTestCase {
|
||||
* @return
|
||||
* TRUE on pass, FALSE on fail.
|
||||
*/
|
||||
protected function assertTextHelper($text, $message = '', $group, $not_exists) {
|
||||
protected function assertTextHelper($text, $message, $group, $not_exists) {
|
||||
if ($this->plainTextContent === FALSE) {
|
||||
$this->plainTextContent = filter_xss($this->drupalGetContent(), array());
|
||||
}
|
||||
@@ -3153,7 +3156,7 @@ class DrupalWebTestCase extends DrupalTestCase {
|
||||
* @return
|
||||
* TRUE on pass, FALSE on fail.
|
||||
*/
|
||||
protected function assertUniqueTextHelper($text, $message = '', $group, $be_unique) {
|
||||
protected function assertUniqueTextHelper($text, $message, $group, $be_unique) {
|
||||
if ($this->plainTextContent === FALSE) {
|
||||
$this->plainTextContent = filter_xss($this->drupalGetContent(), array());
|
||||
}
|
||||
@@ -3259,7 +3262,7 @@ class DrupalWebTestCase extends DrupalTestCase {
|
||||
* @param $callback
|
||||
* The name of the theme function to invoke; e.g. 'links' for theme_links().
|
||||
* @param $variables
|
||||
* (optional) An array of variables to pass to the theme function.
|
||||
* An array of variables to pass to the theme function.
|
||||
* @param $expected
|
||||
* The expected themed output string.
|
||||
* @param $message
|
||||
@@ -3275,7 +3278,7 @@ class DrupalWebTestCase extends DrupalTestCase {
|
||||
* @return
|
||||
* TRUE on pass, FALSE on fail.
|
||||
*/
|
||||
protected function assertThemeOutput($callback, array $variables = array(), $expected, $message = '', $group = 'Other') {
|
||||
protected function assertThemeOutput($callback, array $variables, $expected, $message = '', $group = 'Other') {
|
||||
$output = theme($callback, $variables);
|
||||
$this->verbose('Variables:' . '<pre>' . check_plain(var_export($variables, TRUE)) . '</pre>'
|
||||
. '<hr />' . 'Result:' . '<pre>' . check_plain(var_export($output, TRUE)) . '</pre>'
|
||||
|
@@ -33,6 +33,7 @@ files[] = tests/pager.test
|
||||
files[] = tests/password.test
|
||||
files[] = tests/path.test
|
||||
files[] = tests/registry.test
|
||||
files[] = tests/request_sanitizer.test
|
||||
files[] = tests/schema.test
|
||||
files[] = tests/session.test
|
||||
files[] = tests/tablesort.test
|
||||
@@ -57,7 +58,7 @@ 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 2019-05-08
|
||||
version = "7.67"
|
||||
; Information added by Drupal.org packaging script on 2021-04-21
|
||||
version = "7.80"
|
||||
project = "drupal"
|
||||
datestamp = "1557336079"
|
||||
datestamp = "1619021862"
|
||||
|
@@ -563,7 +563,7 @@ function simpletest_clean_environment() {
|
||||
* Removed prefixed tables from the database that are left over from crashed tests.
|
||||
*/
|
||||
function simpletest_clean_database() {
|
||||
$tables = db_find_tables(Database::getConnection()->prefixTables('{simpletest}') . '%');
|
||||
$tables = db_find_tables_d8(Database::getConnection()->prefixTables('{simpletest}') . '%');
|
||||
$schema = drupal_get_schema_unprocessed('simpletest');
|
||||
$count = 0;
|
||||
foreach (array_diff_key($tables, $schema) as $table) {
|
||||
|
@@ -164,13 +164,16 @@ class SimpleTestFunctionalTest extends DrupalWebTestCase {
|
||||
$this->pass(t('Test ID is @id.', array('@id' => $this->testId)));
|
||||
|
||||
// Generates a warning.
|
||||
$i = 1 / 0;
|
||||
$a = '';
|
||||
foreach ($a as $b) {
|
||||
|
||||
}
|
||||
|
||||
// Call an assert function specific to that class.
|
||||
$this->assertNothing();
|
||||
|
||||
// Generates a warning inside a PHP function.
|
||||
array_key_exists(NULL, NULL);
|
||||
// Generates 3 warnings inside a PHP function.
|
||||
simplexml_load_string('<fake>');
|
||||
|
||||
debug('Foo', 'Debug');
|
||||
}
|
||||
@@ -195,19 +198,21 @@ class SimpleTestFunctionalTest extends DrupalWebTestCase {
|
||||
$this->assertAssertion(t('Invalid permission %permission.', array('%permission' => $this->invalid_permission)), 'Role', 'Fail', 'simpletest.test', 'SimpleTestFunctionalTest->stubTest()');
|
||||
|
||||
// Check that a warning is caught by simpletest.
|
||||
$this->assertAssertion('Division by zero', 'Warning', 'Fail', 'simpletest.test', 'SimpleTestFunctionalTest->stubTest()');
|
||||
// The exact error message differs between PHP versions so we check only
|
||||
// the presense of the 'foreach' statement.
|
||||
$this->assertAssertion('foreach()', 'Warning', 'Fail', 'simpletest.test', 'SimpleTestFunctionalTest->stubTest()');
|
||||
|
||||
// Check that the backtracing code works for specific assert function.
|
||||
$this->assertAssertion('This is nothing.', 'Other', 'Pass', 'simpletest.test', 'SimpleTestFunctionalTest->stubTest()');
|
||||
|
||||
// Check that errors that occur inside PHP internal functions are correctly reported.
|
||||
// The exact error message differs between PHP versions so we check only
|
||||
// the function name 'array_key_exists'.
|
||||
$this->assertAssertion('array_key_exists', 'Warning', 'Fail', 'simpletest.test', 'SimpleTestFunctionalTest->stubTest()');
|
||||
// the function name 'simplexml_load_string'.
|
||||
$this->assertAssertion('simplexml_load_string', 'Warning', 'Fail', 'simpletest.test', 'SimpleTestFunctionalTest->stubTest()');
|
||||
|
||||
$this->assertAssertion("Debug: 'Foo'", 'Debug', 'Fail', 'simpletest.test', 'SimpleTestFunctionalTest->stubTest()');
|
||||
|
||||
$this->assertEqual('6 passes, 5 fails, 2 exceptions, and 1 debug message', $this->childTestResults['summary'], 'Stub test summary is correct');
|
||||
$this->assertEqual('6 passes, 5 fails, 4 exceptions, and 1 debug message', $this->childTestResults['summary'], 'Stub test summary is correct');
|
||||
|
||||
$this->test_ids[] = $test_id = $this->getTestIdFromResults();
|
||||
$this->assertTrue($test_id, 'Found test ID in results.');
|
||||
|
@@ -5,7 +5,7 @@ version = VERSION
|
||||
core = 7.x
|
||||
hidden = TRUE
|
||||
|
||||
; Information added by Drupal.org packaging script on 2019-05-08
|
||||
version = "7.67"
|
||||
; Information added by Drupal.org packaging script on 2021-04-21
|
||||
version = "7.80"
|
||||
project = "drupal"
|
||||
datestamp = "1557336079"
|
||||
datestamp = "1619021862"
|
||||
|
@@ -5,7 +5,7 @@ package = Testing
|
||||
version = VERSION
|
||||
hidden = TRUE
|
||||
|
||||
; Information added by Drupal.org packaging script on 2019-05-08
|
||||
version = "7.67"
|
||||
; Information added by Drupal.org packaging script on 2021-04-21
|
||||
version = "7.80"
|
||||
project = "drupal"
|
||||
datestamp = "1557336079"
|
||||
datestamp = "1619021862"
|
||||
|
@@ -5,7 +5,7 @@ version = VERSION
|
||||
core = 7.x
|
||||
hidden = TRUE
|
||||
|
||||
; Information added by Drupal.org packaging script on 2019-05-08
|
||||
version = "7.67"
|
||||
; Information added by Drupal.org packaging script on 2021-04-21
|
||||
version = "7.80"
|
||||
project = "drupal"
|
||||
datestamp = "1557336079"
|
||||
datestamp = "1619021862"
|
||||
|
@@ -5,7 +5,7 @@ version = VERSION
|
||||
core = 7.x
|
||||
hidden = TRUE
|
||||
|
||||
; Information added by Drupal.org packaging script on 2019-05-08
|
||||
version = "7.67"
|
||||
; Information added by Drupal.org packaging script on 2021-04-21
|
||||
version = "7.80"
|
||||
project = "drupal"
|
||||
datestamp = "1557336079"
|
||||
datestamp = "1619021862"
|
||||
|
@@ -5,7 +5,7 @@ package = Testing
|
||||
version = VERSION
|
||||
hidden = TRUE
|
||||
|
||||
; Information added by Drupal.org packaging script on 2019-05-08
|
||||
version = "7.67"
|
||||
; Information added by Drupal.org packaging script on 2021-04-21
|
||||
version = "7.80"
|
||||
project = "drupal"
|
||||
datestamp = "1557336079"
|
||||
datestamp = "1619021862"
|
||||
|
@@ -5,7 +5,7 @@ package = Testing
|
||||
version = VERSION
|
||||
hidden = TRUE
|
||||
|
||||
; Information added by Drupal.org packaging script on 2019-05-08
|
||||
version = "7.67"
|
||||
; Information added by Drupal.org packaging script on 2021-04-21
|
||||
version = "7.80"
|
||||
project = "drupal"
|
||||
datestamp = "1557336079"
|
||||
datestamp = "1619021862"
|
||||
|
@@ -453,13 +453,13 @@ class BootstrapGetFilenameTestCase extends DrupalUnitTestCase {
|
||||
/**
|
||||
* Skips handling of "file not found" errors.
|
||||
*/
|
||||
public function fileNotFoundErrorHandler($error_level, $message, $filename, $line, $context) {
|
||||
public function fileNotFoundErrorHandler($error_level, $message, $filename, $line) {
|
||||
// Skip error handling if this is a "file not found" error.
|
||||
if (strpos($message, 'is missing from the file system:') !== FALSE || strpos($message, 'has moved within the file system:') !== FALSE) {
|
||||
$this->getFilenameTestTriggeredError = $message;
|
||||
return;
|
||||
}
|
||||
_drupal_error_handler($error_level, $message, $filename, $line, $context);
|
||||
_drupal_error_handler($error_level, $message, $filename, $line);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -569,13 +569,13 @@ class BootstrapGetFilenameWebTestCase extends DrupalWebTestCase {
|
||||
/**
|
||||
* Skips handling of "file not found" errors.
|
||||
*/
|
||||
public function fileNotFoundErrorHandler($error_level, $message, $filename, $line, $context) {
|
||||
public function fileNotFoundErrorHandler($error_level, $message, $filename, $line) {
|
||||
// Skip error handling if this is a "file not found" error.
|
||||
if (strpos($message, 'is missing from the file system:') !== FALSE || strpos($message, 'has moved within the file system:') !== FALSE) {
|
||||
$this->getFilenameTestTriggeredError = $message;
|
||||
return;
|
||||
}
|
||||
_drupal_error_handler($error_level, $message, $filename, $line, $context);
|
||||
_drupal_error_handler($error_level, $message, $filename, $line);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -1124,9 +1124,15 @@ class DrupalHTTPRequestTestCase extends DrupalWebTestCase {
|
||||
$this->assertEqual($unable_to_parse->code, -1001, 'Returned with "-1001" error code.');
|
||||
$this->assertEqual($unable_to_parse->error, 'unable to parse URL', 'Returned with "unable to parse URL" error message.');
|
||||
|
||||
// Fetch page.
|
||||
$result = drupal_http_request(url('node', array('absolute' => TRUE)));
|
||||
// Fetch page and check that the data parameter works with both array and string.
|
||||
$data_array = array($this->randomName() => $this->randomString() . ' "\'');
|
||||
$data_string = drupal_http_build_query($data_array);
|
||||
$result = drupal_http_request(url('node', array('absolute' => TRUE)), array('data' => $data_array));
|
||||
$this->assertEqual($result->code, 200, 'Fetched page successfully.');
|
||||
$this->assertTrue(substr($result->request, -strlen($data_string)) === $data_string, 'Request ends with URL-encoded data when drupal_http_request() called using array.');
|
||||
$result = drupal_http_request(url('node', array('absolute' => TRUE)), array('data' => $data_string));
|
||||
$this->assertTrue(substr($result->request, -strlen($data_string)) === $data_string, 'Request ends with URL-encoded data when drupal_http_request() called using string.');
|
||||
|
||||
$this->drupalSetContent($result->data);
|
||||
$this->assertTitle(t('Welcome to @site-name | @site-name', array('@site-name' => variable_get('site_name', 'Drupal'))), 'Site title matches.');
|
||||
|
||||
@@ -2045,6 +2051,32 @@ class DrupalRenderTestCase extends DrupalWebTestCase {
|
||||
|
||||
// The elements should appear in output in the same order as the array.
|
||||
$this->assertTrue(strpos($output, $second) < strpos($output, $first), 'Elements were not sorted.');
|
||||
|
||||
// The order of children with same weight should be preserved.
|
||||
$element_mixed_weight = array(
|
||||
'child5' => array('#weight' => 10),
|
||||
'child3' => array('#weight' => -10),
|
||||
'child1' => array(),
|
||||
'child4' => array('#weight' => 10),
|
||||
'child2' => array(),
|
||||
'child6' => array('#weight' => 10),
|
||||
'child9' => array(),
|
||||
'child8' => array('#weight' => 10),
|
||||
'child7' => array(),
|
||||
);
|
||||
|
||||
$expected = array(
|
||||
'child3',
|
||||
'child1',
|
||||
'child2',
|
||||
'child9',
|
||||
'child7',
|
||||
'child5',
|
||||
'child4',
|
||||
'child6',
|
||||
'child8',
|
||||
);
|
||||
$this->assertEqual($expected, element_children($element_mixed_weight, TRUE), 'Order of elements with the same weight is preserved.');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2601,8 +2633,8 @@ class DrupalErrorCollectionUnitTest extends DrupalWebTestCase {
|
||||
$this->assertEqual(count($this->collectedErrors), 3, 'Three errors were collected');
|
||||
|
||||
if (count($this->collectedErrors) == 3) {
|
||||
$this->assertError($this->collectedErrors[0], 'Notice', 'error_test_generate_warnings()', 'error_test.module', 'Undefined variable: bananas');
|
||||
$this->assertError($this->collectedErrors[1], 'Warning', 'error_test_generate_warnings()', 'error_test.module', 'Division by zero');
|
||||
$this->assertError($this->collectedErrors[0], 'Notice', 'error_test_generate_warnings()', 'error_test.module', 'Object of class stdClass could not be converted to int');
|
||||
$this->assertError($this->collectedErrors[1], 'Warning', 'error_test_generate_warnings()', 'error_test.module', \PHP_VERSION_ID < 80000 ? 'Invalid argument supplied for foreach()' : 'foreach() argument must be of type array|object, string given');
|
||||
$this->assertError($this->collectedErrors[2], 'User warning', 'error_test_generate_warnings()', 'error_test.module', 'Drupal is awesome');
|
||||
}
|
||||
else {
|
||||
|
@@ -7,7 +7,7 @@ stylesheets[all][] = common_test.css
|
||||
stylesheets[print][] = common_test.print.css
|
||||
hidden = TRUE
|
||||
|
||||
; Information added by Drupal.org packaging script on 2019-05-08
|
||||
version = "7.67"
|
||||
; Information added by Drupal.org packaging script on 2021-04-21
|
||||
version = "7.80"
|
||||
project = "drupal"
|
||||
datestamp = "1557336079"
|
||||
datestamp = "1619021862"
|
||||
|
@@ -5,7 +5,7 @@ version = VERSION
|
||||
core = 7.x
|
||||
hidden = TRUE
|
||||
|
||||
; Information added by Drupal.org packaging script on 2019-05-08
|
||||
version = "7.67"
|
||||
; Information added by Drupal.org packaging script on 2021-04-21
|
||||
version = "7.80"
|
||||
project = "drupal"
|
||||
datestamp = "1557336079"
|
||||
datestamp = "1619021862"
|
||||
|
@@ -5,7 +5,7 @@ package = Testing
|
||||
version = VERSION
|
||||
hidden = TRUE
|
||||
|
||||
; Information added by Drupal.org packaging script on 2019-05-08
|
||||
version = "7.67"
|
||||
; Information added by Drupal.org packaging script on 2021-04-21
|
||||
version = "7.80"
|
||||
project = "drupal"
|
||||
datestamp = "1557336079"
|
||||
datestamp = "1619021862"
|
||||
|
@@ -217,5 +217,24 @@ function database_test_schema() {
|
||||
),
|
||||
);
|
||||
|
||||
$schema['virtual'] = array(
|
||||
'description' => 'Basic test table with a reserved name.',
|
||||
'fields' => array(
|
||||
'id' => array(
|
||||
'type' => 'serial',
|
||||
'unsigned' => TRUE,
|
||||
'not null' => TRUE,
|
||||
),
|
||||
'function' => array(
|
||||
'description' => "A column with a reserved name.",
|
||||
'type' => 'varchar',
|
||||
'length' => 255,
|
||||
'not null' => FALSE,
|
||||
'default' => '',
|
||||
),
|
||||
),
|
||||
'primary key' => array('id'),
|
||||
);
|
||||
|
||||
return $schema;
|
||||
}
|
||||
|
@@ -163,6 +163,12 @@ class DatabaseTestCase extends DrupalWebTestCase {
|
||||
'priority' => 3,
|
||||
))
|
||||
->execute();
|
||||
|
||||
db_insert('virtual')
|
||||
->fields(array(
|
||||
'function' => 'Function value 1',
|
||||
))
|
||||
->execute();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3457,7 +3463,6 @@ class DatabaseQueryTestCase extends DatabaseTestCase {
|
||||
->fetchField();
|
||||
$this->assertFalse($result, 'SQL injection attempt did not result in a row being inserted in the database table.');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -3750,21 +3755,36 @@ class DatabaseTransactionTestCase extends DatabaseTestCase {
|
||||
$transaction = db_transaction();
|
||||
$this->insertRow('row');
|
||||
$this->executeDDLStatement();
|
||||
// Rollback the outer transaction.
|
||||
|
||||
set_error_handler(array($this, 'rollBackWithoutTransactionErrorHandler'));
|
||||
try {
|
||||
// Rollback the outer transaction.
|
||||
$transaction->rollback();
|
||||
unset($transaction);
|
||||
// @TODO: an exception should be triggered here, but is not, because
|
||||
// "ROLLBACK" fails silently in MySQL if there is no transaction active.
|
||||
// $this->fail(t('Rolling back a transaction containing DDL should fail.'));
|
||||
// @see \DatabaseConnection_mysql::rollback()
|
||||
if (PHP_VERSION_ID >= 80000) {
|
||||
$this->fail('Rolling back a transaction containing DDL should produce a warning.');
|
||||
}
|
||||
}
|
||||
catch (DatabaseTransactionNoActiveException $e) {
|
||||
$this->pass('Rolling back a transaction containing DDL should fail.');
|
||||
catch (Exception $e) {
|
||||
$this->assertEqual('Rollback attempted when there is no active transaction.', $e->getMessage());
|
||||
}
|
||||
restore_error_handler();
|
||||
unset($transaction);
|
||||
$this->assertRowPresent('row');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Special handling of "rollback without transaction" errors.
|
||||
*/
|
||||
public function rollBackWithoutTransactionErrorHandler($error_level, $message, $filename, $line) {
|
||||
// Throw an exception if this is a "rollback without transaction" error.
|
||||
if (strpos($message, 'Rollback attempted when there is no active transaction.') !== FALSE ) {
|
||||
throw new Exception('Rollback attempted when there is no active transaction.');
|
||||
}
|
||||
_drupal_error_handler($error_level, $message, $filename, $line);
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert a single row into the testing table.
|
||||
*/
|
||||
@@ -4033,6 +4053,8 @@ class ConnectionUnitTest extends DrupalUnitTestCase {
|
||||
protected $monitor;
|
||||
protected $originalCount;
|
||||
|
||||
protected $skipTest;
|
||||
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Connection unit tests',
|
||||
@@ -4053,7 +4075,7 @@ class ConnectionUnitTest extends DrupalUnitTestCase {
|
||||
// @todo Make this test driver-agnostic, or find a proper way to skip it.
|
||||
// @see http://drupal.org/node/1273478
|
||||
$connection_info = Database::getConnectionInfo('default');
|
||||
$this->skipTest = (bool) $connection_info['default']['driver'] != 'mysql';
|
||||
$this->skipTest = (bool) ($connection_info['default']['driver'] != 'mysql');
|
||||
if ($this->skipTest) {
|
||||
// Insert an assertion to prevent Simpletest from interpreting the test
|
||||
// as failure.
|
||||
@@ -4238,5 +4260,178 @@ class ConnectionUnitTest extends DrupalUnitTestCase {
|
||||
// Verify that we are back to the original connection count.
|
||||
$this->assertNoConnection($id);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Test reserved keyword handling (introduced for MySQL 8+)
|
||||
*/
|
||||
class DatabaseReservedKeywordTestCase extends DatabaseTestCase {
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Reserved Keywords',
|
||||
'description' => 'Test handling of reserved keywords.',
|
||||
'group' => 'Database',
|
||||
);
|
||||
}
|
||||
|
||||
function setUp() {
|
||||
parent::setUp('database_test');
|
||||
}
|
||||
|
||||
public function testTableNameQuoting() {
|
||||
// Test db_query with {table} pattern.
|
||||
$record = db_query('SELECT * FROM {system} LIMIT 1')->fetchObject();
|
||||
$this->assertTrue(isset($record->filename), 'Successfully queried the {system} table.');
|
||||
|
||||
$connection = Database::getConnection()->getConnectionOptions();
|
||||
if ($connection['driver'] === 'sqlite') {
|
||||
// In SQLite simpletest's prefixed db tables exist in their own schema
|
||||
// (e.g. simpletest124904.system), so we cannot test the schema.{table}
|
||||
// syntax here as the table name will have the schema name prepended to it
|
||||
// when prefixes are processed.
|
||||
$this->assert(TRUE, 'Skipping schema.{system} test for SQLite.');
|
||||
}
|
||||
else {
|
||||
$database = $connection['database'];
|
||||
// Test db_query with schema.{table} pattern
|
||||
db_query('SELECT * FROM ' . $database . '.{system} LIMIT 1')->fetchObject();
|
||||
$this->assertTrue(isset($record->filename), 'Successfully queried the schema.{system} table.');
|
||||
}
|
||||
}
|
||||
|
||||
public function testSelectReservedWordTableCount() {
|
||||
$rows = db_select('virtual')
|
||||
->countQuery()
|
||||
->execute()
|
||||
->fetchField();
|
||||
$this->assertEqual($rows, 1, 'Successful count query on a table with a reserved name.');
|
||||
}
|
||||
|
||||
public function testSelectReservedWordTableSpecificField() {
|
||||
$record = db_select('virtual')
|
||||
->fields('virtual', array('function'))
|
||||
->execute()
|
||||
->fetchAssoc();
|
||||
$this->assertEqual($record['function'], 'Function value 1', 'Successfully read a field from a table with a name and column which are reserved words.');
|
||||
}
|
||||
|
||||
public function testSelectReservedWordTableAllFields() {
|
||||
$record = db_select('virtual')
|
||||
->fields('virtual')
|
||||
->execute()
|
||||
->fetchAssoc();
|
||||
$this->assertEqual($record['function'], 'Function value 1', 'Successful all_fields query from a table with a name and column which are reserved words.');
|
||||
}
|
||||
|
||||
public function testSelectReservedWordAliasCount() {
|
||||
$rows = db_select('test', 'character')
|
||||
->countQuery()
|
||||
->execute()
|
||||
->fetchField();
|
||||
$this->assertEqual($rows, 4, 'Successful count query using an alias which is a reserved word.');
|
||||
}
|
||||
|
||||
public function testSelectReservedWordAliasSpecificFields() {
|
||||
$record = db_select('test', 'high_priority')
|
||||
->fields('high_priority', array('name'))
|
||||
->condition('age', 27)
|
||||
->execute()->fetchAssoc();
|
||||
$this->assertEqual($record['name'], 'George', 'Successful query using an alias which is a reserved word.');
|
||||
}
|
||||
|
||||
public function testSelectReservedWordAliasAllFields() {
|
||||
$record = db_select('test', 'high_priority')
|
||||
->fields('high_priority')
|
||||
->condition('age', 27)
|
||||
->execute()->fetchAssoc();
|
||||
$this->assertEqual($record['name'], 'George', 'Successful all_fields query using an alias which is a reserved word.');
|
||||
}
|
||||
|
||||
public function testInsertReservedWordTable() {
|
||||
$num_records_before = db_query('SELECT COUNT(*) FROM {virtual}')->fetchField();
|
||||
db_insert('virtual')
|
||||
->fields(array(
|
||||
'function' => 'Inserted function',
|
||||
))
|
||||
->execute();
|
||||
$num_records_after = db_query('SELECT COUNT(*) FROM {virtual}')->fetchField();
|
||||
$this->assertIdentical($num_records_before + 1, (int) $num_records_after, 'Successful insert into a table with a name and column which are reserved words.');
|
||||
}
|
||||
|
||||
public function testDeleteReservedWordTable() {
|
||||
$delete = db_delete('virtual')
|
||||
->condition('function', 'Function value 1');
|
||||
$num_deleted = $delete->execute();
|
||||
$this->assertEqual($num_deleted, 1, "Deleted 1 record from a table with a name and column which are reserved words..");
|
||||
}
|
||||
|
||||
function testTruncateReservedWordTable() {
|
||||
db_truncate('virtual')->execute();
|
||||
$num_records_after = db_query("SELECT COUNT(*) FROM {virtual}")->fetchField();
|
||||
$this->assertEqual(0, $num_records_after, 'Truncated a table with a reserved name.');
|
||||
}
|
||||
|
||||
function testUpdateReservedWordTable() {
|
||||
$num_updated = db_update('virtual')
|
||||
->fields(array('function' => 'Updated function'))
|
||||
->execute();
|
||||
$this->assertIdentical($num_updated, 1, 'Updated 1 record in a table with a name and column which are reserved words.');
|
||||
}
|
||||
|
||||
function testMergeReservedWordTable() {
|
||||
$key = db_query('SELECT id FROM {virtual} LIMIT 1')->fetchField();
|
||||
$num_records_before = db_query('SELECT COUNT(*) FROM {virtual}')->fetchField();
|
||||
db_merge('virtual')
|
||||
->key(array('id' => $key))
|
||||
->fields(array('function' => 'Merged function'))
|
||||
->execute();
|
||||
$num_records_after = db_query('SELECT COUNT(*) FROM {virtual}')->fetchField();
|
||||
$this->assertIdentical($num_records_before, $num_records_after, 'Successful merge query on a table with a name and column which are reserved words.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test table prefix handling.
|
||||
*/
|
||||
class DatabaseTablePrefixTestCase extends DatabaseTestCase {
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Table prefixes',
|
||||
'description' => 'Test handling of table prefixes.',
|
||||
'group' => 'Database',
|
||||
);
|
||||
}
|
||||
|
||||
public function testSchemaDotTablePrefixes() {
|
||||
// Get a copy of the default connection options.
|
||||
$db = Database::getConnection('default', 'default');
|
||||
$connection_options = $db->getConnectionOptions();
|
||||
|
||||
if ($connection_options['driver'] === 'sqlite') {
|
||||
// In SQLite simpletest's prefixed db tables exist in their own schema
|
||||
// (e.g. simpletest124904.system), so we cannot test the schema.table
|
||||
// prefix syntax here.
|
||||
$this->assert(TRUE, 'Skipping schema.table prefixed tables test for SQLite.');
|
||||
return;
|
||||
}
|
||||
|
||||
$db_name = $connection_options['database'];
|
||||
// This prefix is usually something like simpletest12345
|
||||
$test_prefix = $connection_options['prefix']['default'];
|
||||
|
||||
// Set up a new connection with table prefixes in the form "schema.table"
|
||||
$prefixed = $connection_options;
|
||||
$prefixed['prefix'] = array(
|
||||
'default' => $test_prefix,
|
||||
'users' => $db_name . '.' . $test_prefix,
|
||||
'role' => $db_name . '.' . $test_prefix,
|
||||
);
|
||||
Database::addConnectionInfo('default', 'prefixed', $prefixed);
|
||||
|
||||
// Test that the prefixed database connection can query the prefixed tables.
|
||||
$num_users_prefixed = Database::getConnection('prefixed', 'default')->query('SELECT COUNT(1) FROM {users}')->fetchField();
|
||||
$this->assertTrue((int) $num_users_prefixed > 0, 'Successfully queried the users table using a schema.table prefix');
|
||||
$num_users_default = Database::getConnection('default', 'default')->query('SELECT COUNT(1) FROM {users}')->fetchField();
|
||||
$this->assertEqual($num_users_default, $num_users_prefixed, 'Verified results of query using a connection with schema.table prefixed tables');
|
||||
}
|
||||
}
|
||||
|
@@ -7,7 +7,7 @@ version = VERSION
|
||||
core = 7.x
|
||||
hidden = TRUE
|
||||
|
||||
; Information added by Drupal.org packaging script on 2019-05-08
|
||||
version = "7.67"
|
||||
; Information added by Drupal.org packaging script on 2021-04-21
|
||||
version = "7.80"
|
||||
project = "drupal"
|
||||
datestamp = "1557336079"
|
||||
datestamp = "1619021862"
|
||||
|
@@ -5,7 +5,7 @@ version = VERSION
|
||||
core = 7.x
|
||||
hidden = TRUE
|
||||
|
||||
; Information added by Drupal.org packaging script on 2019-05-08
|
||||
version = "7.67"
|
||||
; Information added by Drupal.org packaging script on 2021-04-21
|
||||
version = "7.80"
|
||||
project = "drupal"
|
||||
datestamp = "1557336079"
|
||||
datestamp = "1619021862"
|
||||
|
@@ -5,7 +5,7 @@ version = VERSION
|
||||
core = 7.x
|
||||
hidden = TRUE
|
||||
|
||||
; Information added by Drupal.org packaging script on 2019-05-08
|
||||
version = "7.67"
|
||||
; Information added by Drupal.org packaging script on 2021-04-21
|
||||
version = "7.80"
|
||||
project = "drupal"
|
||||
datestamp = "1557336079"
|
||||
datestamp = "1619021862"
|
||||
|
@@ -6,7 +6,7 @@ core = 7.x
|
||||
dependencies[] = entity_cache_test_dependency
|
||||
hidden = TRUE
|
||||
|
||||
; Information added by Drupal.org packaging script on 2019-05-08
|
||||
version = "7.67"
|
||||
; Information added by Drupal.org packaging script on 2021-04-21
|
||||
version = "7.80"
|
||||
project = "drupal"
|
||||
datestamp = "1557336079"
|
||||
datestamp = "1619021862"
|
||||
|
@@ -5,7 +5,7 @@ version = VERSION
|
||||
core = 7.x
|
||||
hidden = TRUE
|
||||
|
||||
; Information added by Drupal.org packaging script on 2019-05-08
|
||||
version = "7.67"
|
||||
; Information added by Drupal.org packaging script on 2021-04-21
|
||||
version = "7.80"
|
||||
project = "drupal"
|
||||
datestamp = "1557336079"
|
||||
datestamp = "1619021862"
|
||||
|
@@ -5,7 +5,7 @@ package = Testing
|
||||
version = VERSION
|
||||
hidden = TRUE
|
||||
|
||||
; Information added by Drupal.org packaging script on 2019-05-08
|
||||
version = "7.67"
|
||||
; Information added by Drupal.org packaging script on 2021-04-21
|
||||
version = "7.80"
|
||||
project = "drupal"
|
||||
datestamp = "1557336079"
|
||||
datestamp = "1619021862"
|
||||
|
@@ -5,7 +5,7 @@ version = VERSION
|
||||
core = 7.x
|
||||
hidden = TRUE
|
||||
|
||||
; Information added by Drupal.org packaging script on 2019-05-08
|
||||
version = "7.67"
|
||||
; Information added by Drupal.org packaging script on 2021-04-21
|
||||
version = "7.80"
|
||||
project = "drupal"
|
||||
datestamp = "1557336079"
|
||||
datestamp = "1619021862"
|
||||
|
@@ -22,13 +22,13 @@ class DrupalErrorHandlerTestCase extends DrupalWebTestCase {
|
||||
function testErrorHandler() {
|
||||
$error_notice = array(
|
||||
'%type' => 'Notice',
|
||||
'!message' => 'Undefined variable: bananas',
|
||||
'!message' => 'Object of class stdClass could not be converted to int',
|
||||
'%function' => 'error_test_generate_warnings()',
|
||||
'%file' => drupal_realpath('modules/simpletest/tests/error_test.module'),
|
||||
);
|
||||
$error_warning = array(
|
||||
'%type' => 'Warning',
|
||||
'!message' => 'Division by zero',
|
||||
'!message' => \PHP_VERSION_ID < 80000 ? 'Invalid argument supplied for foreach()' : 'foreach() argument must be of type array|object, string given',
|
||||
'%function' => 'error_test_generate_warnings()',
|
||||
'%file' => drupal_realpath('modules/simpletest/tests/error_test.module'),
|
||||
);
|
||||
@@ -113,4 +113,3 @@ class DrupalErrorHandlerTestCase extends DrupalWebTestCase {
|
||||
$this->assertNoRaw($message, format_string('Did not find error message: !message.', array('!message' => $message)));
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -5,7 +5,7 @@ version = VERSION
|
||||
core = 7.x
|
||||
hidden = TRUE
|
||||
|
||||
; Information added by Drupal.org packaging script on 2019-05-08
|
||||
version = "7.67"
|
||||
; Information added by Drupal.org packaging script on 2021-04-21
|
||||
version = "7.80"
|
||||
project = "drupal"
|
||||
datestamp = "1557336079"
|
||||
datestamp = "1619021862"
|
||||
|
@@ -40,9 +40,13 @@ function error_test_generate_warnings($collect_errors = FALSE) {
|
||||
// Tell Drupal error reporter to send errors to Simpletest or not.
|
||||
define('SIMPLETEST_COLLECT_ERRORS', $collect_errors);
|
||||
// This will generate a notice.
|
||||
$monkey_love = $bananas;
|
||||
$notice = new \stdClass();
|
||||
$notice == 1 ? 1 : 0;
|
||||
// This will generate a warning.
|
||||
$awesomely_big = 1/0;
|
||||
$a = '';
|
||||
foreach ($a as $b) {
|
||||
|
||||
}
|
||||
// This will generate a user error.
|
||||
trigger_error("Drupal is awesome", E_USER_WARNING);
|
||||
return "";
|
||||
|
@@ -706,7 +706,7 @@ class FileSaveUploadTest extends FileHookTestCase {
|
||||
$edit = array(
|
||||
'file_test_replace' => FILE_EXISTS_REPLACE,
|
||||
'files[file_test_upload]' => drupal_realpath($this->image->uri),
|
||||
'allow_all_extensions' => TRUE,
|
||||
'allow_all_extensions' => 'empty_array',
|
||||
);
|
||||
$this->drupalPost('file-test/upload', $edit, t('Submit'));
|
||||
$this->assertResponse(200, 'Received a 200 response for posted test file.');
|
||||
@@ -715,14 +715,35 @@ class FileSaveUploadTest extends FileHookTestCase {
|
||||
|
||||
// Check that the correct hooks were called.
|
||||
$this->assertFileHooksCalled(array('validate', 'load', 'update'));
|
||||
|
||||
// Reset the hook counters.
|
||||
file_test_reset();
|
||||
|
||||
// Now tell file_save_upload() to allow any extension and try and upload a
|
||||
// malicious file.
|
||||
$edit = array(
|
||||
'file_test_replace' => FILE_EXISTS_REPLACE,
|
||||
'files[file_test_upload]' => drupal_realpath($this->phpfile->uri),
|
||||
'is_image_file' => FALSE,
|
||||
'allow_all_extensions' => 'empty_array',
|
||||
);
|
||||
$this->drupalPost('file-test/upload', $edit, t('Submit'));
|
||||
$this->assertResponse(200, 'Received a 200 response for posted test file.');
|
||||
$message = t('For security reasons, your upload has been renamed to') . ' <em class="placeholder">' . $this->phpfile->filename . '_.txt' . '</em>';
|
||||
$this->assertRaw($message, 'Dangerous file was renamed.');
|
||||
$this->assertText('File name is php-2.php_.txt.');
|
||||
$this->assertRaw(t('File MIME type is text/plain.'), "Dangerous file's MIME type was changed.");
|
||||
$this->assertRaw(t('You WIN!'), 'Found the success message.');
|
||||
// Check that the correct hooks were called.
|
||||
$this->assertFileHooksCalled(array('validate', 'insert'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test dangerous file handling.
|
||||
*/
|
||||
function testHandleDangerousFile() {
|
||||
// Allow the .php extension and make sure it gets renamed to .txt for
|
||||
// safety. Also check to make sure its MIME type was changed.
|
||||
// Allow the .php extension and make sure it gets munged and given a .txt
|
||||
// extension for safety. Also check to make sure its MIME type was changed.
|
||||
$edit = array(
|
||||
'file_test_replace' => FILE_EXISTS_REPLACE,
|
||||
'files[file_test_upload]' => drupal_realpath($this->phpfile->uri),
|
||||
@@ -732,8 +753,9 @@ class FileSaveUploadTest extends FileHookTestCase {
|
||||
|
||||
$this->drupalPost('file-test/upload', $edit, t('Submit'));
|
||||
$this->assertResponse(200, 'Received a 200 response for posted test file.');
|
||||
$message = t('For security reasons, your upload has been renamed to') . ' <em class="placeholder">' . $this->phpfile->filename . '.txt' . '</em>';
|
||||
$message = t('For security reasons, your upload has been renamed to') . ' <em class="placeholder">' . $this->phpfile->filename . '_.txt' . '</em>';
|
||||
$this->assertRaw($message, 'Dangerous file was renamed.');
|
||||
$this->assertRaw('File name is php-2.php_.txt.');
|
||||
$this->assertRaw(t('File MIME type is text/plain.'), "Dangerous file's MIME type was changed.");
|
||||
$this->assertRaw(t('You WIN!'), 'Found the success message.');
|
||||
|
||||
@@ -755,8 +777,39 @@ class FileSaveUploadTest extends FileHookTestCase {
|
||||
// Check that the correct hooks were called.
|
||||
$this->assertFileHooksCalled(array('validate', 'insert'));
|
||||
|
||||
// Turn off insecure uploads.
|
||||
// Reset the hook counters.
|
||||
file_test_reset();
|
||||
|
||||
// Even with insecure uploads allowed, the .php file should not be uploaded
|
||||
// if it is not explicitly included in the list of allowed extensions.
|
||||
$edit['extensions'] = 'foo';
|
||||
$this->drupalPost('file-test/upload', $edit, t('Submit'));
|
||||
$this->assertResponse(200, 'Received a 200 response for posted test file.');
|
||||
$message = t('Only files with the following extensions are allowed:') . ' <em class="placeholder">' . $edit['extensions'] . '</em>';
|
||||
$this->assertRaw($message, 'Cannot upload a disallowed extension');
|
||||
$this->assertRaw(t('Epic upload FAIL!'), 'Found the failure message.');
|
||||
|
||||
// Check that the correct hooks were called.
|
||||
$this->assertFileHooksCalled(array('validate'));
|
||||
|
||||
// Reset the hook counters.
|
||||
file_test_reset();
|
||||
|
||||
// Turn off insecure uploads, then try the same thing as above (ensure that
|
||||
// the .php file is still rejected since it's not in the list of allowed
|
||||
// extensions).
|
||||
variable_set('allow_insecure_uploads', 0);
|
||||
$this->drupalPost('file-test/upload', $edit, t('Submit'));
|
||||
$this->assertResponse(200, 'Received a 200 response for posted test file.');
|
||||
$message = t('Only files with the following extensions are allowed:') . ' <em class="placeholder">' . $edit['extensions'] . '</em>';
|
||||
$this->assertRaw($message, 'Cannot upload a disallowed extension');
|
||||
$this->assertRaw(t('Epic upload FAIL!'), 'Found the failure message.');
|
||||
|
||||
// Check that the correct hooks were called.
|
||||
$this->assertFileHooksCalled(array('validate'));
|
||||
|
||||
// Reset the hook counters.
|
||||
file_test_reset();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -765,6 +818,7 @@ class FileSaveUploadTest extends FileHookTestCase {
|
||||
function testHandleFileMunge() {
|
||||
// Ensure insecure uploads are disabled for this test.
|
||||
variable_set('allow_insecure_uploads', 0);
|
||||
$original_image_uri = $this->image->uri;
|
||||
$this->image = file_move($this->image, $this->image->uri . '.foo.' . $this->image_extension);
|
||||
|
||||
// Reset the hook counters to get rid of the 'move' we just called.
|
||||
@@ -789,13 +843,33 @@ class FileSaveUploadTest extends FileHookTestCase {
|
||||
// Check that the correct hooks were called.
|
||||
$this->assertFileHooksCalled(array('validate', 'insert'));
|
||||
|
||||
// Reset the hook counters.
|
||||
file_test_reset();
|
||||
|
||||
// Ensure we don't munge the .foo extension if it is in the list of allowed
|
||||
// extensions.
|
||||
$extensions = 'foo ' . $this->image_extension;
|
||||
$edit = array(
|
||||
'files[file_test_upload]' => drupal_realpath($this->image->uri),
|
||||
'extensions' => $extensions,
|
||||
);
|
||||
|
||||
$this->drupalPost('file-test/upload', $edit, t('Submit'));
|
||||
$this->assertResponse(200, 'Received a 200 response for posted test file.');
|
||||
$this->assertNoRaw(t('For security reasons, your upload has been renamed'), 'Found no security message.');
|
||||
$this->assertRaw(t('File name is @filename', array('@filename' => 'image-test.png.foo.png')), 'File was not munged when all extensions within it are allowed.');
|
||||
$this->assertRaw(t('You WIN!'), 'Found the success message.');
|
||||
|
||||
// Check that the correct hooks were called.
|
||||
$this->assertFileHooksCalled(array('validate', 'insert'));
|
||||
|
||||
// Ensure we don't munge files if we're allowing any extension.
|
||||
// Reset the hook counters.
|
||||
file_test_reset();
|
||||
|
||||
$edit = array(
|
||||
'files[file_test_upload]' => drupal_realpath($this->image->uri),
|
||||
'allow_all_extensions' => TRUE,
|
||||
'allow_all_extensions' => 'empty_array',
|
||||
);
|
||||
|
||||
$this->drupalPost('file-test/upload', $edit, t('Submit'));
|
||||
@@ -806,6 +880,94 @@ class FileSaveUploadTest extends FileHookTestCase {
|
||||
|
||||
// Check that the correct hooks were called.
|
||||
$this->assertFileHooksCalled(array('validate', 'insert'));
|
||||
|
||||
// Test that a dangerous extension such as .php is munged even if it is in
|
||||
// the list of allowed extensions.
|
||||
$this->image = file_move($this->image, $original_image_uri . '.php.' . $this->image_extension);
|
||||
// Reset the hook counters.
|
||||
file_test_reset();
|
||||
|
||||
$extensions = 'php ' . $this->image_extension;
|
||||
$edit = array(
|
||||
'files[file_test_upload]' => drupal_realpath($this->image->uri),
|
||||
'extensions' => $extensions,
|
||||
);
|
||||
|
||||
$munged_filename = $this->image->filename;
|
||||
$munged_filename = substr($munged_filename, 0, strrpos($munged_filename, '.'));
|
||||
$munged_filename .= '_.' . $this->image_extension;
|
||||
|
||||
$this->drupalPost('file-test/upload', $edit, t('Submit'));
|
||||
$this->assertResponse(200, 'Received a 200 response for posted test file.');
|
||||
$this->assertRaw(t('For security reasons, your upload has been renamed'), 'Found security message.');
|
||||
$this->assertRaw(t('File name is @filename', array('@filename' => $munged_filename)), 'File was successfully munged.');
|
||||
$this->assertRaw(t('You WIN!'), 'Found the success message.');
|
||||
|
||||
// Check that the correct hooks were called.
|
||||
$this->assertFileHooksCalled(array('validate', 'insert'));
|
||||
|
||||
// Reset the hook counters.
|
||||
file_test_reset();
|
||||
|
||||
// Dangerous extensions are munged even when all extensions are allowed.
|
||||
$edit = array(
|
||||
'files[file_test_upload]' => drupal_realpath($this->image->uri),
|
||||
'allow_all_extensions' => 'empty_array',
|
||||
);
|
||||
|
||||
$munged_filename = $this->image->filename;
|
||||
$munged_filename = substr($munged_filename, 0, strrpos($munged_filename, '.'));
|
||||
$munged_filename .= '_.' . $this->image_extension;
|
||||
|
||||
$this->drupalPost('file-test/upload', $edit, t('Submit'));
|
||||
$this->assertResponse(200, 'Received a 200 response for posted test file.');
|
||||
$this->assertRaw(t('For security reasons, your upload has been renamed'), 'Found security message.');
|
||||
$this->assertRaw(t('File name is @filename.', array('@filename' => 'image-test.png_.php_.png_.txt')), 'File was successfully munged.');
|
||||
$this->assertRaw(t('You WIN!'), 'Found the success message.');
|
||||
|
||||
// Check that the correct hooks were called.
|
||||
$this->assertFileHooksCalled(array('validate', 'insert'));
|
||||
|
||||
// Dangerous extensions are munged if is renamed to end in .txt.
|
||||
$this->image = file_move($this->image, $original_image_uri . '.cgi.' . $this->image_extension . '.txt');
|
||||
// Reset the hook counters.
|
||||
file_test_reset();
|
||||
|
||||
$edit = array(
|
||||
'files[file_test_upload]' => drupal_realpath($this->image->uri),
|
||||
'allow_all_extensions' => 'empty_array',
|
||||
);
|
||||
|
||||
$munged_filename = $this->image->filename;
|
||||
$munged_filename = substr($munged_filename, 0, strrpos($munged_filename, '.'));
|
||||
$munged_filename .= '_.' . $this->image_extension;
|
||||
|
||||
$this->drupalPost('file-test/upload', $edit, t('Submit'));
|
||||
$this->assertResponse(200, 'Received a 200 response for posted test file.');
|
||||
$this->assertRaw(t('For security reasons, your upload has been renamed'), 'Found security message.');
|
||||
$this->assertRaw(t('File name is @filename.', array('@filename' => 'image-test.png_.cgi_.png_.txt')), 'File was successfully munged.');
|
||||
$this->assertRaw(t('You WIN!'), 'Found the success message.');
|
||||
|
||||
// Check that the correct hooks were called.
|
||||
$this->assertFileHooksCalled(array('validate', 'insert'));
|
||||
|
||||
// Reset the hook counters.
|
||||
file_test_reset();
|
||||
|
||||
// Ensure that setting $validators['file_validate_extensions'] = array('')
|
||||
// rejects all files without munging or renaming.
|
||||
$edit = array(
|
||||
'files[file_test_upload]' => drupal_realpath($this->image->uri),
|
||||
'allow_all_extensions' => 'empty_string',
|
||||
);
|
||||
|
||||
$this->drupalPost('file-test/upload', $edit, t('Submit'));
|
||||
$this->assertResponse(200, 'Received a 200 response for posted test file.');
|
||||
$this->assertNoRaw(t('For security reasons, your upload has been renamed'), 'Found security message.');
|
||||
$this->assertRaw(t('Epic upload FAIL!'), 'Found the failure message.');
|
||||
|
||||
// Check that the correct hooks were called.
|
||||
$this->assertFileHooksCalled(array('validate'));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -963,7 +1125,7 @@ class FileDirectoryTest extends FileTestCase {
|
||||
$this->fail('Expected exception not thrown');
|
||||
}
|
||||
catch (RuntimeException $e) {
|
||||
$this->assertEqual("Invalid filename '$filename'", $e->getMessage());
|
||||
$this->assertEqual("Invalid filename '$filename'", $e->getMessage(), 'The invalid filename has been detected and RuntimeException has been thrown.');
|
||||
}
|
||||
|
||||
// @TODO: Finally we copy a file into a directory several times, to ensure a properly iterating filename suffix.
|
||||
@@ -1004,7 +1166,7 @@ class FileDirectoryTest extends FileTestCase {
|
||||
$this->fail('Expected exception not thrown');
|
||||
}
|
||||
catch (RuntimeException $e) {
|
||||
$this->assertEqual("Invalid filename 'a\xFFtest\x80€.txt'", $e->getMessage());
|
||||
$this->assertEqual("Invalid filename 'a\xFFtest\x80€.txt'", $e->getMessage(), 'The invalid destination has been detected and RuntimeException has been thrown.');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2192,6 +2354,25 @@ class FileValidateTest extends FileHookTestCase {
|
||||
$this->assertEqual(file_validate($file, $failing), array('Failed', 'Badly', 'Epic fail'), 'Validating returns errors.');
|
||||
$this->assertFileHooksCalled(array('validate'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests hard-coded security check in file_validate().
|
||||
*/
|
||||
public function testInsecureExtensions() {
|
||||
$file = $this->createFile('test.php', 'Invalid PHP');
|
||||
|
||||
// Test that file_validate() will check for insecure extensions by default.
|
||||
$errors = file_validate($file, array());
|
||||
$this->assertEqual('For security reasons, your upload has been rejected.', $errors[0]);
|
||||
$this->assertFileHooksCalled(array('validate'));
|
||||
file_test_reset();
|
||||
|
||||
// Test that the 'allow_insecure_uploads' is respected.
|
||||
variable_set('allow_insecure_uploads', 1);
|
||||
$errors = file_validate($file, array());
|
||||
$this->assertEqual(array(), $errors);
|
||||
$this->assertFileHooksCalled(array('validate'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2561,7 +2742,7 @@ class FileNameMungingTest extends FileTestCase {
|
||||
|
||||
function setUp() {
|
||||
parent::setUp();
|
||||
$this->bad_extension = 'php';
|
||||
$this->bad_extension = 'foo';
|
||||
$this->name = $this->randomName() . '.' . $this->bad_extension . '.txt';
|
||||
$this->name_with_uc_ext = $this->randomName() . '.' . strtoupper($this->bad_extension) . '.txt';
|
||||
}
|
||||
@@ -2610,6 +2791,18 @@ class FileNameMungingTest extends FileTestCase {
|
||||
$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)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests unsafe extensions are munged by file_munge_filename().
|
||||
*/
|
||||
public function testMungeUnsafe() {
|
||||
$prefix = $this->randomName();
|
||||
$name = "$prefix.php.txt";
|
||||
// Put the php extension in the allowed list, but since it is in the unsafe
|
||||
// extension list, it should still be munged.
|
||||
$munged_name = file_munge_filename($name, 'php txt');
|
||||
$this->assertIdentical($munged_name, "$prefix.php_.txt", format_string('The filename (%munged) has been modified from the original (%original) if the allowed extension is also on the unsafe list.', array('%munged' => $munged_name, '%original' => $name)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure that unmunge gets your name back.
|
||||
*/
|
||||
|
@@ -6,7 +6,7 @@ core = 7.x
|
||||
files[] = file_test.module
|
||||
hidden = TRUE
|
||||
|
||||
; Information added by Drupal.org packaging script on 2019-05-08
|
||||
version = "7.67"
|
||||
; Information added by Drupal.org packaging script on 2021-04-21
|
||||
version = "7.80"
|
||||
project = "drupal"
|
||||
datestamp = "1557336079"
|
||||
datestamp = "1619021862"
|
||||
|
@@ -76,9 +76,13 @@ function _file_test_form($form, &$form_state) {
|
||||
);
|
||||
|
||||
$form['allow_all_extensions'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Allow all extensions?'),
|
||||
'#default_value' => FALSE,
|
||||
'#type' => 'radios',
|
||||
'#options' => array(
|
||||
'false' => 'No',
|
||||
'empty_array' => 'Empty array',
|
||||
'empty_string' => 'Empty string',
|
||||
),
|
||||
'#default_value' => 'false',
|
||||
);
|
||||
|
||||
$form['is_image_file'] = array(
|
||||
@@ -114,9 +118,13 @@ function _file_test_form_submit(&$form, &$form_state) {
|
||||
$validators['file_validate_is_image'] = array();
|
||||
}
|
||||
|
||||
if ($form_state['values']['allow_all_extensions']) {
|
||||
$allow = $form_state['values']['allow_all_extensions'];
|
||||
if ($allow === 'empty_array') {
|
||||
$validators['file_validate_extensions'] = array();
|
||||
}
|
||||
elseif ($allow === 'empty_string') {
|
||||
$validators['file_validate_extensions'] = array('');
|
||||
}
|
||||
elseif (!empty($form_state['values']['extensions'])) {
|
||||
$validators['file_validate_extensions'] = array($form_state['values']['extensions']);
|
||||
}
|
||||
|
@@ -5,7 +5,7 @@ version = VERSION
|
||||
core = 7.x
|
||||
hidden = TRUE
|
||||
|
||||
; Information added by Drupal.org packaging script on 2019-05-08
|
||||
version = "7.67"
|
||||
; Information added by Drupal.org packaging script on 2021-04-21
|
||||
version = "7.80"
|
||||
project = "drupal"
|
||||
datestamp = "1557336079"
|
||||
datestamp = "1619021862"
|
||||
|
@@ -240,14 +240,14 @@ class FormsTestCase extends DrupalWebTestCase {
|
||||
$values = drupal_json_decode($this->drupalPost(NULL, array('required_checkbox' => 1), t('Submit')));
|
||||
$expected_values = array(
|
||||
'disabled_checkbox_on' => 'disabled_checkbox_on',
|
||||
'disabled_checkbox_off' => '',
|
||||
'disabled_checkbox_off' => 0,
|
||||
'checkbox_on' => 'checkbox_on',
|
||||
'checkbox_off' => '',
|
||||
'checkbox_off' => 0,
|
||||
'zero_checkbox_on' => '0',
|
||||
'zero_checkbox_off' => '',
|
||||
'zero_checkbox_off' => 0,
|
||||
);
|
||||
foreach ($expected_values as $widget => $expected_value) {
|
||||
$this->assertEqual($values[$widget], $expected_value, format_string('Checkbox %widget returns expected value (expected: %expected, got: %value)', array(
|
||||
$this->assertIdentical($values[$widget], $expected_value, format_string('Checkbox %widget returns expected value (expected: %expected, got: %value)', array(
|
||||
'%widget' => var_export($widget, TRUE),
|
||||
'%expected' => var_export($expected_value, TRUE),
|
||||
'%value' => var_export($values[$widget], TRUE),
|
||||
@@ -521,6 +521,9 @@ class FormsTestCase extends DrupalWebTestCase {
|
||||
$form_state['values'] = array();
|
||||
drupal_prepare_form($form_id, $form, $form_state);
|
||||
|
||||
// Set the CSRF token in the user-provided input.
|
||||
$form_state['input']['form_token'] = $form['form_token']['#default_value'];
|
||||
|
||||
// This is the main function we want to test: it is responsible for
|
||||
// populating user supplied $form_state['input'] to sanitized
|
||||
// $form_state['values'].
|
||||
@@ -588,6 +591,19 @@ class FormElementTestCase extends DrupalWebTestCase {
|
||||
)));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests Weight form element #default_value behavior.
|
||||
*/
|
||||
public function testWeightDefaultValue() {
|
||||
$element = array(
|
||||
'#type' => 'weight',
|
||||
'#delta' => 10,
|
||||
'#default_value' => 15,
|
||||
);
|
||||
$element = form_process_weight($element);
|
||||
$this->assertTrue(isset($element['#options'][$element['#default_value']]), 'Default value exists in #options list');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -687,7 +703,7 @@ class FormValidationTestCase extends DrupalWebTestCase {
|
||||
$this->drupalPost(NULL, $edit, 'Save');
|
||||
$this->assertNoFieldByName('name', '#value changed by #validate', 'Form element #value was not altered.');
|
||||
$this->assertNoText('Name value: value changed by form_set_value() in #validate', 'Form element value in $form_state was not altered.');
|
||||
$this->assertText('The form has become outdated. Copy any unsaved work in the form below');
|
||||
$this->assertText('The form has become outdated.');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -5,7 +5,7 @@ version = VERSION
|
||||
core = 7.x
|
||||
hidden = TRUE
|
||||
|
||||
; Information added by Drupal.org packaging script on 2019-05-08
|
||||
version = "7.67"
|
||||
; Information added by Drupal.org packaging script on 2021-04-21
|
||||
version = "7.80"
|
||||
project = "drupal"
|
||||
datestamp = "1557336079"
|
||||
datestamp = "1619021862"
|
||||
|
@@ -5,7 +5,7 @@ version = VERSION
|
||||
core = 7.x
|
||||
hidden = TRUE
|
||||
|
||||
; Information added by Drupal.org packaging script on 2019-05-08
|
||||
version = "7.67"
|
||||
; Information added by Drupal.org packaging script on 2021-04-21
|
||||
version = "7.80"
|
||||
project = "drupal"
|
||||
datestamp = "1557336079"
|
||||
datestamp = "1619021862"
|
||||
|
@@ -59,6 +59,81 @@ class MailTestCase extends DrupalWebTestCase implements MailSystemInterface {
|
||||
$this->assertNull(self::$sent_message, 'Message was canceled.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks for the site name in an auto-generated From: header.
|
||||
*/
|
||||
function testFromHeader() {
|
||||
global $language;
|
||||
$default_from = variable_get('site_mail', ini_get('sendmail_from'));
|
||||
$site_name = variable_get('site_name', 'Drupal');
|
||||
|
||||
// Reset the class variable holding a copy of the last sent message.
|
||||
self::$sent_message = NULL;
|
||||
// Send an e-mail with a sender address specified.
|
||||
$from_email = 'someone_else@example.com';
|
||||
$message = drupal_mail('simpletest', 'from_test', 'from_test@example.com', $language, array(), $from_email);
|
||||
// Test that the from e-mail is just the e-mail and not the site name and
|
||||
// default sender e-mail.
|
||||
$this->assertEqual($from_email, self::$sent_message['headers']['From']);
|
||||
|
||||
// Check default behavior is only email in FROM header.
|
||||
self::$sent_message = NULL;
|
||||
// Send an e-mail and check that the From-header contains only default mail address.
|
||||
variable_del('mail_display_name_site_name');
|
||||
$message = drupal_mail('simpletest', 'from_test', 'from_test@example.com', $language);
|
||||
$this->assertEqual($default_from, self::$sent_message['headers']['From']);
|
||||
|
||||
self::$sent_message = NULL;
|
||||
// Send an e-mail and check that the From-header contains the site name.
|
||||
variable_set('mail_display_name_site_name', TRUE);
|
||||
$message = drupal_mail('simpletest', 'from_test', 'from_test@example.com', $language);
|
||||
$this->assertEqual($site_name . ' <' . $default_from . '>', self::$sent_message['headers']['From']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks for the site name in an auto-generated From: header.
|
||||
*/
|
||||
function testFromHeaderRfc2822Compliant() {
|
||||
global $language;
|
||||
$default_from = variable_get('site_mail', ini_get('sendmail_from'));
|
||||
|
||||
// Enable adding a site name to From.
|
||||
variable_set('mail_display_name_site_name', TRUE);
|
||||
|
||||
$site_names = array(
|
||||
// Simple ASCII characters.
|
||||
'Test site' => 'Test site',
|
||||
// ASCII with html entity.
|
||||
'Test & site' => 'Test & site',
|
||||
// Non-ASCII characters.
|
||||
'Tést site' => '=?UTF-8?B?VMOpc3Qgc2l0ZQ==?=',
|
||||
// Non-ASCII with special characters.
|
||||
'Tést; site' => '=?UTF-8?B?VMOpc3Q7IHNpdGU=?=',
|
||||
// Non-ASCII with html entity.
|
||||
'Tést; site' => '=?UTF-8?B?VMOpc3Q7IHNpdGU=?=',
|
||||
// ASCII with special characters.
|
||||
'Test; site' => '"Test; site"',
|
||||
// ASCII with special characters as html entity.
|
||||
'Test < site' => '"Test < site"',
|
||||
// ASCII with special characters and '\'.
|
||||
'Test; \ "site"' => '"Test; \\\\ \"site\""',
|
||||
// String already RFC-2822 compliant.
|
||||
'"Test; site"' => '"Test; site"',
|
||||
// String already RFC-2822 compliant.
|
||||
'"Test; \\\\ \"site\""' => '"Test; \\\\ \"site\""',
|
||||
);
|
||||
|
||||
foreach ($site_names as $original_name => $safe_string) {
|
||||
variable_set('site_name', $original_name);
|
||||
|
||||
// Reset the class variable holding a copy of the last sent message.
|
||||
self::$sent_message = NULL;
|
||||
// Send an e-mail and check that the From-header contains is RFC-2822 compliant.
|
||||
drupal_mail('simpletest', 'from_test', 'from_test@example.com', $language);
|
||||
$this->assertEqual($safe_string . ' <' . $default_from . '>', self::$sent_message['headers']['From']);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Concatenate and wrap the e-mail body for plain-text mails.
|
||||
*
|
||||
|
@@ -5,7 +5,7 @@ version = VERSION
|
||||
core = 7.x
|
||||
hidden = TRUE
|
||||
|
||||
; Information added by Drupal.org packaging script on 2019-05-08
|
||||
version = "7.67"
|
||||
; Information added by Drupal.org packaging script on 2021-04-21
|
||||
version = "7.80"
|
||||
project = "drupal"
|
||||
datestamp = "1557336079"
|
||||
datestamp = "1619021862"
|
||||
|
@@ -5,7 +5,7 @@ version = VERSION
|
||||
core = 7.x
|
||||
hidden = TRUE
|
||||
|
||||
; Information added by Drupal.org packaging script on 2019-05-08
|
||||
version = "7.67"
|
||||
; Information added by Drupal.org packaging script on 2021-04-21
|
||||
version = "7.80"
|
||||
project = "drupal"
|
||||
datestamp = "1557336079"
|
||||
datestamp = "1619021862"
|
||||
|
@@ -55,6 +55,22 @@ class PagerFunctionalWebTestCase extends DrupalWebTestCase {
|
||||
$this->assertPagerItems($current_page);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests theme_pager() when an empty quantity is passed.
|
||||
*/
|
||||
public function testThemePagerQuantityNotSet() {
|
||||
$variables = array(
|
||||
'element' => 0,
|
||||
'parameters' => array(),
|
||||
'quantity' => '',
|
||||
'tags' => '',
|
||||
);
|
||||
pager_default_initialize(100, 10);
|
||||
$rendered_output = theme_pager($variables);
|
||||
$this->assertNotIdentical(stripos($rendered_output, 'next'), FALSE);
|
||||
$this->assertNotIdentical(stripos($rendered_output, 'last'), FALSE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Asserts pager items and links.
|
||||
*
|
||||
@@ -156,4 +172,3 @@ class PagerFunctionalWebTestCase extends DrupalWebTestCase {
|
||||
$this->assertTrue(strpos($element['class'], $class) === FALSE, $message);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -5,7 +5,7 @@ version = VERSION
|
||||
core = 7.x
|
||||
hidden = TRUE
|
||||
|
||||
; Information added by Drupal.org packaging script on 2019-05-08
|
||||
version = "7.67"
|
||||
; Information added by Drupal.org packaging script on 2021-04-21
|
||||
version = "7.80"
|
||||
project = "drupal"
|
||||
datestamp = "1557336079"
|
||||
datestamp = "1619021862"
|
||||
|
@@ -5,7 +5,7 @@ core = 7.x
|
||||
hidden = TRUE
|
||||
package = Testing
|
||||
|
||||
; Information added by Drupal.org packaging script on 2019-05-08
|
||||
version = "7.67"
|
||||
; Information added by Drupal.org packaging script on 2021-04-21
|
||||
version = "7.80"
|
||||
project = "drupal"
|
||||
datestamp = "1557336079"
|
||||
datestamp = "1619021862"
|
||||
|
@@ -5,7 +5,7 @@ core = 7.x
|
||||
hidden = TRUE
|
||||
package = Testing
|
||||
|
||||
; Information added by Drupal.org packaging script on 2019-05-08
|
||||
version = "7.67"
|
||||
; Information added by Drupal.org packaging script on 2021-04-21
|
||||
version = "7.80"
|
||||
project = "drupal"
|
||||
datestamp = "1557336079"
|
||||
datestamp = "1619021862"
|
||||
|
354
modules/simpletest/tests/request_sanitizer.test
Normal file
354
modules/simpletest/tests/request_sanitizer.test
Normal file
@@ -0,0 +1,354 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Tests for the RequestSanitizer class.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Tests DrupalRequestSanitizer class.
|
||||
*/
|
||||
class RequestSanitizerTest extends DrupalUnitTestCase {
|
||||
|
||||
/**
|
||||
* Log of errors triggered during sanitization.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $errors;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'DrupalRequestSanitizer',
|
||||
'description' => 'Test the DrupalRequestSanitizer class',
|
||||
'group' => 'System',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
require_once DRUPAL_ROOT . '/includes/request-sanitizer.inc';
|
||||
parent::setUp();
|
||||
set_error_handler(array($this, "sanitizerTestErrorHandler"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Iterate through all the RequestSanitizerTests.
|
||||
*/
|
||||
public function testRequestSanitization() {
|
||||
foreach ($this->requestSanitizerTests() as $label => $data) {
|
||||
$this->errors = array();
|
||||
// Normalize the test parameters.
|
||||
$test = array(
|
||||
'request' => $data[0],
|
||||
'expected' => isset($data[1]) ? $data[1] : array(),
|
||||
'expected_errors' => isset($data[2]) ? $data[2] : NULL,
|
||||
'whitelist' => isset($data[3]) ? $data[3] : array(),
|
||||
);
|
||||
$this->requestSanitizationTest($test['request'], $test['expected'], $test['expected_errors'], $test['whitelist'], $label);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests RequestSanitizer class.
|
||||
*
|
||||
* @param \SanitizerTestRequest $request
|
||||
* The request to sanitize.
|
||||
* @param array $expected
|
||||
* An array of expected request parameters after sanitization.
|
||||
* @param array|null $expected_errors
|
||||
* An array of expected errors. If set to NULL then error logging is
|
||||
* disabled.
|
||||
* @param array $whitelist
|
||||
* An array of keys to whitelist and not sanitize.
|
||||
* @param string $label
|
||||
* A descriptive name for each test / group of assertions.
|
||||
*
|
||||
* @throws \ReflectionException
|
||||
*/
|
||||
public function requestSanitizationTest(SanitizerTestRequest $request, array $expected = array(), array $expected_errors = NULL, array $whitelist = array(), $label = NULL) {
|
||||
// Set up globals.
|
||||
$_GET = $request->getQuery();
|
||||
$_POST = $request->getRequest();
|
||||
$_COOKIE = $request->getCookies();
|
||||
$_REQUEST = array_merge($request->getQuery(), $request->getRequest());
|
||||
|
||||
$GLOBALS['conf']['sanitize_input_whitelist'] = $whitelist;
|
||||
$GLOBALS['conf']['sanitize_input_logging'] = is_null($expected_errors) ? FALSE : TRUE;
|
||||
if ($label !== 'already sanitized request') {
|
||||
$reflection = new \ReflectionProperty('DrupalRequestSanitizer', 'sanitized');
|
||||
$reflection->setAccessible(TRUE);
|
||||
$reflection->setValue(NULL, FALSE);
|
||||
}
|
||||
DrupalRequestSanitizer::sanitize();
|
||||
if (isset($_GET['destination'])) {
|
||||
DrupalRequestSanitizer::cleanDestination();
|
||||
}
|
||||
|
||||
// Normalise the expected data.
|
||||
$expected += array(
|
||||
'cookies' => array(),
|
||||
'query' => array(),
|
||||
'request' => array(),
|
||||
);
|
||||
|
||||
// Test PHP globals.
|
||||
$this->assertEqualLabelled($expected['cookies'], $_COOKIE, NULL, 'Other', $label . ' (COOKIE)');
|
||||
$this->assertEqualLabelled($expected['query'], $_GET, NULL, 'Other', $label . ' (GET)');
|
||||
$this->assertEqualLabelled($expected['request'], $_POST, NULL, 'Other', $label . ' (POST)');
|
||||
$expected_request = array_merge($expected['query'], $expected['request']);
|
||||
$this->assertEqualLabelled($expected_request, $_REQUEST, NULL, 'Other', $label . ' (REQUEST)');
|
||||
|
||||
// Ensure any expected errors have been triggered.
|
||||
if (!empty($expected_errors)) {
|
||||
foreach ($expected_errors as $expected_error) {
|
||||
$this->assertError($expected_error, E_USER_NOTICE, $label . ' (errors)');
|
||||
}
|
||||
}
|
||||
else {
|
||||
$this->assertEqualLabelled(array(), $this->errors, NULL, 'Other', $label . ' (errors)');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Data provider for testRequestSanitization.
|
||||
*
|
||||
* @return array
|
||||
* A list of tests to carry out.
|
||||
*/
|
||||
public function requestSanitizerTests() {
|
||||
$tests = array();
|
||||
|
||||
$request = new SanitizerTestRequest(array('q' => 'index.php'));
|
||||
$tests['no sanitization GET'] = array($request, array('query' => array('q' => 'index.php')));
|
||||
|
||||
$request = new SanitizerTestRequest(array(), array('field' => 'value'));
|
||||
$tests['no sanitization POST'] = array($request, array('request' => array('field' => 'value')));
|
||||
|
||||
$request = new SanitizerTestRequest(array(), array(), array(), array('key' => 'value'));
|
||||
$tests['no sanitization COOKIE'] = array($request, array('cookies' => array('key' => 'value')));
|
||||
|
||||
$request = new SanitizerTestRequest(array('q' => 'index.php'), array('field' => 'value'), array(), array('key' => 'value'));
|
||||
$tests['no sanitization GET, POST, COOKIE'] = array($request, array('query' => array('q' => 'index.php'), 'request' => array('field' => 'value'), 'cookies' => array('key' => 'value')));
|
||||
|
||||
$request = new SanitizerTestRequest(array('q' => 'index.php'));
|
||||
$tests['no sanitization GET log'] = array($request, array('query' => array('q' => 'index.php')), array());
|
||||
|
||||
$request = new SanitizerTestRequest(array(), array('field' => 'value'));
|
||||
$tests['no sanitization POST log'] = array($request, array('request' => array('field' => 'value')), array());
|
||||
|
||||
$request = new SanitizerTestRequest(array(), array(), array(), array('key' => 'value'));
|
||||
$tests['no sanitization COOKIE log'] = array($request, array('cookies' => array('key' => 'value')), array());
|
||||
|
||||
$request = new SanitizerTestRequest(array('#q' => 'index.php'));
|
||||
$tests['sanitization GET'] = array($request);
|
||||
|
||||
$request = new SanitizerTestRequest(array(), array('#field' => 'value'));
|
||||
$tests['sanitization POST'] = array($request);
|
||||
|
||||
$request = new SanitizerTestRequest(array(), array(), array(), array('#key' => 'value'));
|
||||
$tests['sanitization COOKIE'] = array($request);
|
||||
|
||||
$request = new SanitizerTestRequest(array('#q' => 'index.php'), array('#field' => 'value'), array(), array('#key' => 'value'));
|
||||
$tests['sanitization GET, POST, COOKIE'] = array($request);
|
||||
|
||||
$request = new SanitizerTestRequest(array('#q' => 'index.php'));
|
||||
$tests['sanitization GET log'] = array($request, array(), array('Potentially unsafe keys removed from query string parameters (GET): #q'));
|
||||
|
||||
$request = new SanitizerTestRequest(array(), array('#field' => 'value'));
|
||||
$tests['sanitization POST log'] = array($request, array(), array('Potentially unsafe keys removed from request body parameters (POST): #field'));
|
||||
|
||||
$request = new SanitizerTestRequest(array(), array(), array(), array('#key' => 'value'));
|
||||
$tests['sanitization COOKIE log'] = array($request, array(), array('Potentially unsafe keys removed from cookie parameters (COOKIE): #key'));
|
||||
|
||||
$request = new SanitizerTestRequest(array('#q' => 'index.php'), array('#field' => 'value'), array(), array('#key' => 'value'));
|
||||
$tests['sanitization GET, POST, COOKIE log'] = array($request, array(), array('Potentially unsafe keys removed from query string parameters (GET): #q', 'Potentially unsafe keys removed from request body parameters (POST): #field', 'Potentially unsafe keys removed from cookie parameters (COOKIE): #key'));
|
||||
|
||||
$request = new SanitizerTestRequest(array('q' => 'index.php', 'foo' => array('#bar' => 'foo')));
|
||||
$tests['recursive sanitization log'] = array($request, array('query' => array('q' => 'index.php', 'foo' => array())), array('Potentially unsafe keys removed from query string parameters (GET): #bar'));
|
||||
|
||||
$request = new SanitizerTestRequest(array('q' => 'index.php', 'foo' => array('#bar' => 'foo')));
|
||||
$tests['recursive no sanitization whitelist'] = array($request, array('query' => array('q' => 'index.php', 'foo' => array('#bar' => 'foo'))), array(), array('#bar'));
|
||||
|
||||
$request = new SanitizerTestRequest(array(), array('#field' => 'value'));
|
||||
$tests['no sanitization POST whitelist'] = array($request, array('request' => array('#field' => 'value')), array(), array('#field'));
|
||||
|
||||
$request = new SanitizerTestRequest(array('q' => 'index.php', 'foo' => array('#bar' => 'foo', '#foo' => 'bar')));
|
||||
$tests['recursive multiple sanitization log'] = array($request, array('query' => array('q' => 'index.php', 'foo' => array())), array('Potentially unsafe keys removed from query string parameters (GET): #bar, #foo'));
|
||||
|
||||
$request = new SanitizerTestRequest(array('#q' => 'index.php'));
|
||||
$tests['already sanitized request'] = array($request, array('query' => array('#q' => 'index.php')));
|
||||
|
||||
$request = new SanitizerTestRequest(array('destination' => 'whatever?%23test=value'));
|
||||
$tests['destination removal GET'] = array($request);
|
||||
|
||||
$request = new SanitizerTestRequest(array('destination' => 'whatever?%23test=value'));
|
||||
$tests['destination removal GET log'] = array($request, array(), array('Potentially unsafe destination removed from query string parameters (GET) because it contained the following keys: #test'));
|
||||
|
||||
$request = new SanitizerTestRequest(array('destination' => 'whatever?q[%23test]=value'));
|
||||
$tests['destination removal subkey'] = array($request);
|
||||
|
||||
$request = new SanitizerTestRequest(array('destination' => 'whatever?q[%23test]=value'));
|
||||
$tests['destination whitelist'] = array($request, array('query' => array('destination' => 'whatever?q[%23test]=value')), array(), array('#test'));
|
||||
|
||||
$request = new SanitizerTestRequest(array('destination' => "whatever?\x00bar=base&%23test=value"));
|
||||
$tests['destination removal zero byte'] = array($request);
|
||||
|
||||
$request = new SanitizerTestRequest(array('destination' => 'whatever?q=value'));
|
||||
$tests['destination kept'] = array($request, array('query' => array('destination' => 'whatever?q=value')));
|
||||
|
||||
$request = new SanitizerTestRequest(array('destination' => 'whatever'));
|
||||
$tests['destination no query'] = array($request, array('query' => array('destination' => 'whatever')));
|
||||
|
||||
return $tests;
|
||||
}
|
||||
|
||||
/**
|
||||
* Catches and logs errors to $this->errors.
|
||||
*
|
||||
* @param int $errno
|
||||
* The severity level of the error.
|
||||
* @param string $errstr
|
||||
* The error message.
|
||||
*/
|
||||
public function sanitizerTestErrorHandler($errno, $errstr) {
|
||||
$this->errors[] = compact('errno', 'errstr');
|
||||
}
|
||||
|
||||
/**
|
||||
* Asserts that the expected error has been logged.
|
||||
*
|
||||
* @param string $errstr
|
||||
* The error message.
|
||||
* @param int $errno
|
||||
* The severity level of the error.
|
||||
* @param string $label
|
||||
* The label to include with the message.
|
||||
*
|
||||
* @return bool
|
||||
* TRUE if the assertion succeeded, FALSE otherwise.
|
||||
*/
|
||||
protected function assertError($errstr, $errno, $label) {
|
||||
$label = (empty($label)) ? '' : $label . ': ';
|
||||
foreach ($this->errors as $error) {
|
||||
if ($error['errstr'] === $errstr && $error['errno'] === $errno) {
|
||||
return $this->pass($label . "Error with level $errno and message '$errstr' found");
|
||||
}
|
||||
}
|
||||
return $this->fail($label . "Error with level $errno and message '$errstr' not found in " . var_export($this->errors, TRUE));
|
||||
}
|
||||
|
||||
/**
|
||||
* Asserts two values are equal, includes a label.
|
||||
*
|
||||
* @param mixed $first
|
||||
* The first value to check.
|
||||
* @param mixed $second
|
||||
* The second value to check.
|
||||
* @param string $message
|
||||
* The message to display along with the assertion.
|
||||
* @param string $group
|
||||
* The type of assertion - examples are "Browser", "PHP".
|
||||
* @param string $label
|
||||
* The label to include with the message.
|
||||
*
|
||||
* @return bool
|
||||
* TRUE if the assertion succeeded, FALSE otherwise.
|
||||
*/
|
||||
protected function assertEqualLabelled($first, $second, $message = '', $group = 'Other', $label = '') {
|
||||
$label = (empty($label)) ? '' : $label . ': ';
|
||||
$message = $message ? $message : t('Value @first is equal to value @second.', array(
|
||||
'@first' => var_export($first, TRUE),
|
||||
'@second' => var_export($second, TRUE),
|
||||
));
|
||||
return $this->assert($first == $second, $label . $message, $group);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Basic HTTP Request class.
|
||||
*/
|
||||
class SanitizerTestRequest {
|
||||
|
||||
/**
|
||||
* The query (GET).
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $query;
|
||||
|
||||
/**
|
||||
* The request (POST).
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $request;
|
||||
|
||||
/**
|
||||
* The request attributes.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $attributes;
|
||||
|
||||
/**
|
||||
* The request cookies.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $cookies;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param array $query
|
||||
* The GET parameters.
|
||||
* @param array $request
|
||||
* The POST parameters.
|
||||
* @param array $attributes
|
||||
* The request attributes.
|
||||
* @param array $cookies
|
||||
* The COOKIE parameters.
|
||||
*/
|
||||
public function __construct(array $query = array(), array $request = array(), array $attributes = array(), array $cookies = array()) {
|
||||
$this->query = $query;
|
||||
$this->request = $request;
|
||||
$this->attributes = $attributes;
|
||||
$this->cookies = $cookies;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for $query.
|
||||
*/
|
||||
public function getQuery() {
|
||||
return $this->query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for $request.
|
||||
*/
|
||||
public function getRequest() {
|
||||
return $this->request;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for $attributes.
|
||||
*/
|
||||
public function getAttributes() {
|
||||
return $this->attributes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for $cookies.
|
||||
*/
|
||||
public function getCookies() {
|
||||
return $this->cookies;
|
||||
}
|
||||
|
||||
}
|
@@ -5,7 +5,7 @@ version = VERSION
|
||||
core = 7.x
|
||||
hidden = TRUE
|
||||
|
||||
; Information added by Drupal.org packaging script on 2019-05-08
|
||||
version = "7.67"
|
||||
; Information added by Drupal.org packaging script on 2021-04-21
|
||||
version = "7.80"
|
||||
project = "drupal"
|
||||
datestamp = "1557336079"
|
||||
datestamp = "1619021862"
|
||||
|
@@ -7,7 +7,7 @@ version = VERSION
|
||||
core = 7.x
|
||||
hidden = TRUE
|
||||
|
||||
; Information added by Drupal.org packaging script on 2019-05-08
|
||||
version = "7.67"
|
||||
; Information added by Drupal.org packaging script on 2021-04-21
|
||||
version = "7.80"
|
||||
project = "drupal"
|
||||
datestamp = "1557336079"
|
||||
datestamp = "1619021862"
|
||||
|
@@ -381,4 +381,60 @@ class SchemaTestCase extends DrupalWebTestCase {
|
||||
|
||||
db_drop_field($table_name, $field_name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the findTables() method.
|
||||
*/
|
||||
public function testFindTables() {
|
||||
// We will be testing with three tables, two of them using the default
|
||||
// prefix and the third one with an individually specified prefix.
|
||||
|
||||
// Set up a new connection with different connection info.
|
||||
$connection_info = Database::getConnectionInfo();
|
||||
|
||||
// Add per-table prefix to the second table.
|
||||
$new_connection_info = $connection_info['default'];
|
||||
$new_connection_info['prefix']['test_2_table'] = $new_connection_info['prefix']['default'] . '_shared_';
|
||||
Database::addConnectionInfo('test', 'default', $new_connection_info);
|
||||
|
||||
Database::setActiveConnection('test');
|
||||
|
||||
// Create the tables.
|
||||
$table_specification = array(
|
||||
'description' => 'Test table.',
|
||||
'fields' => array(
|
||||
'id' => array(
|
||||
'type' => 'int',
|
||||
'default' => NULL,
|
||||
),
|
||||
),
|
||||
);
|
||||
Database::getConnection()->schema()->createTable('test_1_table', $table_specification);
|
||||
Database::getConnection()->schema()->createTable('test_2_table', $table_specification);
|
||||
Database::getConnection()->schema()->createTable('the_third_table', $table_specification);
|
||||
|
||||
// Check the "all tables" syntax.
|
||||
$tables = Database::getConnection()->schema()->findTablesD8('%');
|
||||
sort($tables);
|
||||
$expected = array(
|
||||
'test_1_table',
|
||||
// This table uses a per-table prefix, yet it is returned as un-prefixed.
|
||||
'test_2_table',
|
||||
'the_third_table',
|
||||
);
|
||||
|
||||
$this->assertTrue(!array_diff($expected, $tables), 'All tables were found.');
|
||||
|
||||
// Check the restrictive syntax.
|
||||
$tables = Database::getConnection()->schema()->findTablesD8('test_%');
|
||||
sort($tables);
|
||||
$expected = array(
|
||||
'test_1_table',
|
||||
'test_2_table',
|
||||
);
|
||||
$this->assertEqual($tables, $expected, 'Two tables were found.');
|
||||
|
||||
// Go back to the initial connection.
|
||||
Database::setActiveConnection('default');
|
||||
}
|
||||
}
|
||||
|
@@ -244,6 +244,187 @@ class SessionTestCase extends DrupalWebTestCase {
|
||||
$this->assertResponse(403, 'An empty session ID is not allowed.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test absence of SameSite attribute on session cookies by default.
|
||||
*/
|
||||
function testNoSameSiteCookieAttributeDefault() {
|
||||
$user = $this->drupalCreateUser(array('access content'));
|
||||
$this->sessionReset($user->uid);
|
||||
if (\PHP_VERSION_ID < 70300) {
|
||||
$this->drupalLogin($user);
|
||||
}
|
||||
else {
|
||||
// PHP often defaults to an empty value for session.cookie_samesite but
|
||||
// that may vary, so we set an explicit empty value.
|
||||
// Send our own login POST so that we can pass a custom header to trigger
|
||||
// session_test.module to call ini_set('session.cookie_samesite', $value)
|
||||
$headers[] = 'X-Session-Cookie-Ini-Set: *EMPTY*';
|
||||
$edit = array(
|
||||
'name' => $user->name,
|
||||
'pass' => $user->pass_raw,
|
||||
);
|
||||
$this->drupalPost('user', $edit, t('Log in'), array(), $headers);
|
||||
}
|
||||
$this->assertFalse(preg_match('/SameSite=/i', $this->drupalGetHeader('Set-Cookie', TRUE)), 'Session cookie has no SameSite attribute (default).');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test SameSite attribute = None by default on Secure session cookies.
|
||||
*/
|
||||
function testSameSiteCookieAttributeNoneSecure() {
|
||||
$user = $this->drupalCreateUser(array('access content'));
|
||||
$this->sessionReset($user->uid);
|
||||
$headers = array();
|
||||
if (\PHP_VERSION_ID >= 70300) {
|
||||
// Send our own login POST so that we can pass a custom header to trigger
|
||||
// session_test.module to call ini_set('session.cookie_samesite', $value)
|
||||
$headers[] = 'X-Session-Cookie-Ini-Set: None';
|
||||
}
|
||||
// Test HTTPS session handling by altering the form action to submit the
|
||||
// login form through https.php, which creates a mock HTTPS request.
|
||||
$this->drupalGet('user');
|
||||
$form = $this->xpath('//form[@id="user-login"]');
|
||||
$form[0]['action'] = $this->httpsUrl('user');
|
||||
$edit = array('name' => $user->name, 'pass' => $user->pass_raw);
|
||||
$this->drupalPost(NULL, $edit, t('Log in'), array(), $headers);
|
||||
$this->assertTrue(preg_match('/SameSite=None/i', $this->drupalGetHeader('Set-Cookie', TRUE)), 'Session cookie is set as SameSite=None.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test SameSite attribute = None on session cookies.
|
||||
*/
|
||||
function testSameSiteCookieAttributeNone() {
|
||||
variable_set('samesite_cookie_value', 'None');
|
||||
$user = $this->drupalCreateUser(array('access content'));
|
||||
$this->sessionReset($user->uid);
|
||||
$this->drupalLogin($user);
|
||||
$this->assertTrue(preg_match('/SameSite=None/i', $this->drupalGetHeader('Set-Cookie', TRUE)), 'Session cookie is set as SameSite=None.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test SameSite attribute = Lax on session cookies.
|
||||
*/
|
||||
function testSameSiteCookieAttributeLax() {
|
||||
variable_set('samesite_cookie_value', 'Lax');
|
||||
$user = $this->drupalCreateUser(array('access content'));
|
||||
$this->sessionReset($user->uid);
|
||||
$this->drupalLogin($user);
|
||||
$this->assertTrue(preg_match('/SameSite=Lax/i', $this->drupalGetHeader('Set-Cookie', TRUE)), 'Session cookie is set as SameSite=Lax.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test SameSite attribute = Strict on session cookies.
|
||||
*/
|
||||
function testSameSiteCookieAttributeStrict() {
|
||||
variable_set('samesite_cookie_value', 'Strict');
|
||||
$user = $this->drupalCreateUser(array('access content'));
|
||||
$this->sessionReset($user->uid);
|
||||
$this->drupalLogin($user);
|
||||
$this->assertTrue(preg_match('/SameSite=Strict/i', $this->drupalGetHeader('Set-Cookie', TRUE)), 'Session cookie is set as SameSite=Strict.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test disabling the samesite attribute on session cookies via $conf
|
||||
*/
|
||||
function testSameSiteCookieAttributeDisabledViaConf() {
|
||||
$user = $this->drupalCreateUser(array('access content'));
|
||||
$this->sessionReset($user->uid);
|
||||
variable_set('samesite_cookie_value', FALSE);
|
||||
if (\PHP_VERSION_ID < 70300) {
|
||||
// There is no session.cookie_samesite in earlier PHP versions.
|
||||
$this->drupalLogin($user);
|
||||
}
|
||||
else {
|
||||
// Send our own login POST so that we can pass a custom header to trigger
|
||||
// session_test.module to call ini_set('session.cookie_samesite', $value)
|
||||
$headers[] = 'X-Session-Cookie-Ini-Set: Lax';
|
||||
$edit = array(
|
||||
'name' => $user->name,
|
||||
'pass' => $user->pass_raw,
|
||||
);
|
||||
$this->drupalPost('user', $edit, t('Log in'), array(), $headers);
|
||||
}
|
||||
$this->assertFalse(preg_match('/SameSite=/i', $this->drupalGetHeader('Set-Cookie', TRUE)), 'Session cookie has no SameSite attribute (conf).');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test disabling the samesite attribute on session cookies via php ini
|
||||
*/
|
||||
function testSameSiteCookieAttributeDisabledViaPhpIni() {
|
||||
if (\PHP_VERSION_ID < 70300) {
|
||||
// There is no session.cookie_samesite in earlier PHP versions.
|
||||
$this->pass('This test is only for PHP 7.3 and later.');
|
||||
return;
|
||||
}
|
||||
$user = $this->drupalCreateUser(array('access content'));
|
||||
// Send our own login POST so that we can pass a custom header to trigger
|
||||
// session_test.module to call ini_set('session.cookie_samesite', $value)
|
||||
$headers[] = 'X-Session-Cookie-Ini-Set: *EMPTY*';
|
||||
$edit = array(
|
||||
'name' => $user->name,
|
||||
'pass' => $user->pass_raw,
|
||||
);
|
||||
$this->drupalPost('user', $edit, t('Log in'), array(), $headers);
|
||||
$this->assertFalse(preg_match('/SameSite=/i', $this->drupalGetHeader('Set-Cookie', TRUE)), 'Session cookie has no SameSite attribute (ini).');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that a PHP setting for session.cookie_samesite is not overridden by
|
||||
* the default value in Drupal, without a samesite_cookie_value variable.
|
||||
*/
|
||||
function testSamesiteCookiePhpSettingLax() {
|
||||
if (\PHP_VERSION_ID < 70300) {
|
||||
// There is no session.cookie_samesite in earlier PHP versions.
|
||||
$this->pass('This test is only for PHP 7.3 and later.');
|
||||
return;
|
||||
}
|
||||
$user = $this->drupalCreateUser(array('access content'));
|
||||
// Send our own login POST so that we can pass a custom header to trigger
|
||||
// session_test.module to call ini_set('session.cookie_samesite', $value)
|
||||
$headers[] = 'X-Session-Cookie-Ini-Set: Lax';
|
||||
$edit = array(
|
||||
'name' => $user->name,
|
||||
'pass' => $user->pass_raw,
|
||||
);
|
||||
$this->drupalPost('user', $edit, t('Log in'), array(), $headers);
|
||||
$this->assertTrue(preg_match('/SameSite=Lax/i', $this->drupalGetHeader('Set-Cookie', TRUE)), 'Session cookie is set as SameSite=Lax.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test overriding the PHP setting for session.cookie_samesite with the
|
||||
* samesite_cookie_value variable.
|
||||
*/
|
||||
function testSamesiteCookieOverrideLaxToStrict() {
|
||||
if (\PHP_VERSION_ID < 70300) {
|
||||
// There is no session.cookie_samesite in earlier PHP versions.
|
||||
$this->pass('This test is only for PHP 7.3 and later.');
|
||||
return;
|
||||
}
|
||||
variable_set('samesite_cookie_value', 'Strict');
|
||||
$user = $this->drupalCreateUser(array('access content'));
|
||||
// Send our own login POST so that we can pass a custom header to trigger
|
||||
// session_test.module to call ini_set('session.cookie_samesite', $value)
|
||||
$headers[] = 'X-Session-Cookie-Ini-Set: Lax';
|
||||
$edit = array(
|
||||
'name' => $user->name,
|
||||
'pass' => $user->pass_raw,
|
||||
);
|
||||
$this->drupalPost('user', $edit, t('Log in'), array(), $headers);
|
||||
$this->assertTrue(preg_match('/SameSite=Strict/i', $this->drupalGetHeader('Set-Cookie', TRUE)), 'Session cookie is set as SameSite=Strict.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test SameSite attribute = Lax on set-cookie header on logout.
|
||||
*/
|
||||
function testSamesiteCookieLogoutLax() {
|
||||
variable_set('samesite_cookie_value', 'Lax');
|
||||
$user = $this->drupalCreateUser(array('access content'));
|
||||
$this->sessionReset($user->uid);
|
||||
$this->drupalLogin($user);
|
||||
$this->drupalGet('user/logout');
|
||||
$this->assertTrue(preg_match('/SameSite=Lax/i', $this->drupalGetHeader('Set-Cookie', TRUE)), 'Session cookie deletion includes SameSite=Lax.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset the cookie file so that it refers to the specified user.
|
||||
*
|
||||
@@ -285,6 +466,20 @@ class SessionTestCase extends DrupalWebTestCase {
|
||||
$this->assertIdentical($this->drupalGetHeader('X-Session-Empty'), '0', 'Session was not empty.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds a URL for submitting a mock HTTPS request to HTTP test environments.
|
||||
*
|
||||
* @param $url
|
||||
* A Drupal path such as 'user'.
|
||||
*
|
||||
* @return
|
||||
* An absolute URL.
|
||||
*/
|
||||
protected function httpsUrl($url) {
|
||||
global $base_url;
|
||||
return $base_url . '/modules/simpletest/tests/https.php?q=' . $url;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -5,7 +5,7 @@ version = VERSION
|
||||
core = 7.x
|
||||
hidden = TRUE
|
||||
|
||||
; Information added by Drupal.org packaging script on 2019-05-08
|
||||
version = "7.67"
|
||||
; Information added by Drupal.org packaging script on 2021-04-21
|
||||
version = "7.80"
|
||||
project = "drupal"
|
||||
datestamp = "1557336079"
|
||||
datestamp = "1619021862"
|
||||
|
@@ -64,6 +64,19 @@ function session_test_menu() {
|
||||
return $items;
|
||||
}
|
||||
|
||||
/**
|
||||
* It's very unusual to do anything outside of a function / hook, but in this
|
||||
* case we want to simulate a given session.cookie_samesite setting in php.ini
|
||||
* or via ini_set() in settings.php. This would almost never be a good idea
|
||||
* outside of a test scenario.
|
||||
*/
|
||||
if (isset($_SERVER['HTTP_X_SESSION_COOKIE_INI_SET'])) {
|
||||
if (in_array($_SERVER['HTTP_X_SESSION_COOKIE_INI_SET'], array('None', 'Lax', 'Strict', '*EMPTY*'))) {
|
||||
$value = ($_SERVER['HTTP_X_SESSION_COOKIE_INI_SET'] == '*EMPTY*') ? '' : $_SERVER['HTTP_X_SESSION_COOKIE_INI_SET'];
|
||||
ini_set('session.cookie_samesite', $value);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_boot().
|
||||
*/
|
||||
|
@@ -6,7 +6,7 @@ core = 7.x
|
||||
hidden = TRUE
|
||||
dependencies[] = _missing_dependency
|
||||
|
||||
; Information added by Drupal.org packaging script on 2019-05-08
|
||||
version = "7.67"
|
||||
; Information added by Drupal.org packaging script on 2021-04-21
|
||||
version = "7.80"
|
||||
project = "drupal"
|
||||
datestamp = "1557336079"
|
||||
datestamp = "1619021862"
|
||||
|
@@ -6,7 +6,7 @@ core = 7.x
|
||||
hidden = TRUE
|
||||
dependencies[] = system_incompatible_core_version_test
|
||||
|
||||
; Information added by Drupal.org packaging script on 2019-05-08
|
||||
version = "7.67"
|
||||
; Information added by Drupal.org packaging script on 2021-04-21
|
||||
version = "7.80"
|
||||
project = "drupal"
|
||||
datestamp = "1557336079"
|
||||
datestamp = "1619021862"
|
||||
|
@@ -5,7 +5,7 @@ version = VERSION
|
||||
core = 5.x
|
||||
hidden = TRUE
|
||||
|
||||
; Information added by Drupal.org packaging script on 2019-05-08
|
||||
version = "7.67"
|
||||
; Information added by Drupal.org packaging script on 2021-04-21
|
||||
version = "7.80"
|
||||
project = "drupal"
|
||||
datestamp = "1557336079"
|
||||
datestamp = "1619021862"
|
||||
|
@@ -7,7 +7,7 @@ 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 2019-05-08
|
||||
version = "7.67"
|
||||
; Information added by Drupal.org packaging script on 2021-04-21
|
||||
version = "7.80"
|
||||
project = "drupal"
|
||||
datestamp = "1557336079"
|
||||
datestamp = "1619021862"
|
||||
|
@@ -5,7 +5,7 @@ version = 1.0
|
||||
core = 7.x
|
||||
hidden = TRUE
|
||||
|
||||
; Information added by Drupal.org packaging script on 2019-05-08
|
||||
version = "7.67"
|
||||
; Information added by Drupal.org packaging script on 2021-04-21
|
||||
version = "7.80"
|
||||
project = "drupal"
|
||||
datestamp = "1557336079"
|
||||
datestamp = "1619021862"
|
||||
|
@@ -6,7 +6,7 @@ core = 7.x
|
||||
hidden = TRUE
|
||||
dependencies[] = drupal:filter
|
||||
|
||||
; Information added by Drupal.org packaging script on 2019-05-08
|
||||
version = "7.67"
|
||||
; Information added by Drupal.org packaging script on 2021-04-21
|
||||
version = "7.80"
|
||||
project = "drupal"
|
||||
datestamp = "1557336079"
|
||||
datestamp = "1619021862"
|
||||
|
@@ -6,7 +6,7 @@ core = 7.x
|
||||
files[] = system_test.module
|
||||
hidden = TRUE
|
||||
|
||||
; Information added by Drupal.org packaging script on 2019-05-08
|
||||
version = "7.67"
|
||||
; Information added by Drupal.org packaging script on 2021-04-21
|
||||
version = "7.80"
|
||||
project = "drupal"
|
||||
datestamp = "1557336079"
|
||||
datestamp = "1619021862"
|
||||
|
@@ -6,7 +6,7 @@ core = 7.x
|
||||
hidden = TRUE
|
||||
dependencies[] = taxonomy
|
||||
|
||||
; Information added by Drupal.org packaging script on 2019-05-08
|
||||
version = "7.67"
|
||||
; Information added by Drupal.org packaging script on 2021-04-21
|
||||
version = "7.80"
|
||||
project = "drupal"
|
||||
datestamp = "1557336079"
|
||||
datestamp = "1619021862"
|
||||
|
@@ -238,6 +238,27 @@ class ThemeTableTestCase extends DrupalWebTestCase {
|
||||
$this->assertNoRaw('class="odd"', 'Odd/even classes were not added because $no_striping = TRUE.');
|
||||
$this->assertNoRaw('no_striping', 'No invalid no_striping HTML attribute was printed.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that the 'footer' option works correctly.
|
||||
*/
|
||||
function testThemeTableFooter() {
|
||||
$footer = array(
|
||||
array(
|
||||
'data' => array(1),
|
||||
),
|
||||
array('Foo'),
|
||||
);
|
||||
|
||||
$table = array(
|
||||
'rows' => array(),
|
||||
'footer' => $footer,
|
||||
);
|
||||
|
||||
$this->content = theme('table', $table);
|
||||
$this->content = preg_replace('@>\s+<@', '><', $this->content);
|
||||
$this->assertRaw('<tfoot><tr><td>1</td></tr><tr><td>Foo</td></tr></tfoot>', 'Table footer found.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -5,7 +5,7 @@ version = VERSION
|
||||
core = 7.x
|
||||
hidden = TRUE
|
||||
|
||||
; Information added by Drupal.org packaging script on 2019-05-08
|
||||
version = "7.67"
|
||||
; Information added by Drupal.org packaging script on 2021-04-21
|
||||
version = "7.80"
|
||||
project = "drupal"
|
||||
datestamp = "1557336079"
|
||||
datestamp = "1619021862"
|
||||
|
@@ -6,7 +6,7 @@ hidden = TRUE
|
||||
settings[basetheme_only] = base theme value
|
||||
settings[subtheme_override] = base theme value
|
||||
|
||||
; Information added by Drupal.org packaging script on 2019-05-08
|
||||
version = "7.67"
|
||||
; Information added by Drupal.org packaging script on 2021-04-21
|
||||
version = "7.80"
|
||||
project = "drupal"
|
||||
datestamp = "1557336079"
|
||||
datestamp = "1619021862"
|
||||
|
@@ -6,7 +6,7 @@ hidden = TRUE
|
||||
|
||||
settings[subtheme_override] = subtheme value
|
||||
|
||||
; Information added by Drupal.org packaging script on 2019-05-08
|
||||
version = "7.67"
|
||||
; Information added by Drupal.org packaging script on 2021-04-21
|
||||
version = "7.80"
|
||||
project = "drupal"
|
||||
datestamp = "1557336079"
|
||||
datestamp = "1619021862"
|
||||
|
@@ -17,7 +17,7 @@ stylesheets[all][] = system.base.css
|
||||
|
||||
settings[theme_test_setting] = default value
|
||||
|
||||
; Information added by Drupal.org packaging script on 2019-05-08
|
||||
version = "7.67"
|
||||
; Information added by Drupal.org packaging script on 2021-04-21
|
||||
version = "7.80"
|
||||
project = "drupal"
|
||||
datestamp = "1557336079"
|
||||
datestamp = "1619021862"
|
||||
|
@@ -4,7 +4,7 @@ core = 7.x
|
||||
hidden = TRUE
|
||||
engine = nyan_cat
|
||||
|
||||
; Information added by Drupal.org packaging script on 2019-05-08
|
||||
version = "7.67"
|
||||
; Information added by Drupal.org packaging script on 2021-04-21
|
||||
version = "7.80"
|
||||
project = "drupal"
|
||||
datestamp = "1557336079"
|
||||
datestamp = "1619021862"
|
||||
|
@@ -5,7 +5,7 @@ version = VERSION
|
||||
core = 7.x
|
||||
hidden = TRUE
|
||||
|
||||
; Information added by Drupal.org packaging script on 2019-05-08
|
||||
version = "7.67"
|
||||
; Information added by Drupal.org packaging script on 2021-04-21
|
||||
version = "7.80"
|
||||
project = "drupal"
|
||||
datestamp = "1557336079"
|
||||
datestamp = "1619021862"
|
||||
|
@@ -5,7 +5,7 @@ version = VERSION
|
||||
core = 7.x
|
||||
hidden = TRUE
|
||||
|
||||
; Information added by Drupal.org packaging script on 2019-05-08
|
||||
version = "7.67"
|
||||
; Information added by Drupal.org packaging script on 2021-04-21
|
||||
version = "7.80"
|
||||
project = "drupal"
|
||||
datestamp = "1557336079"
|
||||
datestamp = "1619021862"
|
||||
|
@@ -5,7 +5,7 @@ version = VERSION
|
||||
core = 7.x
|
||||
hidden = TRUE
|
||||
|
||||
; Information added by Drupal.org packaging script on 2019-05-08
|
||||
version = "7.67"
|
||||
; Information added by Drupal.org packaging script on 2021-04-21
|
||||
version = "7.80"
|
||||
project = "drupal"
|
||||
datestamp = "1557336079"
|
||||
datestamp = "1619021862"
|
||||
|
@@ -5,7 +5,7 @@ version = VERSION
|
||||
core = 7.x
|
||||
hidden = TRUE
|
||||
|
||||
; Information added by Drupal.org packaging script on 2019-05-08
|
||||
version = "7.67"
|
||||
; Information added by Drupal.org packaging script on 2021-04-21
|
||||
version = "7.80"
|
||||
project = "drupal"
|
||||
datestamp = "1557336079"
|
||||
datestamp = "1619021862"
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -124,7 +124,7 @@ class LocaleUpgradePathTestCase extends UpgradePathTestCase {
|
||||
/**
|
||||
* Asserts that a page exists and is in the specified language.
|
||||
*/
|
||||
public function assertPageInLanguage($path = NULL, $langcode) {
|
||||
public function assertPageInLanguage($path, $langcode) {
|
||||
if (isset($path)) {
|
||||
$this->drupalGet($path);
|
||||
}
|
||||
|
@@ -5,7 +5,7 @@ package = Testing
|
||||
version = VERSION
|
||||
hidden = TRUE
|
||||
|
||||
; Information added by Drupal.org packaging script on 2019-05-08
|
||||
version = "7.67"
|
||||
; Information added by Drupal.org packaging script on 2021-04-21
|
||||
version = "7.80"
|
||||
project = "drupal"
|
||||
datestamp = "1557336079"
|
||||
datestamp = "1619021862"
|
||||
|
@@ -5,7 +5,7 @@ version = VERSION
|
||||
core = 7.x
|
||||
hidden = TRUE
|
||||
|
||||
; Information added by Drupal.org packaging script on 2019-05-08
|
||||
version = "7.67"
|
||||
; Information added by Drupal.org packaging script on 2021-04-21
|
||||
version = "7.80"
|
||||
project = "drupal"
|
||||
datestamp = "1557336079"
|
||||
datestamp = "1619021862"
|
||||
|
Reference in New Issue
Block a user