mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
dfa44c055c
ENHANCEMENT Added DataObject->isChanged() to detect if a field has been changed in this object instance MINOR Changing call to CompositeDBField->compositeDatabaseFields() in DataObject->hasOwnDatabaseField() BUGFIX Unsettig "Version" property in DataObject->getChangedField() to allow versioned to write a new version after a call to forceChange() BUGFIX Introduced $markChanged in Money class BUGFIX Casting Money->__toString() return value as string MINOR Changing Member class to use new DataObject->isChanged() API BUGFIX Using new $markChanged API for CompositeDBFields in DBField::create() git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@77893 467b73ca-7a2a-4603-9d3b-597d59a354a9
43 lines
1.4 KiB
PHP
43 lines
1.4 KiB
PHP
<?php
|
|
|
|
class VersionedTest extends SapphireTest {
|
|
static $fixture_file = 'sapphire/tests/model/VersionedTest.yml';
|
|
|
|
function testForceChangeUpdatesVersion() {
|
|
$page = $this->objFromFixture('Page', 'page3');
|
|
$oldVersion = $page->Version;
|
|
$page->forceChange();
|
|
$page->write();
|
|
|
|
$this->assertTrue(
|
|
($page->Version > $oldVersion),
|
|
"A object Version is increased when just calling forceChange() without any other changes"
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Test Versioned::get_including_deleted()
|
|
*/
|
|
function testGetIncludingDeleted() {
|
|
// Delete a page
|
|
$this->objFromFixture('Page', 'page3')->delete();
|
|
|
|
// Get all items, ignoring deleted
|
|
$remainingPages = DataObject::get("SiteTree", "ParentID = 0");
|
|
// Check that page 3 has gone
|
|
$this->assertNotNull($remainingPages);
|
|
$this->assertEquals(array("Page 1", "Page 2"), $remainingPages->column('Title'));
|
|
|
|
// Get all including deleted
|
|
$allPages = Versioned::get_including_deleted("SiteTree", "ParentID = 0");
|
|
// 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");
|
|
$allPages = Versioned::get_including_deleted("SiteTree", "ParentID = 0");
|
|
$this->assertEquals(array("Page 1", "Page 2", "Page 3"), $allPages->column('Title'));
|
|
|
|
}
|
|
|
|
} |