mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Merge pull request #6699 from sminnee/add-versioned-test
MINOR: Add a Versioned test for #6680
This commit is contained in:
commit
f24d81af7b
@ -1020,6 +1020,35 @@ class VersionedTest extends SapphireTest
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that that stage a record was queried from cascades to child relations, even if the
|
||||
* global stage has changed
|
||||
*/
|
||||
public function testStageCascadeOnRelations()
|
||||
{
|
||||
$origReadingMode = Versioned::get_reading_mode();
|
||||
|
||||
// Stage record - 2 children
|
||||
Versioned::set_stage(Versioned::DRAFT);
|
||||
$draftPage = $this->objFromFixture(VersionedTest\TestObject::class, 'page2');
|
||||
$draftPage->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
|
||||
$this->assertEquals(2, $draftPage->Children()->Count());
|
||||
|
||||
// Live record - no children
|
||||
Versioned::set_stage(Versioned::LIVE);
|
||||
$livePage = $this->objFromFixture(VersionedTest\TestObject::class, 'page2');
|
||||
$this->assertEquals(0, $livePage->Children()->Count());
|
||||
|
||||
// Validate that draft page still queries draft children even though global stage is live
|
||||
$this->assertEquals(2, $draftPage->Children()->Count());
|
||||
|
||||
// Validate that live page still queries live children even though global stage is live
|
||||
Versioned::set_stage(Versioned::DRAFT);
|
||||
$this->assertEquals(0, $livePage->Children()->Count());
|
||||
|
||||
Versioned::set_reading_mode($origReadingMode);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that multi-table dataobjects are correctly versioned
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user