Merge pull request #6699 from sminnee/add-versioned-test

MINOR: Add a Versioned test for #6680
This commit is contained in:
Damian Mooyman 2017-03-14 10:17:08 +13:00 committed by GitHub
commit f24d81af7b

View File

@ -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
*/