2014-02-24 01:38:16 +01:00
|
|
|
<?php
|
|
|
|
|
2017-09-06 05:49:23 +02:00
|
|
|
namespace SilverStripe\ContentReview\Tests;
|
|
|
|
|
|
|
|
use SilverStripe\CMS\Controllers\CMSPageEditController;
|
|
|
|
use SilverStripe\CMS\Model\SiteTree;
|
|
|
|
use SilverStripe\ContentReview\Extensions\ContentReviewCMSExtension;
|
|
|
|
use SilverStripe\ContentReview\Extensions\ContentReviewDefaultSettings;
|
|
|
|
use SilverStripe\ContentReview\Extensions\ContentReviewOwner;
|
|
|
|
use SilverStripe\ContentReview\Extensions\SiteTreeContentReview;
|
|
|
|
use SilverStripe\ContentReview\Reports\PagesDueForReviewReport;
|
|
|
|
use SilverStripe\ContentReview\Reports\PagesWithoutReviewScheduleReport;
|
|
|
|
use SilverStripe\Dev\FunctionalTest;
|
|
|
|
use SilverStripe\ORM\FieldType\DBDatetime;
|
|
|
|
use SilverStripe\Security\Group;
|
|
|
|
use SilverStripe\Security\Member;
|
|
|
|
use SilverStripe\SiteConfig\SiteConfig;
|
|
|
|
|
2015-11-02 00:27:42 +01:00
|
|
|
class ContentReviewReportTest extends FunctionalTest
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @var string
|
|
|
|
*/
|
2017-09-06 05:49:23 +02:00
|
|
|
protected static $fixture_file = 'ContentReviewTest.yml';
|
2015-11-02 00:27:42 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @var array
|
|
|
|
*/
|
2017-09-06 05:49:23 +02:00
|
|
|
protected static $required_extensions = [
|
|
|
|
SiteTree::class => [SiteTreeContentReview::class],
|
|
|
|
Group::class => [ContentReviewOwner::class],
|
|
|
|
Member::class => [ContentReviewOwner::class],
|
|
|
|
CMSPageEditController::class => [ContentReviewCMSExtension::class],
|
|
|
|
SiteConfig::class => [ContentReviewDefaultSettings::class],
|
|
|
|
];
|
2015-11-02 00:27:42 +01:00
|
|
|
|
|
|
|
public function testPagesDueForReviewReport()
|
|
|
|
{
|
|
|
|
/** @var Member $editor */
|
2017-09-06 05:49:23 +02:00
|
|
|
$editor = $this->objFromFixture(Member::class, "editor");
|
2015-11-02 00:27:42 +01:00
|
|
|
|
|
|
|
$this->logInAs($editor);
|
|
|
|
|
|
|
|
$report = new PagesDueForReviewReport();
|
|
|
|
|
|
|
|
$report->parameterFields();
|
|
|
|
$report->columns();
|
|
|
|
$report->title();
|
|
|
|
|
2018-01-08 04:47:31 +01:00
|
|
|
$results = $report->sourceRecords([
|
2017-09-06 06:53:45 +02:00
|
|
|
"ReviewDateAfter" => "2010-01-01",
|
|
|
|
"ReviewDateBefore" => "2010-12-12",
|
2018-01-08 04:47:31 +01:00
|
|
|
]);
|
2015-11-02 00:27:42 +01:00
|
|
|
|
2018-07-31 01:55:50 +02:00
|
|
|
$this->assertListEquals([
|
2018-07-30 23:26:49 +02:00
|
|
|
['Title' => 'Contact Us Child'],
|
|
|
|
['Title' => 'Home'],
|
|
|
|
['Title' => 'About Us'],
|
|
|
|
['Title' => 'Staff'],
|
|
|
|
['Title' => 'Contact Us'],
|
|
|
|
], $results);
|
2015-11-02 00:27:42 +01:00
|
|
|
|
2017-09-06 05:49:23 +02:00
|
|
|
DBDatetime::set_mock_now("2010-02-13 00:00:00");
|
2014-02-24 01:38:16 +01:00
|
|
|
|
2018-01-08 04:47:31 +01:00
|
|
|
$results = $report->sourceRecords([]);
|
2015-11-02 00:27:42 +01:00
|
|
|
|
2018-01-08 04:47:31 +01:00
|
|
|
$this->assertEquals([
|
2015-11-02 00:27:42 +01:00
|
|
|
"Home",
|
2015-11-12 04:00:34 +01:00
|
|
|
"About Us",
|
2018-01-08 04:47:31 +01:00
|
|
|
], $results->column("Title"));
|
2015-11-02 00:27:42 +01:00
|
|
|
|
2017-09-06 05:49:23 +02:00
|
|
|
DBDatetime::clear_mock_now();
|
2015-11-02 00:27:42 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public function testPagesWithoutReviewScheduleReport()
|
|
|
|
{
|
|
|
|
/** @var Member $editor */
|
2017-09-06 05:49:23 +02:00
|
|
|
$editor = $this->objFromFixture(Member::class, "editor");
|
2015-11-02 00:27:42 +01:00
|
|
|
|
|
|
|
$this->logInAs($editor);
|
|
|
|
|
|
|
|
$report = new PagesWithoutReviewScheduleReport();
|
|
|
|
|
|
|
|
$report->parameterFields();
|
|
|
|
$report->columns();
|
|
|
|
$report->title();
|
|
|
|
|
|
|
|
$results = $report->sourceRecords();
|
|
|
|
|
2022-03-07 00:37:13 +01:00
|
|
|
$this->assertListEquals([
|
|
|
|
['Title' => 'Home'],
|
|
|
|
['Title' => 'About Us'],
|
|
|
|
['Title' => 'Page without review date'],
|
|
|
|
['Title' => 'Page owned by group'],
|
|
|
|
], $results);
|
2015-11-02 00:27:42 +01:00
|
|
|
}
|
|
|
|
}
|