From 8e0dabd20bebe55d5dd725f3015c41019cb8dbed Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Tue, 10 Mar 2020 00:23:45 -0700 Subject: [PATCH] (NFC) dev/core#1637 - Add E2E test for generation of Civi-WP backend URLs without trailing / --- tests/phpunit/E2E/Core/PathUrlTest.php | 28 ++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/tests/phpunit/E2E/Core/PathUrlTest.php b/tests/phpunit/E2E/Core/PathUrlTest.php index 8855c559e1..c555ccc6f0 100644 --- a/tests/phpunit/E2E/Core/PathUrlTest.php +++ b/tests/phpunit/E2E/Core/PathUrlTest.php @@ -88,4 +88,32 @@ class PathUrlTest extends \CiviEndToEndTestCase { $this->assertRegexp($expectContentRegex, $content); } + /** + * @link https://lab.civicrm.org/dev/core/issues/1637 + */ + public function testGetUrl_WpAdmin() { + $config = \CRM_Core_Config::singleton(); + if ($config->userFramework !== 'WordPress') { + $this->markTestSkipped('This test only applies to WP sites.'); + } + + // NOTE: For backend admin forms (eg `civicrm/contribute`) on WP, it doesn't matter + // if cleanURL's are enabled. Those are always be dirty URLs. + + // WORKAROUND: There's some issue where the URL gets a diff value in WP E2E env + // than in normal WP env. The `cv url` command seems to behave more + // representatively, though this technique is harder to inspect with xdebug. + $url = cv('url civicrm/contribute?reset=1'); + // $url = \CRM_Utils_System::url('civicrm/contribute', 'reset=1', TRUE, NULL, FALSE); + + $parts = parse_url($url); + parse_str($parts['query'], $queryParts); + $this->assertEquals('CiviCRM', $queryParts['page']); + $this->assertEquals('civicrm/contribute', $queryParts['q']); + $this->assertEquals('1', $queryParts['reset']); + + // As an E2E test for wp-demo, this assertion is specifically valid for wp-demo. + $this->assertEquals('/wp-admin/admin.php', $parts['path']); + } + } -- 2.25.1