Created
March 13, 2017 20:32
-
-
Save sminnee/b032d2ae250b2e387c79e828164db616 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/tests/php/ORM/VersionedTest.php b/tests/php/ORM/VersionedTest.php | |
| index 003e56e..e99668a 100644 | |
| --- a/tests/php/ORM/VersionedTest.php | |
| +++ b/tests/php/ORM/VersionedTest.php | |
| @@ -1021,6 +1021,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 | |
| */ | |
| public function testWriteToStage() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment