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:
Ingo Schommer 2010-04-14 03:56:51 +00:00
parent 658e24ea45
commit a5c2a3e564
2 changed files with 23 additions and 1 deletions

View File

@ -1415,7 +1415,6 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
// If deleting this page, delete all its children.
if(SiteTree::enforce_strict_hierarchy() && $children = $this->Children()) {
// if($children = $this->Children()) {
foreach($children as $child) {
$child->delete();
}

View File

@ -354,6 +354,29 @@ class SiteTreeTest extends SapphireTest {
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() {
$this->logInWithPermssion('ADMIN');