Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

ENHANCEMENT Fixed ContentReviewTest to work with SQLite3, MSSQL and P…

…ostgres database drivers
  • Loading branch information...
commit 8e246c387a72051b99044e079f081ebabf003c61 1 parent 7836db5
@chillu chillu authored
View
2  code/ContentReviewEmails.php
@@ -15,7 +15,7 @@ function process() {
Subsite::$disable_subsite_filter = true;
}
- $pages = DataObject::get('Page', "SiteTree.NextReviewDate = '".(class_exists('SS_Datetime') ? SS_Datetime::now()->URLDate() : SSDatetime::now()->URLDate())."' AND SiteTree.OwnerID != 0");
+ $pages = DataObject::get('Page', "\"SiteTree\".\"NextReviewDate\" = '".(class_exists('SS_Datetime') ? SS_Datetime::now()->URLDate() : SSDatetime::now()->URLDate())."' AND \"SiteTree\".\"OwnerID\" != 0");
if ($pages && $pages->Count()) {
foreach($pages as $page) {
$owner = $page->Owner();
View
18 code/PagesDueForReviewReport.php
@@ -1,4 +1,5 @@
<?php
+require_once 'Zend/Date.php';
/**
* Show all pages that need to be reviewed
@@ -88,20 +89,23 @@ function sourceRecords($params, $sort, $limit) {
if(empty($params['ReviewDateBefore']) && empty($params['ReviewDateAfter'])) {
// If there's no review dates set, default to all pages due for review now
- $wheres[] = 'NextReviewDate < \'' . (class_exists('SS_Datetime') ? SS_Datetime::now()->URLDate() : SSDatetime::now()->URLDate()) . '\' + INTERVAL 1 DAY';
+ $reviewDate = new Zend_Date(SS_Datetime::now()->getValue());
+ $reviewDate->add(1, Zend_Date::DAY);
+ $wheres[] = sprintf('"NextReviewDate" < \'%s\'', $reviewDate->toString('YYYY-MM-dd'));
} else {
// Review date before
if(!empty($params['ReviewDateBefore'])) {
list($day, $month, $year) = explode('/', $params['ReviewDateBefore']);
- $reviewDate = "$year-$month-$day";
- $wheres[] = 'NextReviewDate < \'' . Convert::raw2sql($reviewDate) . '\' + INTERVAL 1 DAY';
+ $reviewDate = new Zend_Date("$year-$month-$day");
+ $reviewDate->add(1, Zend_Date::DAY);
+ $wheres[] = sprintf('"NextReviewDate" < \'%s\'', $reviewDate->toString('YYYY-MM-dd'));
}
// Review date after
if(!empty($params['ReviewDateAfter'])) {
list($day, $month, $year) = explode('/', $params['ReviewDateAfter']);
- $reviewDate = "$year-$month-$day";
- $wheres[] = 'NextReviewDate >= \'' . Convert::raw2sql($reviewDate) . '\'';
+ $reviewDate = new Zend_Date("$year-$month-$day");
+ $wheres[] = sprintf('"NextReviewDate" >= \'%s\'', $reviewDate->toString('YYYY-MM-dd'));
}
}
@@ -119,7 +123,7 @@ function sourceRecords($params, $sort, $limit) {
$ownerID = (int)$params[$ownerIdParam];
// We use -1 here to distinguish between No Owner and Any
if($ownerID == -1) $ownerID = 0;
- $wheres[] = 'OwnerID = ' . $ownerID;
+ $wheres[] = '"OwnerID" = ' . $ownerID;
}
$query = singleton("SiteTree")->extendedSQL(join(' AND ', $wheres));
@@ -134,7 +138,7 @@ function sourceRecords($params, $sort, $limit) {
$direction = $parts[1];
if($field == 'AbsoluteLink') {
- $sort = 'URLSegment ' . $direction;
+ $sort = '"URLSegment" ' . $direction;
} elseif($field == 'Subsite.Title') {
$query->from[] = 'LEFT JOIN "Subsite" ON "Subsite"."ID" = "SiteTree"."SubsiteID"';
}
View
4 tests/ContentReviewTest.php
@@ -67,11 +67,9 @@ function testReportContent() {
'Contact Us'
));
- SS_Datetime::set_mock_now('2010-02-13 12:00:00');
-
+ SS_Datetime::set_mock_now('2010-02-13 00:00:00');
$results = $report->sourceRecords(array(
), 'NextReviewDate ASC', false);
-
$this->assertEquals($results->column('Title'), array(
'Home',
'About Us'
Please sign in to comment.
Something went wrong with that request. Please try again.