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');
 }
 public function testLazyLoadFieldsRetrieval()
 {
     // Set reading mode to Stage
     Versioned::set_stage(Versioned::DRAFT);
     // Create object only in reading stage
     $original = new VersionedTest_Subclass();
     $original->ExtraField = 'Foo';
     $original->write();
     // Query for object using base class
     $query = VersionedTest_DataObject::get()->filter('ID', $original->ID);
     // Set reading mode to Live
     Versioned::set_stage(Versioned::LIVE);
     $fetched = $query->first();
     $this->assertTrue($fetched instanceof VersionedTest_Subclass);
     $this->assertEquals($original->ID, $fetched->ID);
     // Eager loaded
     $this->assertEquals($original->ExtraField, $fetched->ExtraField);
     // Lazy loaded
 }