diff --git a/.gitattributes b/.gitattributes index 475f5f2..6b268f8 100644 --- a/.gitattributes +++ b/.gitattributes @@ -4,3 +4,5 @@ /.gitignore export-ignore /.travis.yml export-ignore /.scrutinizer.yml export-ignore +/.phpcs.xml.dist export-ignore +/.codecov.yml export-ignore diff --git a/.travis.yml b/.travis.yml index 9d33fe9..20c2fca 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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: diff --git a/changelog.md b/changelog.md deleted file mode 100644 index b775f3d..0000000 --- a/changelog.md +++ /dev/null @@ -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. diff --git a/phpcs.xml.dist b/phpcs.xml.dist new file mode 100644 index 0000000..f6e295b --- /dev/null +++ b/phpcs.xml.dist @@ -0,0 +1,10 @@ + + + CodeSniffer ruleset for SilverStripe coding conventions. + + + + + + + diff --git a/readme.md b/readme.md index 252b4a5..41c4e38 100644 --- a/readme.md +++ b/readme.md @@ -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. @@ -19,6 +17,8 @@ There are two types of roles with this module. ## Requirements * SilverStripe ^4.0 + + **Note:** For SilverStripe 3.x, please use the [3.x release line](https://github.com/silverstripe/silverstripe-contentreview/tree/3). ## Features diff --git a/src/Compatibility/ContentReviewCompatability.php b/src/Compatibility/ContentReviewCompatability.php index 7346995..3d41dd0 100644 --- a/src/Compatibility/ContentReviewCompatability.php +++ b/src/Compatibility/ContentReviewCompatability.php @@ -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; diff --git a/src/Extensions/ContentReviewDefaultSettings.php b/src/Extensions/ContentReviewDefaultSettings.php index 3154073..bf636b8 100644 --- a/src/Extensions/ContentReviewDefaultSettings.php +++ b/src/Extensions/ContentReviewDefaultSettings.php @@ -42,7 +42,8 @@ class ContentReviewDefaultSettings extends DataExtension */ private static $defaults = array( 'ReviewSubject' => 'Page(s) are due for content review', - 'ReviewBody' => '

Page(s) due for review

There are $PagesCount pages that are due for review today by you.

', + 'ReviewBody' => '

Page(s) due for review

' + . '

There are $PagesCount pages that are due for review today by you.

