Skip to content

Commit

Permalink
(NFC) Update comments in PathsTest.php
Browse files Browse the repository at this point in the history
  • Loading branch information
totten committed Mar 24, 2020
1 parent d0cda11 commit 961b200
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions tests/phpunit/Civi/Core/PathsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,18 +117,21 @@ public function testAbsoluteRelativeConversions() {
];
});
$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/'),
];
});
Expand Down

0 comments on commit 961b200

Please sign in to comment.