From 924fe92491b6f5ae35dabc8e1d71277f99961e33 Mon Sep 17 00:00:00 2001 From: catch <catch@35733.no-reply.drupal.org> Date: Thu, 5 Nov 2020 13:39:20 +0000 Subject: [PATCH] Issue #3164686 by mondrake, longwave, ridhimaabrol24, alexpott, larowlan: WebAssert::addressEquals() and AssertLegacyTrait::assertUrl() fail to check the querystring --- .../Drupal/FunctionalTests/WebAssertTest.php | 29 ------------------- core/tests/Drupal/Tests/WebAssert.php | 8 +---- 2 files changed, 1 insertion(+), 36 deletions(-) diff --git a/core/tests/Drupal/FunctionalTests/WebAssertTest.php b/core/tests/Drupal/FunctionalTests/WebAssertTest.php index 59348ecb9e40..c7a588ad20ed 100644 --- a/core/tests/Drupal/FunctionalTests/WebAssertTest.php +++ b/core/tests/Drupal/FunctionalTests/WebAssertTest.php @@ -3,7 +3,6 @@ namespace Drupal\FunctionalTests; use Drupal\Tests\BrowserTestBase; -use Behat\Mink\Exception\ExpectationException; use Behat\Mink\Exception\ResponseTextException; use PHPUnit\Framework\AssertionFailedError; @@ -20,7 +19,6 @@ class WebAssertTest extends BrowserTestBase { */ protected static $modules = [ 'test_page_test', - 'dblog', ]; /** @@ -56,33 +54,6 @@ public function testResponseHeaderDoesNotExist() { $this->assertSession()->responseHeaderDoesNotExist('Null-Header'); } - /** - * Tests that addressEquals distinguishes querystrings. - * - * @covers ::addressEquals - */ - public function testAddressEqualsDistinguishesQuerystrings() { - // Insert 300 log messages. - $logger = $this->container->get('logger.factory')->get('pager_test'); - for ($i = 0; $i < 300; $i++) { - $logger->debug($this->randomString()); - } - - // Get to the db log report. - $this->drupalLogin($this->drupalCreateUser([ - 'access site reports', - ])); - $this->drupalGet('admin/reports/dblog'); - $this->assertSession()->addressEquals('admin/reports/dblog'); - - // Go to the second page, we expect the querystring to change to '?page=1'. - $this->drupalGet('admin/reports/dblog', ['query' => ['page' => 1]]); - $this->assertSession()->addressEquals('admin/reports/dblog?page=1'); - $this->expectException(ExpectationException::class); - $this->expectExceptionMessage('Current page is "/admin/reports/dblog?page=1", but "/admin/reports/dblog" expected.'); - $this->assertSession()->addressEquals('admin/reports/dblog'); - } - /** * @covers ::pageTextMatchesCount */ diff --git a/core/tests/Drupal/Tests/WebAssert.php b/core/tests/Drupal/Tests/WebAssert.php index 06b95521db3e..1856ab5ffb90 100644 --- a/core/tests/Drupal/Tests/WebAssert.php +++ b/core/tests/Drupal/Tests/WebAssert.php @@ -58,13 +58,7 @@ protected function cleanUrl($url) { if (parse_url($url, PHP_URL_HOST) === NULL && strpos($url, '/') !== 0) { $url = "/$url"; } - - $parts = parse_url($url); - $fragment = empty($parts['fragment']) ? '' : '#' . $parts['fragment']; - $query = empty($parts['query']) ? '' : '?' . $parts['query']; - $path = empty($parts['path']) ? '/' : $parts['path']; - - return preg_replace('/^\/[^\.\/]+\.php\//', '/', $path) . $query . $fragment; + return parent::cleanUrl($url); } /** -- GitLab