mirror of
https://github.com/silverstripe/silverstripe-subsites
synced 2024-10-22 11:05:55 +02:00
ENHANCEMENT Added URLSegment test to SubsiteTest
This commit is contained in:
parent
f6706c16ed
commit
9b1fae7901
@ -3,6 +3,36 @@
|
||||
class SubsiteTest extends SapphireTest {
|
||||
static $fixture_file = 'subsites/tests/SubsiteTest.yml';
|
||||
|
||||
function testPagesInDifferentSubsitesCanShareURLSegment() {
|
||||
$subsiteMain = $this->objFromFixture('Subsite_Template', 'main');
|
||||
$subsite1 = $this->objFromFixture('Subsite_Template', 'subsite1');
|
||||
|
||||
$pageMain = new SiteTree();
|
||||
$pageMain->URLSegment = 'testpage';
|
||||
$pageMain->write();
|
||||
$pageMain->publish('Stage', 'Live');
|
||||
|
||||
$pageMainOther = new SiteTree();
|
||||
$pageMainOther->URLSegment = 'testpage';
|
||||
$pageMainOther->write();
|
||||
$pageMainOther->publish('Stage', 'Live');
|
||||
|
||||
$this->assertNotEquals($pageMain->URLSegment, $pageMainOther->URLSegment,
|
||||
'Pages in same subsite cant share the same URL'
|
||||
);
|
||||
|
||||
Subsite::changeSubsite($subsite1->ID);
|
||||
|
||||
$pageSubsite1 = new SiteTree();
|
||||
$pageSubsite1->URLSegment = 'testpage';
|
||||
$pageSubsite1->write();
|
||||
$pageSubsite1->publish('Stage', 'Live');
|
||||
|
||||
$this->assertEquals($pageMain->URLSegment, $pageSubsite1->URLSegment,
|
||||
'Pages in different subsites can share the same URL'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new subsite from the template and verify that all the template's pages are copied
|
||||
*/
|
||||
@ -34,13 +64,13 @@ class SubsiteTest extends SapphireTest {
|
||||
|
||||
// Another test that changeSubsite is working
|
||||
Subsite::changeSubsite($subsite->ID);
|
||||
$pages = DataObject::get("SiteTree");
|
||||
|
||||
$siteHome = DataObject::get_one('SiteTree', "URLSegment = 'home'");
|
||||
$this->assertEquals($subsite->ID, $siteHome->SubsiteID);
|
||||
|
||||
// Check master page value
|
||||
$this->assertEquals($siteHome->MasterPageID, $tmplHome->ID);
|
||||
$this->assertNotNull($siteHome);
|
||||
$this->assertEquals($subsite->ID, $siteHome->SubsiteID,
|
||||
'createInstance() copies existing pages retaining the same URLSegment'
|
||||
);
|
||||
$this->assertEquals($siteHome->MasterPageID, $tmplHome->ID, 'Check master page value');
|
||||
|
||||
// Check linking of child pages
|
||||
$tmplStaff = $this->objFromFixture('SiteTree','staff');
|
||||
@ -83,6 +113,7 @@ class SubsiteTest extends SapphireTest {
|
||||
$subsite1 = $this->objFromFixture('Subsite_Template', 'subsite1');
|
||||
$subsite2 = $this->objFromFixture('Subsite_Template', 'subsite2');
|
||||
|
||||
// Cant pass member as arguments to canEdit() because of GroupSubsites
|
||||
Session::set("loggedInAs", $admin->ID);
|
||||
$this->assertTrue(
|
||||
(bool)$subsite1page->canEdit(),
|
||||
|
Loading…
Reference in New Issue
Block a user