diff --git a/core/modules/system/lib/Drupal/system/Tests/Pager/PagerQueryParametersTest.php b/core/modules/system/lib/Drupal/system/Tests/Pager/PagerQueryParametersTest.php deleted file mode 100644 index 0946440..0000000 --- a/core/modules/system/lib/Drupal/system/Tests/Pager/PagerQueryParametersTest.php +++ /dev/null @@ -1,71 +0,0 @@ - 'Pager query parameters functionality', - 'description' => 'Tests pager query parameters.', - 'group' => 'Pager', - ); - } - - function setUp() { - parent::setUp(); - - // Insert 300 log messages. - for ($i = 0; $i < 300; $i++) { - watchdog('pager_test', $this->randomString(), NULL, WATCHDOG_DEBUG); - } - - $this->admin_user = $this->drupalCreateUser(array( - 'access site reports', - )); - $this->drupalLogin($this->admin_user); - } - - /** - * Test proper functioning of the query parameters. - */ - function testPagerQueryParameters() { - // First page. - $this->drupalGet('pager-test/query-parameters'); - $current_page = 0; - $this->assertText(t('Pager calls: 0'), 'Initial call to pager shows 0 calls.'); - - // Go to last page, the count of pager calls need to go to 1. - $elements = $this->xpath('//li[contains(@class, :class)]/a', array(':class' => 'pager-last')); - $this->drupalGet($GLOBALS['base_root'] . $elements[0]['href'], array('external' => TRUE)); - $this->assertText(t('Pager calls: 1'), 'First link call to pager shows 1 calls.'); - - // Go back to first page, the count of pager calls need to go to 2. - $elements = $this->xpath('//li[contains(@class, :class)]/a', array(':class' => 'pager-first')); - $this->drupalGet($GLOBALS['base_root'] . $elements[0]['href'], array('external' => TRUE)); - $this->assertText(t('Pager calls: 2'), 'Second link call to pager shows 2 calls.'); - } - -} diff --git a/core/modules/system/lib/Drupal/system/Tests/Pager/PagerTest.php b/core/modules/system/lib/Drupal/system/Tests/Pager/PagerTest.php index dc8ead4..c661fe3 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Pager/PagerTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Pager/PagerTest.php @@ -2,7 +2,7 @@ /** * @file - * Definition of Drupal\system\Tests\Pager\PagerTest. + * Contains \Drupal\system\Tests\Pager\PagerTest. */ namespace Drupal\system\Tests\Pager; @@ -19,7 +19,7 @@ class PagerTest extends WebTestBase { * * @var array */ - public static $modules = array('dblog'); + public static $modules = array('dblog', 'pager_test'); protected $profile = 'testing'; @@ -68,6 +68,26 @@ function testActiveClass() { } /** + * Test proper functioning of the query parameters. + */ + protected function testPagerQueryParameters() { + // First page. + $this->drupalGet('pager-test/query-parameters'); + $current_page = 0; + $this->assertText(t('Pager calls: 0'), 'Initial call to pager shows 0 calls.'); + + // Go to last page, the count of pager calls need to go to 1. + $elements = $this->xpath('//li[contains(@class, :class)]/a', array(':class' => 'pager-last')); + $this->drupalGet($GLOBALS['base_root'] . $elements[0]['href'], array('external' => TRUE)); + $this->assertText(t('Pager calls: 1'), 'First link call to pager shows 1 calls.'); + + // Go back to first page, the count of pager calls need to go to 2. + $elements = $this->xpath('//li[contains(@class, :class)]/a', array(':class' => 'pager-first')); + $this->drupalGet($GLOBALS['base_root'] . $elements[0]['href'], array('external' => TRUE)); + $this->assertText(t('Pager calls: 2'), 'Second link call to pager shows 2 calls.'); + } + + /** * Asserts pager items and links. * * @param int $current_page diff --git a/core/modules/system/tests/modules/pager_test/lib/Drupal/pager_test/Controller/PagerTestController.php b/core/modules/system/tests/modules/pager_test/lib/Drupal/pager_test/Controller/PagerTestController.php index a66344a..3a22070 100644 --- a/core/modules/system/tests/modules/pager_test/lib/Drupal/pager_test/Controller/PagerTestController.php +++ b/core/modules/system/tests/modules/pager_test/lib/Drupal/pager_test/Controller/PagerTestController.php @@ -7,10 +7,12 @@ namespace Drupal\pager_test\Controller; +use Drupal\Core\Controller\ControllerBase; + /** * Controller routine for testing the pager. */ -class PagerTestController { +class PagerTestController extends ControllerBase { /** * Returns a pager with 'parameters' variable. @@ -40,13 +42,13 @@ public function queryParameters() { '#theme' => 'table', '#header' => $header_0, '#rows' => $rows_0, - '#empty' => t("There are no watchdog records found in the db"), + '#empty' => $this->t("There are no watchdog records found in the db"), ); // Counter of calls to the current pager. $query_params = pager_get_query_parameters(); $pager_calls = isset($query_params['pager_calls']) ? ($query_params['pager_calls'] ? $query_params['pager_calls'] : 0) : 0; - $build['l_pager_pager_0'] = array('#markup' => t('Pager calls: @pager_calls', array('@pager_calls' => $pager_calls))); + $build['l_pager_pager_0'] = array('#markup' => $this->t('Pager calls: @pager_calls', array('@pager_calls' => $pager_calls))); // Pager. $build['pager_pager_0'] = array( diff --git a/core/modules/system/tests/modules/pager_test/pager_test.info.yml b/core/modules/system/tests/modules/pager_test/pager_test.info.yml index 00db3c9..c48b31d 100644 --- a/core/modules/system/tests/modules/pager_test/pager_test.info.yml +++ b/core/modules/system/tests/modules/pager_test/pager_test.info.yml @@ -1,6 +1,6 @@ name: 'Pager Test' type: module -description: 'Support module for Pager tests.' +description: 'Support module for pager tests.' package: Testing version: VERSION core: 8.x diff --git a/core/modules/system/tests/modules/pager_test/pager_test.module b/core/modules/system/tests/modules/pager_test/pager_test.module index bfffe7d..34ccf47 100644 --- a/core/modules/system/tests/modules/pager_test/pager_test.module +++ b/core/modules/system/tests/modules/pager_test/pager_test.module @@ -2,17 +2,5 @@ /** * @file - * Helper module for Pager tests. + * Helper module for pager tests. */ - -/** - * Implements hook_menu(). - */ -function pager_test_menu() { - $items['pager-test/query-parameters'] = array( - 'title' => 'pager_test_query_parameters', - 'route_name' => 'pager_test_query_parameters', - 'type' => MENU_CALLBACK, - ); - return $items; -} diff --git a/core/modules/system/tests/modules/pager_test/pager_test.routing.yml b/core/modules/system/tests/modules/pager_test/pager_test.routing.yml index fa553d3..a25a3e1 100644 --- a/core/modules/system/tests/modules/pager_test/pager_test.routing.yml +++ b/core/modules/system/tests/modules/pager_test/pager_test.routing.yml @@ -1,5 +1,5 @@ pager_test_query_parameters: - pattern: '/pager-test/query-parameters' + path: '/pager-test/query-parameters' defaults: _content: '\Drupal\pager_test\Controller\PagerTestController::queryParameters' requirements: