2009-05-06 08:36:16 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class VersionedTest extends SapphireTest {
|
2011-03-30 08:49:11 +02:00
|
|
|
static $fixture_file = 'VersionedTest.yml';
|
2010-04-12 04:03:16 +02:00
|
|
|
|
|
|
|
protected $extraDataObjects = array(
|
|
|
|
'VersionedTest_DataObject',
|
2010-10-19 05:01:51 +02:00
|
|
|
'VersionedTest_Subclass'
|
2010-04-12 04:03:16 +02:00
|
|
|
);
|
2009-05-06 08:36:16 +02:00
|
|
|
|
2010-10-19 05:01:51 +02:00
|
|
|
protected $requiredExtensions = array(
|
|
|
|
"VersionedTest_DataObject" => array('Versioned')
|
|
|
|
);
|
|
|
|
|
|
|
|
function testDeletingOrphanedVersions() {
|
|
|
|
$obj = new VersionedTest_Subclass();
|
|
|
|
$obj->ExtraField = 'Foo'; // ensure that child version table gets written
|
|
|
|
$obj->write();
|
|
|
|
$obj->publish('Stage', 'Live');
|
|
|
|
|
|
|
|
$obj->ExtraField = 'Bar'; // ensure that child version table gets written
|
|
|
|
$obj->write();
|
|
|
|
$obj->publish('Stage', 'Live');
|
|
|
|
|
|
|
|
$versions = DB::query("SELECT COUNT(*) FROM \"VersionedTest_Subclass_versions\" WHERE \"RecordID\" = '$obj->ID'")->value();
|
|
|
|
|
|
|
|
$this->assertGreaterThan(0, $versions, 'At least 1 version exists in the history of the page');
|
|
|
|
|
|
|
|
// Force orphaning of all versions created earlier, only on parent record.
|
|
|
|
// The child versiones table should still have the correct relationship
|
|
|
|
DB::query("DELETE FROM \"VersionedTest_DataObject_versions\" WHERE \"RecordID\" = $obj->ID");
|
|
|
|
|
|
|
|
// insert a record with no primary key (ID)
|
2010-10-19 05:06:15 +02:00
|
|
|
DB::query("INSERT INTO \"VersionedTest_DataObject_versions\" (\"RecordID\") VALUES ($obj->ID)");
|
2010-10-19 05:01:51 +02:00
|
|
|
|
|
|
|
// run the script which should clean that up
|
|
|
|
$obj->augmentDatabase();
|
|
|
|
|
|
|
|
$versions = DB::query("SELECT COUNT(*) FROM \"VersionedTest_Subclass_versions\" WHERE \"RecordID\" = '$obj->ID'")->value();
|
|
|
|
$this->assertEquals(0, $versions, 'Orphaned versions on child tables are removed');
|
|
|
|
|
|
|
|
// test that it doesn't delete records that we need
|
|
|
|
$obj->write();
|
|
|
|
$obj->publish('Stage', 'Live');
|
|
|
|
|
|
|
|
$count = DB::query("SELECT COUNT(*) FROM \"VersionedTest_Subclass_versions\" WHERE \"RecordID\" = '$obj->ID'")->value();
|
|
|
|
$obj->augmentDatabase();
|
|
|
|
|
|
|
|
$count2 = DB::query("SELECT COUNT(*) FROM \"VersionedTest_Subclass_versions\" WHERE \"RecordID\" = '$obj->ID'")->value();
|
|
|
|
|
|
|
|
$this->assertEquals($count, $count2);
|
|
|
|
}
|
|
|
|
|
2009-05-27 02:09:23 +02:00
|
|
|
function testForceChangeUpdatesVersion() {
|
2010-10-12 23:42:45 +02:00
|
|
|
$obj = new VersionedTest_DataObject();
|
|
|
|
$obj->Name = "test";
|
|
|
|
$obj->write();
|
|
|
|
|
|
|
|
$oldVersion = $obj->Version;
|
|
|
|
$obj->forceChange();
|
|
|
|
$obj->write();
|
2010-10-13 03:04:38 +02:00
|
|
|
|
2009-05-27 02:09:23 +02:00
|
|
|
$this->assertTrue(
|
2010-10-12 23:42:45 +02:00
|
|
|
($obj->Version > $oldVersion),
|
2009-05-27 02:09:23 +02:00
|
|
|
"A object Version is increased when just calling forceChange() without any other changes"
|
|
|
|
);
|
|
|
|
}
|
2010-10-19 05:01:51 +02:00
|
|
|
|
2009-05-06 08:36:16 +02:00
|
|
|
/**
|
|
|
|
* Test Versioned::get_including_deleted()
|
|
|
|
*/
|
|
|
|
function testGetIncludingDeleted() {
|
|
|
|
// Delete a page
|
2011-03-23 04:32:24 +01:00
|
|
|
$this->objFromFixture('VersionedTest_DataObject', 'page3')->delete();
|
2010-10-13 03:04:38 +02:00
|
|
|
|
2009-05-06 08:36:16 +02:00
|
|
|
// Get all items, ignoring deleted
|
2011-03-23 04:32:24 +01:00
|
|
|
$remainingPages = DataObject::get("VersionedTest_DataObject", "\"ParentID\" = 0", "\"VersionedTest_DataObject\".\"ID\" ASC");
|
2009-05-06 08:36:16 +02:00
|
|
|
// Check that page 3 has gone
|
2009-05-14 07:26:47 +02:00
|
|
|
$this->assertNotNull($remainingPages);
|
2009-05-06 08:36:16 +02:00
|
|
|
$this->assertEquals(array("Page 1", "Page 2"), $remainingPages->column('Title'));
|
|
|
|
|
|
|
|
// Get all including deleted
|
2011-03-23 04:32:24 +01:00
|
|
|
$allPages = Versioned::get_including_deleted("VersionedTest_DataObject", "\"ParentID\" = 0", "\"VersionedTest_DataObject\".\"ID\" ASC");
|
2009-05-06 08:36:16 +02:00
|
|
|
// Check that page 3 is still there
|
|
|
|
$this->assertEquals(array("Page 1", "Page 2", "Page 3"), $allPages->column('Title'));
|
|
|
|
|
|
|
|
// Check that this still works if we switch to reading the other stage
|
|
|
|
Versioned::reading_stage("Live");
|
2011-03-23 04:32:24 +01:00
|
|
|
$allPages = Versioned::get_including_deleted("VersionedTest_DataObject", "\"ParentID\" = 0", "\"VersionedTest_DataObject\".\"ID\" ASC");
|
2009-05-06 08:36:16 +02:00
|
|
|
$this->assertEquals(array("Page 1", "Page 2", "Page 3"), $allPages->column('Title'));
|
|
|
|
|
|
|
|
}
|
2009-06-22 04:42:42 +02:00
|
|
|
|
|
|
|
function testVersionedFieldsAdded() {
|
|
|
|
$obj = new VersionedTest_DataObject();
|
|
|
|
// Check that the Version column is added as a full-fledged column
|
2012-05-09 12:43:22 +02:00
|
|
|
$this->assertInstanceOf('Int', $obj->dbObject('Version'));
|
2010-10-13 03:04:38 +02:00
|
|
|
|
2009-06-22 04:42:42 +02:00
|
|
|
$obj2 = new VersionedTest_Subclass();
|
|
|
|
// Check that the Version column is added as a full-fledged column
|
2012-05-09 12:43:22 +02:00
|
|
|
$this->assertInstanceOf('Int', $obj2->dbObject('Version'));
|
2009-06-22 04:42:42 +02:00
|
|
|
}
|
|
|
|
|
2010-10-13 03:04:38 +02:00
|
|
|
function testPublishCreateNewVersion() {
|
2011-03-23 04:32:24 +01:00
|
|
|
$page1 = $this->objFromFixture('VersionedTest_DataObject', 'page1');
|
2010-10-13 03:04:38 +02:00
|
|
|
$page1->Content = 'orig';
|
|
|
|
$page1->write();
|
|
|
|
$oldVersion = $page1->Version;
|
|
|
|
$page1->publish('Stage', 'Live', false);
|
|
|
|
$this->assertEquals($oldVersion, $page1->Version, 'publish() with $createNewVersion=FALSE');
|
|
|
|
|
|
|
|
$page1->Content = 'changed';
|
|
|
|
$page1->write();
|
|
|
|
$oldVersion = $page1->Version;
|
|
|
|
$page1->publish('Stage', 'Live', true);
|
|
|
|
$this->assertTrue($oldVersion < $page1->Version, 'publish() with $createNewVersion=TRUE');
|
|
|
|
}
|
|
|
|
|
|
|
|
function testRollbackTo() {
|
2011-03-23 04:32:24 +01:00
|
|
|
$page1 = $this->objFromFixture('VersionedTest_DataObject', 'page1');
|
2010-10-13 03:04:38 +02:00
|
|
|
$page1->Content = 'orig';
|
|
|
|
$page1->write();
|
|
|
|
$page1->publish('Stage', 'Live');
|
|
|
|
$origVersion = $page1->Version;
|
|
|
|
|
|
|
|
$page1->Content = 'changed';
|
|
|
|
$page1->write();
|
|
|
|
$page1->publish('Stage', 'Live');
|
|
|
|
$changedVersion = $page1->Version;
|
|
|
|
|
|
|
|
$page1->doRollbackTo($origVersion);
|
2011-03-23 04:32:24 +01:00
|
|
|
$page1 = Versioned::get_one_by_stage('VersionedTest_DataObject', 'Stage', sprintf('"VersionedTest_DataObject"."ID" = %d', $page1->ID));
|
2010-10-13 03:04:38 +02:00
|
|
|
|
|
|
|
$this->assertTrue($page1->Version > $changedVersion, 'Create a new higher version number');
|
|
|
|
$this->assertEquals('orig', $page1->Content, 'Copies the content from the old version');
|
|
|
|
}
|
2010-10-15 04:55:45 +02:00
|
|
|
|
|
|
|
function testDeleteFromStage() {
|
2011-03-23 04:32:24 +01:00
|
|
|
$page1 = $this->objFromFixture('VersionedTest_DataObject', 'page1');
|
2010-10-15 04:55:45 +02:00
|
|
|
$pageID = $page1->ID;
|
|
|
|
|
|
|
|
$page1->Content = 'orig';
|
|
|
|
$page1->write();
|
|
|
|
$page1->publish('Stage', 'Live');
|
|
|
|
|
2011-03-23 04:32:24 +01:00
|
|
|
$this->assertEquals(1, DB::query('SELECT COUNT(*) FROM "VersionedTest_DataObject" WHERE "ID" = '.$pageID)->value());
|
|
|
|
$this->assertEquals(1, DB::query('SELECT COUNT(*) FROM "VersionedTest_DataObject_Live" WHERE "ID" = '.$pageID)->value());
|
2010-10-15 04:55:45 +02:00
|
|
|
|
|
|
|
$page1->deleteFromStage('Live');
|
|
|
|
|
|
|
|
// Confirm that deleteFromStage() doesn't manipulate the original record
|
|
|
|
$this->assertEquals($pageID, $page1->ID);
|
|
|
|
|
2011-03-23 04:32:24 +01:00
|
|
|
$this->assertEquals(1, DB::query('SELECT COUNT(*) FROM "VersionedTest_DataObject" WHERE "ID" = '.$pageID)->value());
|
|
|
|
$this->assertEquals(0, DB::query('SELECT COUNT(*) FROM "VersionedTest_DataObject_Live" WHERE "ID" = '.$pageID)->value());
|
2010-10-15 04:55:45 +02:00
|
|
|
|
|
|
|
$page1->delete();
|
|
|
|
|
|
|
|
$this->assertEquals(0, $page1->ID);
|
2011-03-23 04:32:24 +01:00
|
|
|
$this->assertEquals(0, DB::query('SELECT COUNT(*) FROM "VersionedTest_DataObject" WHERE "ID" = '.$pageID)->value());
|
|
|
|
$this->assertEquals(0, DB::query('SELECT COUNT(*) FROM "VersionedTest_DataObject_Live" WHERE "ID" = '.$pageID)->value());
|
2010-10-15 04:55:45 +02:00
|
|
|
}
|
2010-10-13 03:04:38 +02:00
|
|
|
|
2010-10-15 05:53:14 +02:00
|
|
|
function testWritingNewToStage() {
|
|
|
|
$origStage = Versioned::current_stage();
|
|
|
|
|
|
|
|
Versioned::reading_stage("Stage");
|
2011-03-23 04:32:24 +01:00
|
|
|
$page = new VersionedTest_DataObject();
|
2010-10-15 05:53:14 +02:00
|
|
|
$page->Title = "testWritingNewToStage";
|
|
|
|
$page->URLSegment = "testWritingNewToStage";
|
|
|
|
$page->write();
|
|
|
|
|
2011-03-23 04:32:24 +01:00
|
|
|
$live = Versioned::get_by_stage('VersionedTest_DataObject', 'Live', "\"VersionedTest_DataObject_Live\".\"ID\"='$page->ID'");
|
2009-11-22 06:16:38 +01:00
|
|
|
$this->assertEquals(0, $live->count());
|
2010-10-15 05:53:14 +02:00
|
|
|
|
2011-03-23 04:32:24 +01:00
|
|
|
$stage = Versioned::get_by_stage('VersionedTest_DataObject', 'Stage', "\"VersionedTest_DataObject\".\"ID\"='$page->ID'");
|
2009-11-22 06:16:38 +01:00
|
|
|
$this->assertEquals(1, $stage->count());
|
2010-10-15 05:53:14 +02:00
|
|
|
$this->assertEquals($stage->First()->Title, 'testWritingNewToStage');
|
|
|
|
|
|
|
|
Versioned::reading_stage($origStage);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This tests for the situation described in the ticket #5596.
|
2011-03-23 04:32:24 +01:00
|
|
|
* Writing new Page to live first creates a row in VersionedTest_DataObject table (to get the new ID), then "changes
|
|
|
|
* it's mind" in Versioned and writes VersionedTest_DataObject_Live. It does not remove the VersionedTest_DataObject record though.
|
2010-10-15 05:53:14 +02:00
|
|
|
*/
|
|
|
|
function testWritingNewToLive() {
|
|
|
|
$origStage = Versioned::current_stage();
|
|
|
|
|
|
|
|
Versioned::reading_stage("Live");
|
2011-03-23 04:32:24 +01:00
|
|
|
$page = new VersionedTest_DataObject();
|
2010-10-15 05:53:14 +02:00
|
|
|
$page->Title = "testWritingNewToLive";
|
|
|
|
$page->URLSegment = "testWritingNewToLive";
|
|
|
|
$page->write();
|
|
|
|
|
2011-03-23 04:32:24 +01:00
|
|
|
$live = Versioned::get_by_stage('VersionedTest_DataObject', 'Live', "\"VersionedTest_DataObject_Live\".\"ID\"='$page->ID'");
|
2009-11-22 06:16:38 +01:00
|
|
|
$this->assertEquals(1, $live->count());
|
2010-10-15 05:53:14 +02:00
|
|
|
$this->assertEquals($live->First()->Title, 'testWritingNewToLive');
|
|
|
|
|
2011-03-23 04:32:24 +01:00
|
|
|
$stage = Versioned::get_by_stage('VersionedTest_DataObject', 'Stage', "\"VersionedTest_DataObject\".\"ID\"='$page->ID'");
|
2009-11-22 06:16:38 +01:00
|
|
|
$this->assertEquals(0, $stage->count());
|
2010-10-15 05:53:14 +02:00
|
|
|
|
|
|
|
Versioned::reading_stage($origStage);
|
|
|
|
}
|
2010-10-19 00:53:19 +02:00
|
|
|
|
|
|
|
/**
|
2010-10-19 02:58:40 +02:00
|
|
|
* Tests DataObject::hasOwnTableDatabaseField
|
2010-10-19 00:53:19 +02:00
|
|
|
*/
|
|
|
|
public function testHasOwnTableDatabaseFieldWithVersioned() {
|
|
|
|
$noversion = new DataObject();
|
|
|
|
$versioned = new VersionedTest_DataObject();
|
|
|
|
$versionedSub = new VersionedTest_Subclass();
|
|
|
|
$versionField = new VersionedTest_UnversionedWithField();
|
|
|
|
|
|
|
|
$this->assertFalse(
|
|
|
|
(bool) $noversion->hasOwnTableDatabaseField('Version'),
|
|
|
|
'Plain models have no version field.'
|
|
|
|
);
|
|
|
|
$this->assertEquals(
|
|
|
|
'Int', $versioned->hasOwnTableDatabaseField('Version'),
|
|
|
|
'The versioned ext adds an Int version field.'
|
|
|
|
);
|
|
|
|
$this->assertEquals(
|
|
|
|
'Int', $versionedSub->hasOwnTableDatabaseField('Version'),
|
|
|
|
'Sub-classes of a versioned model have a Version field.'
|
|
|
|
);
|
|
|
|
$this->assertEquals(
|
|
|
|
'Varchar', $versionField->hasOwnTableDatabaseField('Version'),
|
|
|
|
'Models w/o Versioned can have their own Version field.'
|
|
|
|
);
|
|
|
|
}
|
2011-03-30 07:06:33 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Test that SQLQuery::queriedTables() applies the version-suffixes properly.
|
|
|
|
*/
|
|
|
|
public function testQueriedTables() {
|
|
|
|
Versioned::reading_stage('Live');
|
|
|
|
|
|
|
|
$this->assertEquals(array(
|
|
|
|
'VersionedTest_DataObject_Live',
|
|
|
|
'VersionedTest_Subclass_Live',
|
2012-04-20 00:08:17 +02:00
|
|
|
), DataObject::get('VersionedTest_Subclass')->dataQuery()->query()->queriedTables());
|
2011-03-30 07:06:33 +02:00
|
|
|
}
|
2012-06-28 03:00:40 +02:00
|
|
|
|
|
|
|
public function testGetVersionWhenClassnameChanged() {
|
|
|
|
$obj = new VersionedTest_DataObject;
|
|
|
|
$obj->Name = "test";
|
|
|
|
$obj->write();
|
|
|
|
$obj->Name = "test2";
|
|
|
|
$obj->ClassName = "VersionedTest_Subclass";
|
|
|
|
$obj->write();
|
|
|
|
$subclassVersion = $obj->Version;
|
|
|
|
|
|
|
|
$obj->Name = "test3";
|
|
|
|
$obj->ClassName = "VersionedTest_DataObject";
|
|
|
|
$obj->write();
|
|
|
|
|
|
|
|
// We should be able to pass the subclass and still get the correct class back
|
|
|
|
$obj2 = Versioned::get_version("VersionedTest_Subclass", $obj->ID, $subclassVersion);
|
|
|
|
$this->assertInstanceOf("VersionedTest_Subclass", $obj2);
|
|
|
|
$this->assertEquals("test2", $obj2->Name);
|
|
|
|
|
|
|
|
$obj3 = Versioned::get_latest_version("VersionedTest_Subclass", $obj->ID);
|
|
|
|
$this->assertEquals("test3", $obj3->Name);
|
|
|
|
$this->assertInstanceOf("VersionedTest_DataObject", $obj3);
|
|
|
|
|
|
|
|
}
|
2012-08-20 03:24:28 +02:00
|
|
|
|
|
|
|
public function testArchiveVersion() {
|
|
|
|
|
|
|
|
// In 2005 this file was created
|
|
|
|
SS_Datetime::set_mock_now('2005-01-01 00:00:00');
|
|
|
|
$testPage = new VersionedTest_Subclass();
|
|
|
|
$testPage->Title = 'Archived page';
|
|
|
|
$testPage->Content = 'This is the content from 2005';
|
|
|
|
$testPage->ExtraField = '2005';
|
|
|
|
$testPage->write();
|
|
|
|
|
|
|
|
// In 2007 we updated it
|
|
|
|
SS_Datetime::set_mock_now('2007-01-01 00:00:00');
|
|
|
|
$testPage->Content = "It's 2007 already!";
|
|
|
|
$testPage->ExtraField = '2007';
|
|
|
|
$testPage->write();
|
|
|
|
|
|
|
|
// In 2009 we updated it again
|
|
|
|
SS_Datetime::set_mock_now('2009-01-01 00:00:00');
|
|
|
|
$testPage->Content = "I'm enjoying 2009";
|
|
|
|
$testPage->ExtraField = '2009';
|
|
|
|
$testPage->write();
|
|
|
|
|
|
|
|
// End mock, back to the present day:)
|
|
|
|
SS_Datetime::clear_mock_now();
|
|
|
|
|
|
|
|
// Test 1 - 2006 Content
|
|
|
|
singleton('VersionedTest_Subclass')->flushCache(true);
|
|
|
|
Versioned::set_reading_mode('Archive.2006-01-01 00:00:00');
|
|
|
|
$testPage2006 = DataObject::get('VersionedTest_Subclass')->filter(array('Title' => 'Archived page'))->first();
|
|
|
|
$this->assertInstanceOf("VersionedTest_Subclass", $testPage2006);
|
|
|
|
$this->assertEquals("2005", $testPage2006->ExtraField);
|
|
|
|
$this->assertEquals("This is the content from 2005", $testPage2006->Content);
|
|
|
|
|
|
|
|
// Test 2 - 2008 Content
|
|
|
|
singleton('VersionedTest_Subclass')->flushCache(true);
|
|
|
|
Versioned::set_reading_mode('Archive.2008-01-01 00:00:00');
|
|
|
|
$testPage2008 = DataObject::get('VersionedTest_Subclass')->filter(array('Title' => 'Archived page'))->first();
|
|
|
|
$this->assertInstanceOf("VersionedTest_Subclass", $testPage2008);
|
|
|
|
$this->assertEquals("2007", $testPage2008->ExtraField);
|
|
|
|
$this->assertEquals("It's 2007 already!", $testPage2008->Content);
|
|
|
|
|
|
|
|
// Test 3 - Today
|
|
|
|
singleton('VersionedTest_Subclass')->flushCache(true);
|
|
|
|
Versioned::set_reading_mode('Stage.Stage');
|
|
|
|
$testPageCurrent = DataObject::get('VersionedTest_Subclass')->filter(array('Title' => 'Archived page'))->first();
|
|
|
|
$this->assertInstanceOf("VersionedTest_Subclass", $testPageCurrent);
|
|
|
|
$this->assertEquals("2009", $testPageCurrent->ExtraField);
|
|
|
|
$this->assertEquals("I'm enjoying 2009", $testPageCurrent->Content);
|
|
|
|
}
|
2012-08-20 03:44:56 +02:00
|
|
|
|
|
|
|
public function testAllVersions()
|
|
|
|
{
|
|
|
|
// In 2005 this file was created
|
|
|
|
SS_Datetime::set_mock_now('2005-01-01 00:00:00');
|
|
|
|
$testPage = new VersionedTest_Subclass();
|
|
|
|
$testPage->Title = 'Archived page';
|
|
|
|
$testPage->Content = 'This is the content from 2005';
|
|
|
|
$testPage->ExtraField = '2005';
|
|
|
|
$testPage->write();
|
|
|
|
|
|
|
|
// In 2007 we updated it
|
|
|
|
SS_Datetime::set_mock_now('2007-01-01 00:00:00');
|
|
|
|
$testPage->Content = "It's 2007 already!";
|
|
|
|
$testPage->ExtraField = '2007';
|
|
|
|
$testPage->write();
|
|
|
|
|
|
|
|
// In 2009 we updated it again
|
|
|
|
SS_Datetime::set_mock_now('2009-01-01 00:00:00');
|
|
|
|
$testPage->Content = "I'm enjoying 2009";
|
|
|
|
$testPage->ExtraField = '2009';
|
|
|
|
$testPage->write();
|
|
|
|
|
|
|
|
// End mock, back to the present day:)
|
|
|
|
SS_Datetime::clear_mock_now();
|
|
|
|
|
|
|
|
$versions = Versioned::get_all_versions('VersionedTest_Subclass', $testPage->ID);
|
|
|
|
$content = array();
|
|
|
|
$extraFields = array();
|
|
|
|
foreach($versions as $version)
|
|
|
|
{
|
|
|
|
$content[] = $version->Content;
|
|
|
|
$extraFields[] = $version->ExtraField;
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->assertEquals($versions->Count(), 3, 'All versions returned');
|
|
|
|
$this->assertEquals($content, array('This is the content from 2005', "It's 2007 already!", "I'm enjoying 2009"), 'Version fields returned');
|
|
|
|
$this->assertEquals($extraFields, array('2005', '2007', '2009'), 'Version fields returned');
|
|
|
|
}
|
2009-06-22 04:42:42 +02:00
|
|
|
}
|
|
|
|
|
2010-04-12 04:03:16 +02:00
|
|
|
class VersionedTest_DataObject extends DataObject implements TestOnly {
|
2009-06-22 04:42:42 +02:00
|
|
|
static $db = array(
|
|
|
|
"Name" => "Varchar",
|
2011-03-23 04:32:24 +01:00
|
|
|
'Title' => 'Varchar',
|
|
|
|
'Content' => 'HTMLText'
|
2009-06-22 04:42:42 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
static $extensions = array(
|
|
|
|
"Versioned('Stage', 'Live')"
|
|
|
|
);
|
2011-03-23 04:32:24 +01:00
|
|
|
|
|
|
|
static $has_one = array(
|
|
|
|
'Parent' => 'VersionedTest_DataObject'
|
|
|
|
);
|
2009-06-22 04:42:42 +02:00
|
|
|
}
|
2009-05-06 08:36:16 +02:00
|
|
|
|
2010-04-12 04:03:16 +02:00
|
|
|
class VersionedTest_Subclass extends VersionedTest_DataObject implements TestOnly {
|
2009-06-22 04:42:42 +02:00
|
|
|
static $db = array(
|
|
|
|
"ExtraField" => "Varchar",
|
|
|
|
);
|
2010-10-19 05:01:51 +02:00
|
|
|
|
|
|
|
static $extensions = array(
|
|
|
|
"Versioned('Stage', 'Live')"
|
|
|
|
);
|
2009-06-22 04:42:42 +02:00
|
|
|
}
|
2010-10-19 00:53:19 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @ignore
|
|
|
|
*/
|
|
|
|
class VersionedTest_UnversionedWithField extends DataObject implements TestOnly {
|
|
|
|
public static $db = array('Version' => 'Varchar(255)');
|
|
|
|
}
|