Merge pull request #2387 from creative-commoners/pulls/4.3/versioning-test-update

SiteTreeTest::testReadArchiveDate() now tests ORM results rather than underlying sql arguments
This commit is contained in:
Guy Marriott 2019-02-12 08:41:44 +13:00 committed by GitHub
commit 543307adfe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -17,6 +17,7 @@ use SilverStripe\Dev\SapphireTest;
use SilverStripe\i18n\i18n;
use SilverStripe\ORM\DataObject;
use SilverStripe\ORM\DB;
use SilverStripe\ORM\FieldType\DBDatetime;
use SilverStripe\ORM\ValidationException;
use SilverStripe\Security\Group;
use SilverStripe\Security\InheritedPermissions;
@ -613,12 +614,18 @@ class SiteTreeTest extends SapphireTest
*/
public function testReadArchiveDate()
{
DBDatetime::set_mock_now('2009-07-02 14:05:07');
$oldPage = SiteTree::create();
$oldPage->Title = 'A really old page';
$oldPage->write();
DBDatetime::clear_mock_now();
$date = '2009-07-02 14:05:07';
Versioned::reading_archived_date($date);
SiteTree::get()->where([
$result = SiteTree::get()->where([
'"SiteTree"."ParentID"' => 0
])->sql($args);
$this->assertContains($date, $args);
]);
$this->assertCount(1, $result, '"A really old page" should be returned');
}
public function testEditPermissions()