More coverage

This commit is contained in:
Stig Lindqvist 2014-02-24 22:14:26 +13:00
parent 32378bb269
commit bfbc53c080
3 changed files with 40 additions and 8 deletions

View File

@ -387,8 +387,6 @@ class SiteTreeContentReview extends DataExtension implements PermissionProvider
$nextDate = null;
// Changed to Inherit
} elseif($this->owner->ContentReviewType == 'Inherit') {
// clear out the old value so the get_next_review_date() don't fetch it again
$this->owner->NextReviewDate = null;
// Take from Parent page
if($settings && $this->owner->parent()->exists()) {
$nextDate = $this->getReviewDate($this->owner->parent());
@ -417,7 +415,7 @@ class SiteTreeContentReview extends DataExtension implements PermissionProvider
}
// Oh yey.. now we need to update all the child pages that inherit this setting
// We can only change children after this record has been saved, otherwise the stageChildren
// We can only change children after this record has been created, otherwise the stageChildren
// method will grab all pages in the DB (this messes up unittesting)
if(!$this->owner->exists()) {
return;

View File

@ -42,6 +42,18 @@ class ContentReviewSettingsTest extends SapphireTest {
$this->assertFalse($page->getOptions());
}
public function testGetOptionObjectFromInheritedDisabled() {
$page = $this->objFromFixture('Page', 'page-2-1-1');
$this->assertEquals('Inherit', $page->ContentReviewType);
$this->assertFalse($page->getOptions());
}
public function testGetOptionObjectFromDeeplyInheritedPage() {
$page = $this->objFromFixture('Page', 'page-3-1-1-1');
$this->assertEquals('Inherit', $page->ContentReviewType);
$this->assertInstanceOf('SiteConfig', $page->getOptions());
}
public function testGetSettingsObjectFromInheritPage() {
$page = $this->objFromFixture('Page', 'page-1-1');
$this->assertEquals('Inherit', $page->ContentReviewType);

View File

@ -51,22 +51,44 @@ Page:
NextReviewDate: 2010-02-01
ContentReviewUsers: =>Member.editor
ReviewPeriodDays: 10
ParentID: 0
disabled:
Title: disabled
ContentReviewType: Disabled
ParentID: 0
inherit:
Title: inherit
ContentReviewType: Inherit
ParentID: 0
page-1:
Title: page 1
ContentReviewType: Custom
ReviewPeriodDays: 5
NextReviewDate: 2010-02-01
ParentID: 0
page-1-1:
Title: page 1 1
ContentReviewType: Inherit
ParentID: =>Page.page-1
ParentID: =>Page.page-1
page-2:
Title: page 2
ContentReviewType: Inherit
page-2-1:
Title: page 2 1
ContentReviewType: Disabled
ParentID: =>Page.page-2
page-2-1-1:
Title: page 2 1 1
ContentReviewType: Inherit
ParentID: =>Page.page-2-1
page-3:
Title: page 3
ContentReviewType: Inherit
page-3-1:
Title: page 3 1
ContentReviewType: Inherit
ParentID: =>Page.page-3
page-3-1-1:
Title: page 3 1 1
ContentReviewType: Inherit
ParentID: =>Page.page-3-1
page-3-1-1-1:
Title: page 3 1 1 1
ContentReviewType: Inherit
ParentID: =>Page.page-3-1-1