mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-10-22 08:05:56 +02:00
Merge pull request #2383 from creative-commoners/pulls/4.4/resources-dir-url-tests
FIX URL segment generation tests for resources dir are now accurate
This commit is contained in:
commit
1b2d417ed5
@ -30,6 +30,7 @@ use SilverStripe\View\Parsers\Diff;
|
|||||||
use SilverStripe\View\Parsers\ShortcodeParser;
|
use SilverStripe\View\Parsers\ShortcodeParser;
|
||||||
use SilverStripe\View\Parsers\URLSegmentFilter;
|
use SilverStripe\View\Parsers\URLSegmentFilter;
|
||||||
use TractorCow\Fluent\Extension\FluentSiteTreeExtension;
|
use TractorCow\Fluent\Extension\FluentSiteTreeExtension;
|
||||||
|
use const RESOURCES_DIR;
|
||||||
|
|
||||||
class SiteTreeTest extends SapphireTest
|
class SiteTreeTest extends SapphireTest
|
||||||
{
|
{
|
||||||
@ -61,7 +62,6 @@ class SiteTreeTest extends SapphireTest
|
|||||||
['Dev', 'dev-2'],
|
['Dev', 'dev-2'],
|
||||||
['Robots in disguise', 'robots-in-disguise'],
|
['Robots in disguise', 'robots-in-disguise'],
|
||||||
// segments reserved by folder name
|
// segments reserved by folder name
|
||||||
[RESOURCES_DIR, RESOURCES_DIR . '-2'],
|
|
||||||
['assets', 'assets-2'],
|
['assets', 'assets-2'],
|
||||||
['notafoldername', 'notafoldername'],
|
['notafoldername', 'notafoldername'],
|
||||||
];
|
];
|
||||||
@ -149,6 +149,48 @@ class SiteTreeTest extends SapphireTest
|
|||||||
$this->assertEquals($urlSegment, $page->URLSegment);
|
$this->assertEquals($urlSegment, $page->URLSegment);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check that explicitly setting a URL segment to the resources dir will rename it to have a -2 suffix
|
||||||
|
*/
|
||||||
|
public function testExplicitlyUsingResourcesDirForURLSegment()
|
||||||
|
{
|
||||||
|
$page = SiteTree::create(['URLSegment' => RESOURCES_DIR]);
|
||||||
|
$id = $page->write();
|
||||||
|
$page = SiteTree::get()->byID($id);
|
||||||
|
$this->assertSame(RESOURCES_DIR . '-2', $page->URLSegment);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* For legacy resources dir values ("resources"), check that URLSegments get a -2 appended
|
||||||
|
*/
|
||||||
|
public function testLegacyResourcesDirValuesHaveIncrementedValueAppended()
|
||||||
|
{
|
||||||
|
if (RESOURCES_DIR !== 'resources') {
|
||||||
|
$this->markTestSkipped('This legacy test requires RESOURCES_DIR to be "resources"');
|
||||||
|
}
|
||||||
|
|
||||||
|
$page = SiteTree::create(['Title' => 'Resources']);
|
||||||
|
$id = $page->write();
|
||||||
|
$page = SiteTree::get()->byID($id);
|
||||||
|
$this->assertSame('resources-2', $page->URLSegment);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* For new/configured resources dir values ("_resources"), check that URLSegments have the leading underscore
|
||||||
|
* removed
|
||||||
|
*/
|
||||||
|
public function testDefaultResourcesDirHasLeadingUnderscoreRemovedAndResourcesIsUsed()
|
||||||
|
{
|
||||||
|
if (RESOURCES_DIR === 'resources') {
|
||||||
|
$this->markTestSkipped('This test requires RESOURCES_DIR to be something other than "resources"');
|
||||||
|
}
|
||||||
|
|
||||||
|
$page = SiteTree::create(['Title' => '_Resources']);
|
||||||
|
$id = $page->write();
|
||||||
|
$page = SiteTree::get()->byID($id);
|
||||||
|
$this->assertSame('resources', $page->URLSegment);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test that publication copies data to SiteTree_Live
|
* Test that publication copies data to SiteTree_Live
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user