ENHANCEMENT Optimise imports, upgrade array syntax

This commit is contained in:
Raissa North 2018-01-08 16:47:31 +13:00
parent fe44baaa98
commit ad2932c418
18 changed files with 184 additions and 157 deletions

2
.gitattributes vendored
View File

@ -4,3 +4,5 @@
/.gitignore export-ignore
/.travis.yml export-ignore
/.scrutinizer.yml export-ignore
/.phpcs.xml.dist export-ignore
/.codecov.yml export-ignore

View File

@ -43,7 +43,7 @@ before_script:
script:
- if [[ $PHPUNIT_TEST ]]; then vendor/bin/phpunit; fi
- if [[ $PHPUNIT_COVERAGE_TEST ]]; then phpdbg -qrr vendor/bin/phpunit --coverage-clover=coverage.xml; fi
- if [[ $PHPCS_TEST ]]; then vendor/bin/phpcs --standard=vendor/silverstripe/framework/phpcs.xml.dist src/ tests/; fi
- if [[ $PHPCS_TEST ]]; then vendor/bin/phpcs src/ tests/; fi
- if [[ $BEHAT_TEST ]]; then vendor/bin/behat @contentreview; fi
after_success:

View File

@ -1,35 +0,0 @@
# Changelog
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).
## [3.0.2]
* fix(ContentReviewNotificationJob): Changed to use ->config() system so that the next_run_hour can be configured in YAML.
* BUG Prevent non-real draft changes forcing record to appear as changed when saved
## [3.0.1]
- Update documentation and configuration to supported module standard
- Fix documentation links
## [3.0.0]
- Replace review page form with inline form
- Update translations
- Convert to psr-2
- Change "mark as reviewed" page action panel styles
- Add report filter for only the pages a user is assigned to
- BUG Show inherited date even when inheriting settings
- API CMS Editable notification templates
## [2.1.0]
- Added translations
- Fixed a saving bug
- Renamed "reviewed" button
## [2.0.0]
Changelog added.

10
phpcs.xml.dist Normal file
View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<ruleset name="SilverStripe">
<description>CodeSniffer ruleset for SilverStripe coding conventions.</description>
<rule ref="PSR2" >
<!-- Current exclusions -->
<exclude name="PSR1.Methods.CamelCapsMethodName" />
<exclude name="PSR1.Files.SideEffects.FoundWithSymbols" />
</rule>
</ruleset>

View File