', ); /** @@ -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 » @@ -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') ), - ) + ] ); } diff --git a/src/Extensions/ContentReviewOwner.php b/src/Extensions/ContentReviewOwner.php index 101dc65..3daa295 100644 --- a/src/Extensions/ContentReviewOwner.php +++ b/src/Extensions/ContentReviewOwner.php @@ -13,7 +13,7 @@ class ContentReviewOwner extends DataExtension /** * @var array */ - private static $many_many = array( + private static $many_many = [ "SiteTreeContentReview" => SiteTree::class, - ); + ]; } diff --git a/src/Extensions/SiteTreeContentReview.php b/src/Extensions/SiteTreeContentReview.php index 3defb21..fb9076d 100644 --- a/src/Extensions/SiteTreeContentReview.php +++ b/src/Extensions/SiteTreeContentReview.php @@ -48,8 +48,8 @@ use Symbiote\QueuedJobs\Services\QueuedJobService; * to content needing review. * * @property string $ContentReviewType - * @property int $ReviewPeriodDays - * @property Date $NextReviewDate + * @property int $ReviewPeriodDays + * @property Date $NextReviewDate * @property string $LastEditedByName * @property string $OwnerNames * @@ -62,51 +62,51 @@ 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)", - ); + "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, - ); + "ContentReviewUsers" => Member::class, + ]; /** * @var array */ - private static $schedule = array( - 0 => "No automatic review date", - 1 => "1 day", - 7 => "1 week", - 30 => "1 month", - 60 => "2 months", - 91 => "3 months", + private static $schedule = [ + 0 => "No automatic review date", + 1 => "1 day", + 7 => "1 week", + 30 => "1 month", + 60 => "2 months", + 91 => "3 months", 121 => "4 months", 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, - )); + ]); } /** @@ -465,7 +500,7 @@ class SiteTreeContentReview extends DataExtension implements PermissionProvider $this->owner->write(); } - return (bool) $nextDateTimestamp; + return (bool)$nextDateTimestamp; } /** @@ -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, diff --git a/src/Reports/PagesDueForReviewReport.php b/src/Reports/PagesDueForReviewReport.php index b171aeb..7fb3545 100644 --- a/src/Reports/PagesDueForReviewReport.php +++ b/src/Reports/PagesDueForReviewReport.php @@ -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" => "\$value" - ), - "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); diff --git a/src/Reports/PagesWithoutReviewScheduleReport.php b/src/Reports/PagesWithoutReviewScheduleReport.php index 6a6827e..0b9ef9e 100644 --- a/src/Reports/PagesWithoutReviewScheduleReport.php +++ b/src/Reports/PagesWithoutReviewScheduleReport.php @@ -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" => "\$value", - ), - "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); diff --git a/src/Tasks/ContentReviewEmails.php b/src/Tasks/ContentReviewEmails.php index 9b82dd2..28d58f9 100644 --- a/src/Tasks/ContentReviewEmails.php +++ b/src/Tasks/ContentReviewEmails.php @@ -50,7 +50,7 @@ class ContentReviewEmails extends BuildTask */ protected function getOverduePagesForOwners(SS_List $pages) { - $overduePages = array(); + $overduePages = []; foreach ($pages as $page) { if (!$page->canBeReviewedBy()) { diff --git a/tests/php/ContentReviewBaseTest.php b/tests/php/ContentReviewBaseTest.php index 7ff7bdc..8dcc48f 100644 --- a/tests/php/ContentReviewBaseTest.php +++ b/tests/php/ContentReviewBaseTest.php @@ -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. * diff --git a/tests/php/ContentReviewCMSPageEditControllerTest.php b/tests/php/ContentReviewCMSPageEditControllerTest.php index ab84c64..afcb051 100644 --- a/tests/php/ContentReviewCMSPageEditControllerTest.php +++ b/tests/php/ContentReviewCMSPageEditControllerTest.php @@ -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(); diff --git a/tests/php/ContentReviewNotificationTest.php b/tests/php/ContentReviewNotificationTest.php index 4b90852..a96c03a 100644 --- a/tests/php/ContentReviewNotificationTest.php +++ b/tests/php/ContentReviewNotificationTest.php @@ -70,7 +70,8 @@ class ContentReviewNotificationTest extends SapphireTest $email = $this->findEmail($ToEmail, null, $Subject); $this->assertNotNull($email, "Email haven't been sent."); $this->assertContains( - "

$Subject

There are $PagesCount pages that are due for review today by you, $ToFirstName.

This email was sent to $ToEmail

", + "

$Subject

There are $PagesCount pages that are due for review today by you, " + . "$ToFirstName.

This email was sent to $ToEmail

", $email['HtmlContent'] ); $this->assertContains('Staff', $email['HtmlContent']); diff --git a/tests/php/ContentReviewReportTest.php b/tests/php/ContentReviewReportTest.php index 81c5d21..97d8185 100644 --- a/tests/php/ContentReviewReportTest.php +++ b/tests/php/ContentReviewReportTest.php @@ -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")); } } diff --git a/tests/php/ContentReviewSettingsTest.php b/tests/php/ContentReviewSettingsTest.php index dd3c5eb..1913a50 100644 --- a/tests/php/ContentReviewSettingsTest.php +++ b/tests/php/ContentReviewSettingsTest.php @@ -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() diff --git a/tests/php/SiteTreeContentReviewTest.php b/tests/php/SiteTreeContentReviewTest.php index 46075ae..c4eb791 100644 --- a/tests/php/SiteTreeContentReviewTest.php +++ b/tests/php/SiteTreeContentReviewTest.php @@ -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); }