From 961b20062fceeb4ffe585d0cdc172da4598bebf9 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Tue, 24 Mar 2020 14:46:10 -0700 Subject: [PATCH] (NFC) Update comments in PathsTest.php --- tests/phpunit/Civi/Core/PathsTest.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/tests/phpunit/Civi/Core/PathsTest.php b/tests/phpunit/Civi/Core/PathsTest.php index 7df04dbaa4..7415442386 100644 --- a/tests/phpunit/Civi/Core/PathsTest.php +++ b/tests/phpunit/Civi/Core/PathsTest.php @@ -117,18 +117,21 @@ class PathsTest extends \CiviUnitTestCase { ]; }); $paths->register('test.goodsub', function () use ($paths) { + // This is a stand-in for how [civicrm.bower], [civicrm.packages], [civicrm.vendor] currently work. return [ 'path' => $paths->getPath('[test.base]/good/'), 'url' => $paths->getUrl('[test.base]/good/', 'absolute'), ]; }); $paths->register('test.badsub', function () use ($paths) { + // This is a stand-in for how [civicrm.bower], [civicrm.packages], [civicrm.vendor] used to work (incorrectly). return [ 'path' => $paths->getPath('[test.base]/bad/'), - // This *looks* OK, but `getUrl()` by default uses `$preferFormat==relative`. - // The problem is that `$civicrm_paths['...']['url']` is interpreted as relative to CMS root, - // and `getUrl(..., 'relative')` is interpreted as relative to HTTP root. - // So this definition misbehaves on sites where the CMS root and HTTP root are different. + // The following *looks* OK, but it's not. Note that `getUrl()` by default uses `$preferFormat==relative`. + // Both registered URLs (`register()`, `$civicrm_paths`) and outputted URLs (`getUrl()`) + // can be in relative form. However, they are relative to different bases: registrations are + // relative to CMS root, and outputted URLs are relative to HTTP root. They are often the same, but... + // on deployments where they differ, this example will misbehave. 'url' => $paths->getUrl('[test.base]/bad/'), ]; }); -- 2.25.1