mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
MINOR more unit tests around loose hierarchy (from r98509) (from r99062)
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@102830 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
658e24ea45
commit
a5c2a3e564
@ -1415,7 +1415,6 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
|
|
||||||
// If deleting this page, delete all its children.
|
// If deleting this page, delete all its children.
|
||||||
if(SiteTree::enforce_strict_hierarchy() && $children = $this->Children()) {
|
if(SiteTree::enforce_strict_hierarchy() && $children = $this->Children()) {
|
||||||
// if($children = $this->Children()) {
|
|
||||||
foreach($children as $child) {
|
foreach($children as $child) {
|
||||||
$child->delete();
|
$child->delete();
|
||||||
}
|
}
|
||||||
|
@ -354,6 +354,29 @@ class SiteTreeTest extends SapphireTest {
|
|||||||
SiteTree::enforce_strict_hierarchy(true);
|
SiteTree::enforce_strict_hierarchy(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function testUnpublishDoesNotDeleteChildrenWithLooseHierachyOn() {
|
||||||
|
SiteTree::enforce_strict_hierarchy(false);
|
||||||
|
$this->logInWithPermssion('ADMIN');
|
||||||
|
|
||||||
|
$pageAbout = $this->objFromFixture('Page', 'about');
|
||||||
|
$pageAbout->doPublish();
|
||||||
|
$pageStaff = $this->objFromFixture('Page', 'staff');
|
||||||
|
$pageStaff->doPublish();
|
||||||
|
$pageStaffDuplicate = $this->objFromFixture('Page', 'staffduplicate');
|
||||||
|
$pageStaffDuplicate->doPublish();
|
||||||
|
|
||||||
|
$parentPage = $this->objFromFixture('Page', 'about');
|
||||||
|
$parentPage->doUnpublish();
|
||||||
|
|
||||||
|
Versioned::reading_stage('Live');
|
||||||
|
$this->assertFalse(DataObject::get_by_id('Page', $pageAbout->ID));
|
||||||
|
$this->assertTrue(DataObject::get_by_id('Page', $pageStaff->ID) instanceof Page);
|
||||||
|
$this->assertTrue(DataObject::get_by_id('Page', $pageStaffDuplicate->ID) instanceof Page);
|
||||||
|
Versioned::reading_stage('Stage');
|
||||||
|
SiteTree::enforce_strict_hierarchy(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function testDeleteFromLiveOperatesRecursivelyStrict() {
|
function testDeleteFromLiveOperatesRecursivelyStrict() {
|
||||||
$this->logInWithPermssion('ADMIN');
|
$this->logInWithPermssion('ADMIN');
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user