diff --git a/core/modules/system/lib/Drupal/system/Tests/Common/TableSortExtenderUnitTest.php b/core/modules/system/lib/Drupal/system/Tests/Common/TableSortExtenderUnitTest.php index c7cc2a9..e42c4c6 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Common/TableSortExtenderUnitTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Common/TableSortExtenderUnitTest.php @@ -8,6 +8,7 @@ namespace Drupal\system\Tests\Common; use Drupal\simpletest\UnitTestBase; +use Symfony\Component\HttpFoundation\Request; /** * Tests unicode handling features implemented in unicode.inc. @@ -53,38 +54,44 @@ function testTableSortInit() { $headers = array('foo', 'bar', 'baz'); // Reset $_GET to prevent parameters from Simpletest and Batch API ending // up in $ts['query']. - $_GET = array(); $expected_ts = array( 'name' => 'foo', 'sql' => '', 'sort' => 'asc', 'query' => array(), ); + $request = Request::createFromGlobals(); + $request->query->replace(array()); + \Drupal::getContainer()->set('request', $request); $ts = tablesort_init($headers); $this->verbose(strtr('$ts:
!ts
', array('!ts' => check_plain(var_export($ts, TRUE))))); $this->assertEqual($ts, $expected_ts, 'Simple table headers sorted correctly.'); // Test with simple table headers plus $_GET parameters that should _not_ // override the default. - - $_GET = array( + $request = Request::createFromGlobals(); + $request->query->replace(array()); + $request->query->add(array( // This should not override the table order because only complex // headers are overridable. 'order' => 'bar', - ); + )); + \Drupal::getContainer()->set('request', $request); $ts = tablesort_init($headers); $this->verbose(strtr('$ts:
!ts
', array('!ts' => check_plain(var_export($ts, TRUE))))); $this->assertEqual($ts, $expected_ts, 'Simple table headers plus non-overriding $_GET parameters sorted correctly.'); // Test with simple table headers plus $_GET parameters that _should_ // override the default. - - $_GET = array( + $request = Request::createFromGlobals(); + $request->query->replace(array()); + $request->query->add(array( 'sort' => 'DESC', // Add an unrelated parameter to ensure that tablesort will include // it in the links that it creates. 'alpha' => 'beta', - ); + )); + \Drupal::getContainer()->set('request', $request); $expected_ts['sort'] = 'desc'; $expected_ts['query'] = array('alpha' => 'beta'); $ts = tablesort_init($headers); @@ -108,9 +115,12 @@ function testTableSortInit() { ), ); // Reset $_GET from previous assertion. - $_GET = array( + $request = Request::createFromGlobals(); + $request->query->replace(array()); + $request->query->add(array( 'order' => '2', - ); + )); + \Drupal::getContainer()->set('request', $request); $ts = tablesort_init($headers); $expected_ts = array( 'name' => '2', @@ -123,12 +133,14 @@ function testTableSortInit() { // Test complex table headers plus $_GET parameters that should _not_ // override the default. - - $_GET = array( + $request = Request::createFromGlobals(); + $request->query->replace(array()); + $request->query->add(array( // This should not override the table order because this header does not // exist. 'order' => 'bar', - ); + )); + \Drupal::getContainer()->set('request', $request); $ts = tablesort_init($headers); $expected_ts = array( 'name' => '1', @@ -138,18 +150,19 @@ function testTableSortInit() { ); $this->verbose(strtr('$ts:
!ts
', array('!ts' => check_plain(var_export($ts, TRUE))))); $this->assertEqual($ts, $expected_ts, 'Complex table headers plus non-overriding $_GET parameters sorted correctly.'); - unset($_GET['sort'], $_GET['order'], $_GET['alpha']); // Test complex table headers plus $_GET parameters that _should_ // override the default. - - $_GET = array( + $request = Request::createFromGlobals(); + $request->query->replace(array()); + $request->query->add(array( 'order' => '1', 'sort' => 'ASC', // Add an unrelated parameter to ensure that tablesort will include // it in the links that it creates. 'alpha' => 'beta', - ); + )); + \Drupal::getContainer()->set('request', $request); $expected_ts = array( 'name' => '1', 'sql' => 'one', @@ -159,7 +172,5 @@ function testTableSortInit() { $ts = tablesort_init($headers); $this->verbose(strtr('$ts:
!ts
', array('!ts' => check_plain(var_export($ts, TRUE))))); $this->assertEqual($ts, $expected_ts, 'Complex table headers plus $_GET parameters sorted correctly.'); - unset($_GET['sort'], $_GET['order'], $_GET['alpha']); - } } diff --git a/core/modules/system/lib/Drupal/system/Tests/Database/SelectPagerDefaultTest.php b/core/modules/system/lib/Drupal/system/Tests/Database/SelectPagerDefaultTest.php index 83f0640..bbd253a 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Database/SelectPagerDefaultTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Database/SelectPagerDefaultTest.php @@ -6,6 +6,7 @@ */ namespace Drupal\system\Tests\Database; +use Symfony\Component\HttpFoundation\Request; /** * Tests the pager query select extender. @@ -135,7 +136,13 @@ function testHavingPagerQuery() { * Confirms that every pager gets a valid, non-overlaping element ID. */ function testElementNumbers() { - $_GET['page'] = '3, 2, 1, 0'; + + $request = Request::createFromGlobals(); + $request->query->replace(array()); + $request->query->add(array( + 'page' => '3, 2, 1, 0', + )); + \Drupal::getContainer()->set('request', $request); $name = db_select('test', 't') ->extend('Drupal\Core\Database\Query\PagerSelectExtender') @@ -168,6 +175,5 @@ function testElementNumbers() { ->fetchField(); $this->assertEqual($name, 'John', 'Pager query #3 with a generated element ID returned the correct results.'); - unset($_GET['page']); } } diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityQueryTest.php b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityQueryTest.php index cd6fa31..771d5d8 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityQueryTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityQueryTest.php @@ -8,6 +8,7 @@ namespace Drupal\system\Tests\Entity; use Drupal\Core\Language\Language; +use Symfony\Component\HttpFoundation\Request; /** * Tests the basic Entity API. @@ -347,7 +348,12 @@ function testSort() { // Test the pager by setting element #1 to page 2 with a page size of 4. // Results will be #8-12 from above. - $_GET['page'] = '0,2'; + $request = Request::createFromGlobals(); + $request->query->replace(array()); + $request->query->add(array( + 'page' => '0,2', + )); + \Drupal::getContainer()->set('request', $request); $this->queryResults = $this->factory->get('entity_test_mulrev') ->sort("$figures.color") ->sort("$greetings.format") @@ -374,8 +380,14 @@ protected function testTableSort() { // While ordering on bundles do not give us a definite order, we can still // assert that all entities from one bundle are after the other as the // order dictates. - $_GET['sort'] = 'asc'; - $_GET['order'] = 'Type'; + $request = Request::createFromGlobals(); + $request->query->replace(array()); + $request->query->add(array( + 'sort' => 'asc', + 'order' => 'Type', + )); + \Drupal::getContainer()->set('request', $request); + $header = array( 'id' => array('data' => 'Id', 'specifier' => 'id'), 'type' => array('data' => 'Type', 'specifier' => 'type'), @@ -385,7 +397,12 @@ protected function testTableSort() { ->tableSort($header) ->execute()); $this->assertBundleOrder('asc'); - $_GET['sort'] = 'desc'; + + $request->query->add(array( + 'sort' => 'desc', + )); + \Drupal::getContainer()->set('request', $request); + $header = array( 'id' => array('data' => 'Id', 'specifier' => 'id'), 'type' => array('data' => 'Type', 'specifier' => 'type'), @@ -394,8 +411,12 @@ protected function testTableSort() { ->tableSort($header) ->execute()); $this->assertBundleOrder('desc'); + // Ordering on ID is definite, however. - $_GET['order'] = 'Id'; + $request->query->add(array( + 'order' => 'Id', + )); + \Drupal::getContainer()->set('request', $request); $this->queryResults = $this->factory->get('entity_test_mulrev') ->tableSort($header) ->execute();