From 4c94455a4d11180c74fe340ac5944dc3c7bdef32 Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Tue, 12 May 2009 00:46:57 +0000 Subject: [PATCH] ENHANCEMENT Improved TranslatableTest->testCreateTranslationTranslatesUntranslatedParents() to translate two grandchildren - this used to be an issue in branches/2.3 (see #4016) git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@76594 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- tests/model/TranslatableTest.php | 38 +++++++++++++++++--------------- tests/model/TranslatableTest.yml | 8 +++++-- 2 files changed, 26 insertions(+), 20 deletions(-) diff --git a/tests/model/TranslatableTest.php b/tests/model/TranslatableTest.php index 8f29c268d..de7292056 100644 --- a/tests/model/TranslatableTest.php +++ b/tests/model/TranslatableTest.php @@ -335,7 +335,7 @@ class TranslatableTest extends FunctionalTest { $child1Page = $this->objFromFixture('Page', 'child1'); $child2Page = $this->objFromFixture('Page', 'child2'); $child3Page = $this->objFromFixture('Page', 'child3'); - $grandchildPage = $this->objFromFixture('Page', 'grandchild'); + $grandchildPage = $this->objFromFixture('Page', 'grandchild1'); $parentPageTranslated = $parentPage->createTranslation('de_DE'); $child4PageTranslated = new SiteTree(); @@ -372,7 +372,7 @@ class TranslatableTest extends FunctionalTest { $child1Page->publish('Stage', 'Live'); $child2Page = $this->objFromFixture('Page', 'child2'); $child3Page = $this->objFromFixture('Page', 'child3'); - $grandchildPage = $this->objFromFixture('Page', 'grandchild'); + $grandchildPage = $this->objFromFixture('Page', 'grandchild1'); $parentPageTranslated = $parentPage->createTranslation('de_DE'); @@ -517,26 +517,28 @@ class TranslatableTest extends FunctionalTest { $parentPage = $this->objFromFixture('Page', 'parent'); $child1Page = $this->objFromFixture('Page', 'child1'); $child1PageOrigID = $child1Page->ID; - $grandchildPage = $this->objFromFixture('Page', 'grandchild'); - - $this->assertFalse($grandchildPage->hasTranslation('de_DE')); + $grandChild1Page = $this->objFromFixture('Page', 'grandchild1'); + $grandChild2Page = $this->objFromFixture('Page', 'grandchild2'); + + $this->assertFalse($grandChild1Page->hasTranslation('de_DE')); $this->assertFalse($child1Page->hasTranslation('de_DE')); $this->assertFalse($parentPage->hasTranslation('de_DE')); - - $translatedGrandChildPage = $grandchildPage->createTranslation('de_DE'); - - $this->assertTrue($grandchildPage->hasTranslation('de_DE')); + + $translatedGrandChild1Page = $grandChild1Page->createTranslation('de_DE'); + $translatedGrandChild2Page = $grandChild2Page->createTranslation('de_DE'); + $translatedChildPage = $child1Page->getTranslation('de_DE'); + $translatedParentPage = $parentPage->getTranslation('de_DE'); + + $this->assertTrue($grandChild1Page->hasTranslation('de_DE')); + $this->assertEquals($translatedGrandChild1Page->ParentID, $translatedChildPage->ID); + + $this->assertTrue($grandChild2Page->hasTranslation('de_DE')); + $this->assertEquals($translatedGrandChild2Page->ParentID, $translatedChildPage->ID); + $this->assertTrue($child1Page->hasTranslation('de_DE')); + $this->assertEquals($translatedChildPage->ParentID, $translatedParentPage->ID); + $this->assertTrue($parentPage->hasTranslation('de_DE')); - - $this->assertEquals( - $grandchildPage->getTranslation('de_DE')->Parent()->ID, - $child1Page->getTranslation('de_DE')->ID - ); - $this->assertEquals( - $child1Page->getTranslation('de_DE')->Parent()->ID, - $parentPage->getTranslation('de_DE')->ID - ); } function testHierarchyAllChildrenIncludingDeleted() { diff --git a/tests/model/TranslatableTest.yml b/tests/model/TranslatableTest.yml index 65dd01a01..efa160b26 100644 --- a/tests/model/TranslatableTest.yml +++ b/tests/model/TranslatableTest.yml @@ -28,9 +28,13 @@ Page: Title: Child 3 URLSegment: child3 Parent: =>Page.parent - grandchild: + grandchild1: Title: Grandchild - URLSegment: grandchild + URLSegment: grandchild1 + Parent: =>Page.child1 + grandchild2: + Title: Grandchild + URLSegment: grandchild2 Parent: =>Page.child1 TranslatableTest_DataObject: testobject_en: