public function testArchiveRelatedDataWithoutVersioned()
 {
     SS_Datetime::set_mock_now('2009-01-01 00:00:00');
     $relatedData = new VersionedTest_RelatedWithoutVersion();
     $relatedData->Name = 'Related Data';
     $relatedDataId = $relatedData->write();
     $testData = new VersionedTest_DataObject();
     $testData->Title = 'Test';
     $testData->Content = 'Before Content';
     $testData->Related()->add($relatedData);
     $id = $testData->write();
     SS_Datetime::set_mock_now('2010-01-01 00:00:00');
     $testData->Content = 'After Content';
     $testData->write();
     Versioned::reading_archived_date('2009-01-01 19:00:00');
     $fetchedData = VersionedTest_DataObject::get()->byId($id);
     $this->assertEquals('Before Content', $fetchedData->Content, 'We see the correct content of the older version');
     $relatedData = VersionedTest_RelatedWithoutVersion::get()->byId($relatedDataId);
     $this->assertEquals(1, $relatedData->Related()->count(), 'We have a relation, with no version table, querying it still works');
 }
 /**
  * Simple test to confirm that querying from a particular archive date doesn't throw
  * an error
  */
 public function testReadArchiveDate()
 {
     $date = '2009-07-02 14:05:07';
     Versioned::reading_archived_date($date);
     DataObject::get('SiteTree', "\"SiteTree\".\"ParentID\" = 0");
     Versioned::reading_archived_date(null);
     $this->assertEquals(Versioned::get_reading_mode(), 'Archive.');
 }
Пример #3
0
 /**
  * Set the reading archive date.
  * @param string $date New reading archived date.
  */
 static function reading_archived_date($date)
 {
     Versioned::$reading_archived_date = $date;
 }
Пример #4
0
 /**
  * Simple test to confirm that querying from a particular archive date doesn't throw
  * an error
  */
 public function testReadArchiveDate()
 {
     $date = '2009-07-02 14:05:07';
     Versioned::reading_archived_date($date);
     SiteTree::get()->where(array('"SiteTree"."ParentID"' => 0));
     Versioned::reading_archived_date(null);
     $this->assertEquals(Versioned::get_reading_mode(), 'Archive.');
 }
 /**
  * Simple test to confirm that querying from a particular archive date doesn't throw
  * an error
  */
 function testReadArchiveDate()
 {
     Versioned::reading_archived_date('2009-07-02 14:05:07');
     DataObject::get('SiteTree', "\"ParentID\" = 0");
     Versioned::reading_archived_date(null);
 }