Permalink
Browse files

MINOR Fixed TranslatableTest for postgresql database driver (mostly o…

…rdering issues) (from r103798)

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@112159 467b73ca-7a2a-4603-9d3b-597d59a354a9
  • Loading branch information...
sminnee committed Oct 13, 2010
1 parent 0c81b2f commit 5fe546dbc00b50764256d61988763829ddea2cca
Showing with 45 additions and 28 deletions.
  1. +45 −28 tests/model/TranslatableTest.php
@@ -60,7 +60,7 @@ function testLocaleGetParamRedirectsToTranslation() {
$response = $this->get(Controller::join_links($origPage->URLSegment, '?locale=xx_XX'));
$this->assertEquals(200, $response->getStatusCode(), 'Locale GET param without existing translation shows original page');
}
-
+
function testTranslationGroups() {
// first in french
$frPage = new SiteTree();
@@ -95,9 +95,11 @@ function testTranslationGroups() {
);
// test english
+ $expected = $enPage->getTranslations()->column('Locale');
+ sort($expected);
$this->assertEquals(
- $enPage->getTranslations()->column('Locale'),
- array('fr_FR','es_ES')
+ $expected,
+ array('es_ES', 'fr_FR')
);
$this->assertNotNull($frPage->getTranslation('fr_FR'));
$this->assertEquals(
@@ -113,7 +115,7 @@ function testTranslationGroups() {
// test spanish
$this->assertEquals(
$esPage->getTranslations()->column('Locale'),
- array('fr_FR','en_US')
+ array('en_US', 'fr_FR')
);
$this->assertNotNull($esPage->getTranslation('fr_FR'));
$this->assertEquals(
@@ -249,21 +251,25 @@ function testDataObjectGetWithReadingLanguage() {
'Page',
sprintf("\"SiteTree\".\"MenuTitle\" = '%s'", 'A Testpage')
);
+ $resultPagesDefaultLangIDs = $resultPagesDefaultLang->column('ID');
+ array_walk($resultPagesDefaultLangIDs, 'intval');
$this->assertEquals($resultPagesDefaultLang->Count(), 2);
- $this->assertContains($origTestPage->ID, $resultPagesDefaultLang->column('ID'));
- $this->assertContains($otherTestPage->ID, $resultPagesDefaultLang->column('ID'));
- $this->assertNotContains($translatedPage->ID, $resultPagesDefaultLang->column('ID'));
+ $this->assertContains((int)$origTestPage->ID, $resultPagesDefaultLangIDs);
+ $this->assertContains((int)$otherTestPage->ID, $resultPagesDefaultLangIDs);
+ $this->assertNotContains((int)$translatedPage->ID, $resultPagesDefaultLangIDs);
// test in custom language
Translatable::set_current_locale('de_DE');
$resultPagesCustomLang = DataObject::get(
'Page',
sprintf("\"SiteTree\".\"MenuTitle\" = '%s'", 'A Testpage')
);
+ $resultPagesCustomLangIDs = $resultPagesCustomLang->column('ID');
+ array_walk($resultPagesCustomLangIDs, 'intval');
$this->assertEquals($resultPagesCustomLang->Count(), 1);
- $this->assertNotContains($origTestPage->ID, $resultPagesCustomLang->column('ID'));
- $this->assertNotContains($otherTestPage->ID, $resultPagesCustomLang->column('ID'));
- $this->assertContains($translatedPage->ID, $resultPagesCustomLang->column('ID'));
+ $this->assertNotContains((int)$origTestPage->ID, $resultPagesCustomLangIDs);
+ $this->assertNotContains((int)$otherTestPage->ID, $resultPagesCustomLangIDs);
+ $this->assertContains((int)$translatedPage->ID, $resultPagesCustomLangIDs);
Translatable::set_current_locale('en_US');
}
@@ -367,13 +373,16 @@ function testHierarchyChildren() {
$child4PageTranslated->write();
Translatable::set_current_locale('en_US');
+ $actual = $parentPage->Children()->column('ID');
+ sort($actual);
+ $expected = array(
+ $child1Page->ID,
+ $child2Page->ID,
+ $child3Page->ID
+ );
$this->assertEquals(
- $parentPage->Children()->column('ID'),
- array(
- $child1Page->ID,
- $child2Page->ID,
- $child3Page->ID
- ),
+ $actual,
+ $expected,
"Showing Children() in default language doesnt show children in other languages"
);
@@ -420,13 +429,17 @@ function testHierarchyLiveStageChildren() {
"Showing liveChildren() in default language doesnt show children in other languages"
);
$this->assertNotNull($parentPage->stageChildren());
+ $actual = $parentPage->stageChildren()->column('ID');
+ sort($actual);
+ $expected = array(
+ $child1Page->ID,
+ $child2Page->ID,
+ $child3Page->ID
+ );
+ sort($expected);
$this->assertEquals(
- $parentPage->stageChildren()->column('ID'),
- array(
- $child1Page->ID,
- $child2Page->ID,
- $child3Page->ID
- ),
+ $actual,
+ $expected,
"Showing stageChildren() in default language doesnt show children in other languages"
);
@@ -612,13 +625,17 @@ function testHierarchyAllChildrenIncludingDeleted() {
SiteTree::flush_and_destroy_cache();
$parentPage = $this->objFromFixture('Page', 'parent');
$children = $parentPage->AllChildrenIncludingDeleted();
+ $expected = array(
+ $child2PageID,
+ $child3PageID,
+ $child1PageID // $child1Page was deleted from stage, so the original record doesn't have the ID set
+ );
+ sort($expected);
+ $actual = $parentPage->AllChildrenIncludingDeleted()->column('ID');
+ sort($actual);
$this->assertEquals(
- $parentPage->AllChildrenIncludingDeleted()->column('ID'),
- array(
- $child2PageID,
- $child3PageID,
- $child1PageID // $child1Page was deleted from stage, so the original record doesn't have the ID set
- ),
+ $actual,
+ $expected,
"Showing AllChildrenIncludingDeleted() in default language doesnt show deleted children in other languages"
);

0 comments on commit 5fe546d

Please sign in to comment.