@ -3,8 +3,6 @@
[![Build status](https://travis-ci.org/silverstripe/silverstripe-contentreview.png?branch=master)](https://travis-ci.org/silverstripe/silverstripe-contentreview)
[![Code quality](https://scrutinizer-ci.com/g/silverstripe/silverstripe-contentreview/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/silverstripe/silverstripe-contentreview/?branch=master)
[![Code coverage](https://codecov.io/gh/silverstripe/silverstripe-contentreview/branch/master/graph/badge.svg)](https://codecov.io/gh/silverstripe/silverstripe-contentreview)
[![Version](http://img.shields.io/packagist/v/silverstripe/contentreview.svg)](https://packagist.org/packages/silverstripe/contentreview)
[![License](http://img.shields.io/packagist/l/silverstripe/contentreview.svg)](license.md)
This module helps keep your website content accurate and up-to-date, which keeps your users happy.
@ -20,6 +18,8 @@ There are two types of roles with this module.
* SilverStripe ^4.0
**Note:** For SilverStripe 3.x, please use the [3.x release line](https://github.com/silverstripe/silverstripe-contentreview/tree/3).
## Features
* Content reviewer will receive an email notification when a page is due for review.

View File

@ -4,9 +4,10 @@ namespace SilverStripe\ContentReview\Compatibility;
use SilverStripe\Core\ClassInfo;
use SilverStripe\Subsites\Model\Subsite;
// @todo add translatable namespace
use Translatable;
// @todo add translatable namespace
/**
* This is a helper class which lets us do things with content review data without subsites
* and translatable messing our SQL queries up.
@ -27,10 +28,10 @@ class ContentReviewCompatability
*/
public static function start()
{
$compatibility = array(
$compatibility = [
self::SUBSITES => null,
self::TRANSLATABLE => null,
);
];
if (ClassInfo::exists(Subsite::class)) {
$compatibility[self::SUBSITES] = Subsite::$disable_subsite_filter;

View File

@ -42,7 +42,8 @@ class ContentReviewDefaultSettings extends DataExtension
*/
private static $defaults = array(
'ReviewSubject' => 'Page(s) are due for content review',
'ReviewBody' => '<h2>Page(s) due for review</h2><p>There are $PagesCount pages that are due for review today by you.</p>',
'ReviewBody' => '<h2>Page(s) due for review</h2>'
. '<p>There are $PagesCount pages that are due for review today by you.</p>',
);
/**
@ -50,10 +51,10 @@ class ContentReviewDefaultSettings extends DataExtension
*
* @var array
*/
private static $many_many = array(
private static $many_many = [
'ContentReviewGroups' => Group::class,
'ContentReviewUsers' => Member::class,
);
];
/**
* Template to use for content review emails.
@ -71,7 +72,7 @@ class ContentReviewDefaultSettings extends DataExtension
*/
public function getOwnerNames()
{
$names = array();
$names = [];
foreach ($this->OwnerGroups() as $group) {
$names[] = $group->getBreadcrumbs(' > ');
@ -127,10 +128,10 @@ class ContentReviewDefaultSettings extends DataExtension
$fields->addFieldToTab('Root.ContentReview', $reviewFrequency);
$users = Permission::get_members_by_permission(array(
$users = Permission::get_members_by_permission([
'CMS_ACCESS_CMSMain',
'ADMIN',
));
]);
$usersMap = $users->map('ID', 'Title')->toArray();
asort($usersMap);
@ -141,7 +142,7 @@ class ContentReviewDefaultSettings extends DataExtension
$fields->addFieldToTab('Root.ContentReview', $userField);
$groupsMap = array();
$groupsMap = [];
foreach (Group::get() as $group) {
// Listboxfield values are escaped, use ASCII char instead of &raquo;
@ -159,7 +160,7 @@ class ContentReviewDefaultSettings extends DataExtension
// Email content
$fields->addFieldsToTab(
'Root.ContentReview',
array(
[
TextField::create('ReviewFrom', _t(__CLASS__ . '.EMAILFROM', 'From email address'))
->setDescription(_t(__CLASS__ . '.EMAILFROM_RIGHTTITLE', 'e.g: do-not-reply@site.com')),
TextField::create('ReviewSubject', _t(__CLASS__ . '.EMAILSUBJECT', 'Subject line')),
@ -168,7 +169,7 @@ class ContentReviewDefaultSettings extends DataExtension
'TemplateHelp',
$this->owner->renderWith('SilverStripe\\ContentReview\\ContentReviewAdminHelp')
),
)
]
);
}

View File

@ -13,7 +13,7 @@ class ContentReviewOwner extends DataExtension
/**
* @var array
*/
private static $many_many = array(
private static $many_many = [
"SiteTreeContentReview" => SiteTree::class,
);
];
}

View File

@ -62,40 +62,40 @@ class SiteTreeContentReview extends DataExtension implements PermissionProvider
/**
* @var array
*/
private static $db = array(
private static $db = [
"ContentReviewType" => "Enum('Inherit, Disabled, Custom', 'Inherit')",
"ReviewPeriodDays" => "Int",
"NextReviewDate" => "Date",
"LastEditedByName" => "Varchar(255)",
"OwnerNames" => "Varchar(255)",
);
];
/**
* @var array
*/
private static $defaults = array(
private static $defaults = [
"ContentReviewType" => "Inherit",
);
];
/**
* @var array
*/
private static $has_many = array(
private static $has_many = [
"ReviewLogs" => ContentReviewLog::class,
);
];
/**
* @var array
*/
private static $belongs_many_many = array(
private static $belongs_many_many = [
"ContentReviewGroups" => Group::class,
"ContentReviewUsers" => Member::class,
);
];
/**
* @var array
*/
private static $schedule = array(
private static $schedule = [
0 => "No automatic review date",
1 => "1 day",
7 => "1 week",
@ -106,7 +106,7 @@ class SiteTreeContentReview extends DataExtension implements PermissionProvider
152 => "5 months",
183 => "6 months",
365 => "12 months",
);
];
/**
* @return array
@ -129,7 +129,7 @@ class SiteTreeContentReview extends DataExtension implements PermissionProvider
$contentReviewOwners = new ArrayList();
if ($groups->count()) {
$groupIDs = array();
$groupIDs = [];
foreach ($groups as $group) {
$familyIDs = $group->collateFamilyIDs();
@ -142,7 +142,8 @@ class SiteTreeContentReview extends DataExtension implements PermissionProvider
array_unique($groupIDs);
if (count($groupIDs)) {
$groupMembers = DataObject::get(Member::class)->where("\"Group\".\"ID\" IN (" . implode(",", $groupIDs) . ")")
$groupMembers = DataObject::get(Member::class)
->where("\"Group\".\"ID\" IN (" . implode(",", $groupIDs) . ")")
->leftJoin("Group_Members", "\"Member\".\"ID\" = \"Group_Members\".\"MemberID\"")
/** @skipUpgrade */
->leftJoin('Group', "\"Group_Members\".\"GroupID\" = \"Group\".\"ID\"");
@ -178,7 +179,7 @@ class SiteTreeContentReview extends DataExtension implements PermissionProvider
*
* @param SiteTree $page
*
* @return bool|Date
* @return bool|DBDate
*/
public function getReviewDate(SiteTree $page = null)
{
@ -204,7 +205,6 @@ class SiteTreeContentReview extends DataExtension implements PermissionProvider
$nextReviewUnixSec = strtotime(' + ' . $options->ReviewPeriodDays . ' days', DBDatetime::now()->getTimestamp());
$date = DBDate::create('NextReviewDate');
$date->setValue($nextReviewUnixSec);
return $date;
}
@ -262,7 +262,7 @@ class SiteTreeContentReview extends DataExtension implements PermissionProvider
{
$options = $this->getOptions();
$names = array();
$names = [];
if (!$options) {
return "";
@ -333,18 +333,34 @@ class SiteTreeContentReview extends DataExtension implements PermissionProvider
}
$module = ModuleLoader::getModule('silverstripe/contentreview');
Requirements::javascript($module->getRelativeResourcePath('client/dist/js/contentreview.js'));
Requirements::javascript($module->getResource('client/dist/js/contentreview.js')->getRelativePath());
// Display read-only version only
if (!Permission::check("EDIT_CONTENT_REVIEW_FIELDS")) {
$schedule = self::get_schedule();
$contentOwners = ReadonlyField::create("ROContentOwners", _t(__CLASS__ . ".CONTENTOWNERS", "Content Owners"), $this->getOwnerNames());
$nextReviewAt = DateField::create('RONextReviewDate', _t(__CLASS__ . ".NEXTREVIEWDATE", "Next review date"), $this->owner->NextReviewDate);
$contentOwners = ReadonlyField::create(
"ROContentOwners",
_t(__CLASS__ . ".CONTENTOWNERS", "Content Owners"),
$this->getOwnerNames()
);
$nextReviewAt = DateField::create(
'RONextReviewDate',
_t(__CLASS__ . ".NEXTREVIEWDATE", "Next review date"),
$this->owner->NextReviewDate
);
if (!isset($schedule[$this->owner->ReviewPeriodDays])) {
$reviewFreq = ReadonlyField::create("ROReviewPeriodDays", _t(__CLASS__ . ".REVIEWFREQUENCY", "Review frequency"), $schedule[0]);
$reviewFreq = ReadonlyField::create(
"ROReviewPeriodDays",
_t(__CLASS__ . ".REVIEWFREQUENCY", "Review frequency"),
$schedule[0]
);
} else {
$reviewFreq = ReadonlyField::create("ROReviewPeriodDays", _t(__CLASS__ . ".REVIEWFREQUENCY", "Review frequency"), $schedule[$this->owner->ReviewPeriodDays]);
$reviewFreq = ReadonlyField::create(
"ROReviewPeriodDays",
_t(__CLASS__ . ".REVIEWFREQUENCY", "Review frequency"),
$schedule[$this->owner->ReviewPeriodDays]
);
}
$logConfig = GridFieldConfig::create()
@ -352,34 +368,41 @@ class SiteTreeContentReview extends DataExtension implements PermissionProvider
->addComponent($logColumns = Injector::inst()->create(GridFieldDataColumns::class));
// Cast the value to the users preferred date format
$logColumns->setFieldCasting(array(
$logColumns->setFieldCasting([
'Created' => DateTimeField::class . '->value',
));
]);
$logs = GridField::create("ROReviewNotes", "Review Notes", $this->owner->ReviewLogs(), $logConfig);
$optionsFrom = ReadonlyField::create(
"ROType",
_t(__CLASS__ . ".SETTINGSFROM", "Options are"),
$this->owner->ContentReviewType
);
$optionsFrom = ReadonlyField::create("ROType", _t(__CLASS__ . ".SETTINGSFROM", "Options are"), $this->owner->ContentReviewType);
$fields->addFieldsToTab("Root.ContentReview", array(
$fields->addFieldsToTab("Root.ContentReview", [
$contentOwners,
$nextReviewAt->performReadonlyTransformation(),
$reviewFreq,
$optionsFrom,
$logs,
));
]);
return;
}
$options = array();
$options = [];
$options["Disabled"] = _t(__CLASS__ . ".DISABLE", "Disable content review");
$options["Inherit"] = _t(__CLASS__ . ".INHERIT", "Inherit from parent page");
$options["Custom"] = _t(__CLASS__ . ".CUSTOM", "Custom settings");
$viewersOptionsField = OptionsetField::create("ContentReviewType", _t(__CLASS__ . ".OPTIONS", "Options"), $options);
$viewersOptionsField = OptionsetField::create(
"ContentReviewType",
_t(__CLASS__ . ".OPTIONS", "Options"),
$options
);
$users = Permission::get_members_by_permission(array("CMS_ACCESS_CMSMain", "ADMIN"));
$users = Permission::get_members_by_permission(["CMS_ACCESS_CMSMain", "ADMIN"]);
$usersMap = $users->map("ID", "Title")->toArray();
@ -390,7 +413,7 @@ class SiteTreeContentReview extends DataExtension implements PermissionProvider
->setAttribute("data-placeholder", _t(__CLASS__ . ".ADDUSERS", "Add users"))
->setDescription(_t(__CLASS__ . '.OWNERUSERSDESCRIPTION', 'Page owners that are responsible for reviews'));
$groupsMap = array();
$groupsMap = [];
foreach (Group::get() as $group) {
$groupsMap[$group->ID] = $group->getBreadcrumbs(" > ");
@ -411,11 +434,19 @@ class SiteTreeContentReview extends DataExtension implements PermissionProvider
self::get_schedule()
)
->addExtraClass('custom-setting')
->setDescription(_t(__CLASS__ . ".REVIEWFREQUENCYDESCRIPTION", "The review date will be set to this far in the future whenever the page is published"));
->setDescription(_t(
__CLASS__ . ".REVIEWFREQUENCYDESCRIPTION",
"The review date will be set to this far in the future whenever the page is published"
));
$notesField = GridField::create("ReviewNotes", "Review Notes", $this->owner->ReviewLogs(), GridFieldConfig_RecordEditor::create());
$notesField = GridField::create(
"ReviewNotes",
"Review Notes",
$this->owner->ReviewLogs(),
GridFieldConfig_RecordEditor::create()
);
$fields->addFieldsToTab("Root.ContentReview", array(
$fields->addFieldsToTab("Root.ContentReview", [
HeaderField::create('ContentReviewHeader', _t(__CLASS__ . ".REVIEWHEADER", "Content review"), 2),
$viewersOptionsField,
CompositeField::create(
@ -424,9 +455,13 @@ class SiteTreeContentReview extends DataExtension implements PermissionProvider
$reviewDate,
$reviewFrequency
)->addExtraClass("review-settings"),
ReadonlyField::create("ROContentOwners", _t(__CLASS__ . ".CONTENTOWNERS", "Content Owners"), $this->getOwnerNames()),
ReadonlyField::create(
"ROContentOwners",
_t(__CLASS__ . ".CONTENTOWNERS", "Content Owners"),
$this->getOwnerNames()
),
$notesField,
));
]);
}
/**
@ -493,7 +528,8 @@ class SiteTreeContentReview extends DataExtension implements PermissionProvider
if (!$options
// Options can be a SiteConfig with different extension applied
|| (!$options->hasExtension(__CLASS__) && !$options->hasExtension(ContentReviewDefaultSettings::class))
|| (!$options->hasExtension(__CLASS__)
&& !$options->hasExtension(ContentReviewDefaultSettings::class))
) {
return false;
}
@ -615,13 +651,13 @@ class SiteTreeContentReview extends DataExtension implements PermissionProvider
*/
public function providePermissions()
{
return array(
"EDIT_CONTENT_REVIEW_FIELDS" => array(
return [
"EDIT_CONTENT_REVIEW_FIELDS" => [
"name" => "Set content owners and review dates",
"category" => _t("SilverStripe\\Security\\Permission.CONTENT_CATEGORY", "Content permissions"),
"sort" => 50,
),
);
],
];
}
/**
@ -638,7 +674,10 @@ class SiteTreeContentReview extends DataExtension implements PermissionProvider
$nextRun = Injector::inst()->create(ContentReviewNotificationJob::class);
$runHour = Config::inst()->get(ContentReviewNotificationJob::class, "first_run_hour");
$firstRunTime = date("Y-m-d H:i:s", mktime($runHour, 0, 0, date("m"), date("d") + 1, date("y")));
$firstRunTime = date(
"Y-m-d H:i:s",
mktime($runHour, 0, 0, date("m"), date("d") + 1, date("y"))
);
singleton(QueuedJobService::class)->queueJob(
$nextRun,

View File

@ -8,13 +8,12 @@ use SilverStripe\CMS\Model\VirtualPage;
use SilverStripe\ContentReview\Compatibility\ContentReviewCompatability;
use SilverStripe\ContentReview\Extensions\ContentReviewOwner;
use SilverStripe\Core\ClassInfo;
use SilverStripe\Core\Config\Config;
use SilverStripe\Core\Convert;
use SilverStripe\Forms\CheckboxField;
use SilverStripe\Forms\DateField;
use SilverStripe\Forms\FieldList;
use SilverStripe\i18n\i18n;
use SilverStripe\ORM\FieldType\DBDatetime;
use SilverStripe\ORM\SS_List;
use SilverStripe\Reports\Report;
use SilverStripe\Security\Security;
use SilverStripe\SiteConfig\SiteConfig;
@ -81,12 +80,12 @@ class PagesDueForReviewReport extends Report
$linkPath = parse_url($linkBase, PHP_URL_PATH);
$linkQuery = parse_url($linkBase, PHP_URL_QUERY);
$fields = array(
"Title" => array(
$fields = [
"Title" => [
"title" => "Page name",
"formatting" => "<a href='{$linkPath}/\$ID?{$linkQuery}' title='Edit page'>\$value</a>"
),
"NextReviewDate" => array(
],
"NextReviewDate" => [
"title" => "Review Date",
"casting" => "Date->Full",
"formatting" => function ($value, $item) {
@ -102,12 +101,12 @@ class PagesDueForReviewReport extends Report
}
return $value;
}
),
"OwnerNames" => array(
],
"OwnerNames" => [
"title" => "Owner"
),
],
"LastEditedByName" => "Last edited by",
"AbsoluteLink" => array(
"AbsoluteLink" => [
"title" => "URL",
"formatting" => function ($value, $item) {
$liveLink = $item->AbsoluteLiveLink;
@ -120,8 +119,8 @@ class PagesDueForReviewReport extends Report
$liveLink ? "(live)" : "(draft)"
);
}
),
"ContentReviewType" => array(
],
"ContentReviewType" => [
"title" => "Settings are",
"formatting" => function ($value, $item) use ($linkPath, $linkQuery) {
if ($item->ContentReviewType == "Inherit") {
@ -141,8 +140,8 @@ class PagesDueForReviewReport extends Report
return $value;
}
),
);
],
];
return $fields;
}
@ -152,7 +151,7 @@ class PagesDueForReviewReport extends Report
*
* @return SS_List
*/
public function sourceRecords($params = array())
public function sourceRecords($params = [])
{
Versioned::set_stage(Versioned::DRAFT);

View File

@ -2,15 +2,16 @@
namespace SilverStripe\ContentReview\Reports;
use SilverStripe\Forms\CheckboxField;
use SilverStripe\Forms\FieldList;
use SilverStripe\CMS\Controllers\CMSPageEditController;
use SilverStripe\CMS\Model\SiteTree;
use SilverStripe\CMS\Model\VirtualPage;
use SilverStripe\ContentReview\Compatibility\ContentReviewCompatability;
use SilverStripe\Core\ClassInfo;
use SilverStripe\Forms\CheckboxField;
use SilverStripe\Forms\FieldList;
use SilverStripe\ORM\ArrayList;
use SilverStripe\ORM\DataObject;
use SilverStripe\ORM\SS_List;
use SilverStripe\Reports\Report;
use SilverStripe\SiteConfig\SiteConfig;
use SilverStripe\Versioned\Versioned;
@ -48,20 +49,20 @@ class PagesWithoutReviewScheduleReport extends Report
$linkPath = parse_url($linkBase, PHP_URL_PATH);
$linkQuery = parse_url($linkBase, PHP_URL_QUERY);
$fields = array(
"Title" => array(
$fields = [
"Title" => [
"title" => "Page name",
"formatting" => "<a href='{$linkPath}/\$ID?{$linkQuery}' title='Edit page'>\$value</a>",
),
"NextReviewDate" => array(
],
"NextReviewDate" => [
"title" => "Review Date",
"casting" => "Date->Full",
),
"OwnerNames" => array(
],
"OwnerNames" => [
"title" => "Owner",
),
],
"LastEditedByName" => "Last edited by",
"AbsoluteLink" => array(
"AbsoluteLink" => [
"title" => "URL",
"formatting" => function ($value, $item) {
$liveLink = $item->AbsoluteLiveLink;
@ -74,8 +75,8 @@ class PagesWithoutReviewScheduleReport extends Report
$liveLink ? "(live)" : "(draft)"
);
},
),
"ContentReviewType" => array(
],
"ContentReviewType" => [
"title" => "Settings are",
"formatting" => function ($value, $item) use ($linkPath, $linkQuery) {
if ($item->ContentReviewType == "Inherit") {
@ -95,8 +96,8 @@ class PagesWithoutReviewScheduleReport extends Report
return $value;
},
),
);
],
];
return $fields;
}
@ -106,7 +107,7 @@ class PagesWithoutReviewScheduleReport extends Report
*
* @return SS_List
*/
public function sourceRecords($params = array())
public function sourceRecords($params = [])
{
Versioned::set_stage(Versioned::DRAFT);

View File

@ -50,7 +50,7 @@ class ContentReviewEmails extends BuildTask
*/
protected function getOverduePagesForOwners(SS_List $pages)
{
$overduePages = array();
$overduePages = [];
foreach ($pages as $page) {
if (!$page->canBeReviewedBy()) {

View File

@ -25,7 +25,8 @@ abstract class ContentReviewBaseTest extends FunctionalTest
/*
* We set the locale for pages explicitly, because if we don't, then we get into a situation
* where the page takes on the tester's (your) locale, and any calls to simulate subsequent requests
* (e.g. $this->post()) do not seem to get passed the tester's locale, but instead fallback to the default locale.
* (e.g. $this->post()) do not seem to get passed the tester's locale,
* but instead fallback to the default locale.
*
* So we set the pages locale to be the default locale, which will then match any subsequent requests.
*

View File

@ -40,7 +40,7 @@ class ContentReviewCMSPageEditControllerTest extends ContentReviewBaseTest
public function testReviewedThrowsExceptionWithNoRecordID()
{
$this->setExpectedException(HTTPResponse_Exception::class);
$this->expectException(HTTPResponse_Exception::class);
/** @var CMSPageEditController|ContentReviewCMSExtension $controller */
$controller = new CMSPageEditController();
@ -55,7 +55,7 @@ class ContentReviewCMSPageEditControllerTest extends ContentReviewBaseTest
public function testReviewedThrowsExceptionWithWrongRecordID()
{
$this->setExpectedException(HTTPResponse_Exception::class);
$this->expectException(HTTPResponse_Exception::class);
/** @var CMSPageEditController|ContentReviewCMSExtension $controller */
$controller = new CMSPageEditController();

View File

@ -70,7 +70,8 @@ class ContentReviewNotificationTest extends SapphireTest
$email = $this->findEmail($ToEmail, null, $Subject);
$this->assertNotNull($email, "Email haven't been sent.");
$this->assertContains(
"<h1>$Subject</h1><p>There are $PagesCount pages that are due for review today by you, $ToFirstName.</p><p>This email was sent to $ToEmail</p>",
"<h1>$Subject</h1><p>There are $PagesCount pages that are due for review today by you, "
. "$ToFirstName.</p><p>This email was sent to $ToEmail</p>",
$email['HtmlContent']
);
$this->assertContains('Staff', $email['HtmlContent']);

View File

@ -47,27 +47,27 @@ class ContentReviewReportTest extends FunctionalTest
$report->columns();
$report->title();
$results = $report->sourceRecords(array(
$results = $report->sourceRecords([
"ReviewDateAfter" => "2010-01-01",
"ReviewDateBefore" => "2010-12-12",
));
]);
$this->assertEquals(array(
$this->assertEquals([
"Contact Us Child",
"Home",
"About Us",
"Staff",
"Contact Us",
), $results->column("Title"));
], $results->column("Title"));
DBDatetime::set_mock_now("2010-02-13 00:00:00");
$results = $report->sourceRecords(array());
$results = $report->sourceRecords([]);
$this->assertEquals(array(
$this->assertEquals([
"Home",
"About Us",
), $results->column("Title"));
], $results->column("Title"));
DBDatetime::clear_mock_now();
}
@ -87,11 +87,11 @@ class ContentReviewReportTest extends FunctionalTest
$results = $report->sourceRecords();
$this->assertEquals(array(
$this->assertEquals([
"Home",
"About Us",
"Page without review date",
"Page owned by group",
), $results->column("Title"));
], $results->column("Title"));
}
}

View File

@ -2,6 +2,7 @@
namespace SilverStripe\ContentReview\Tests;
use function date;
use Page;
use SilverStripe\CMS\Controllers\CMSPageEditController;
use SilverStripe\CMS\Model\SiteTree;
@ -80,7 +81,10 @@ class ContentReviewSettingsTest extends SapphireTest
$page->write();
$this->assertEquals(date('Y-m-d', strtotime("now + " . $page->ReviewPeriodDays . " days")), $page->NextReviewDate);
$this->assertEquals(
date('Y-m-d', strtotime("now + " . $page->ReviewPeriodDays . " days")),
$page->NextReviewDate
);
}
public function testAdvanceReviewFromInheritedSettings()
@ -112,7 +116,10 @@ class ContentReviewSettingsTest extends SapphireTest
$page->write();
$this->assertEquals(date('Y-m-d', strtotime("now + " . $siteConfig->ReviewPeriodDays . " days")), $page->NextReviewDate);
$this->assertEquals(
date('Y-m-d', strtotime("now + " . $siteConfig->ReviewPeriodDays . " days")),
$page->NextReviewDate
);
}
public function testGetSettingsObjectFromCustom()

View File

@ -5,15 +5,15 @@ namespace SilverStripe\ContentReview\Tests;
use Page;
use SilverStripe\CMS\Controllers\CMSPageEditController;
use SilverStripe\CMS\Model\SiteTree;
use SilverStripe\ContentReview\Extensions\SiteTreeContentReview;
use SilverStripe\ContentReview\Extensions\ContentReviewOwner;
use SilverStripe\ContentReview\Extensions\ContentReviewCMSExtension;
use SilverStripe\ContentReview\Extensions\ContentReviewDefaultSettings;
use SilverStripe\ContentReview\Extensions\ContentReviewOwner;
use SilverStripe\ContentReview\Extensions\SiteTreeContentReview;
use SilverStripe\Forms\LiteralField;
use SilverStripe\ORM\FieldType\DBDatetime;
use SilverStripe\Security\Group;
use SilverStripe\Security\Member;
use SilverStripe\SiteConfig\SiteConfig;
use SilverStripe\ORM\FieldType\DBDatetime;
use SilverStripe\Versioned\Versioned;
/**
@ -63,7 +63,7 @@ class SiteTreeContentReviewTest extends ContentReviewBaseTest
$page->write();
$this->assertTrue($page->canPublish());
$this->assertTrue($page->doPublish());
$this->assertTrue($page->publishRecursive());
$this->assertEquals("", $page->OwnerNames);
}