Merge pull request #149 from dhensby/pull/135

Clear non-recurring custom date when reviewing
This commit is contained in:
Steve Boyd 2021-05-17 10:30:58 +12:00 committed by GitHub
commit fa031262fb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 0 deletions

View File

@ -495,6 +495,11 @@ class SiteTreeContentReview extends DataExtension implements PermissionProvider
$this->owner->write();
}
if ($options && $options->ReviewPeriodDays == 0) {
$this->owner->NextReviewDate = null;
$this->owner->write();
}
return (bool)$nextDateTimestamp;
}

View File

@ -10,6 +10,7 @@ use SilverStripe\ContentReview\Extensions\ContentReviewDefaultSettings;
use SilverStripe\ContentReview\Extensions\ContentReviewOwner;
use SilverStripe\ContentReview\Extensions\SiteTreeContentReview;
use SilverStripe\Forms\LiteralField;
use SilverStripe\ORM\FieldType\DBDate;
use SilverStripe\ORM\FieldType\DBDatetime;
use SilverStripe\Security\Group;
use SilverStripe\Security\Member;
@ -123,6 +124,20 @@ class SiteTreeContentReviewTest extends ContentReviewBaseTest
$this->assertEquals(null, $page->NextReviewDate);
}
public function testAdvanceReviewDate()
{
$page = new Page();
$page->Title = 'Test page';
$page->ReviewPeriodDays = 0;
// Set timestamp to a time in the past
$timestamp = DBDatetime::now()->getTimestamp() - 100000;
$page->NextReviewDate = DBDate::create()->setValue($timestamp)->Format(DBDate::ISO_DATE);
$page->write();
$page->advanceReviewDate();
$this->assertNull(Page::get()->find('Title', 'Test page')->NextReviewDate);
}
public function testAddReviewNote()
{
/** @var Member $author */