MINOR Fixed TranslatableTest for postgresql database driver (mostly ordering issues) (from r103798)

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@112159 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Sam Minnee 2010-10-13 04:06:21 +00:00
parent 0c81b2f997
commit 5fe546dbc0

View File

@ -95,9 +95,11 @@ class TranslatableTest extends FunctionalTest {
); );
// test english // test english
$expected = $enPage->getTranslations()->column('Locale');
sort($expected);
$this->assertEquals( $this->assertEquals(
$enPage->getTranslations()->column('Locale'), $expected,
array('fr_FR','es_ES') array('es_ES', 'fr_FR')
); );
$this->assertNotNull($frPage->getTranslation('fr_FR')); $this->assertNotNull($frPage->getTranslation('fr_FR'));
$this->assertEquals( $this->assertEquals(
@ -113,7 +115,7 @@ class TranslatableTest extends FunctionalTest {
// test spanish // test spanish
$this->assertEquals( $this->assertEquals(
$esPage->getTranslations()->column('Locale'), $esPage->getTranslations()->column('Locale'),
array('fr_FR','en_US') array('en_US', 'fr_FR')
); );
$this->assertNotNull($esPage->getTranslation('fr_FR')); $this->assertNotNull($esPage->getTranslation('fr_FR'));
$this->assertEquals( $this->assertEquals(
@ -249,10 +251,12 @@ class TranslatableTest extends FunctionalTest {
'Page', 'Page',
sprintf("\"SiteTree\".\"MenuTitle\" = '%s'", 'A Testpage') sprintf("\"SiteTree\".\"MenuTitle\" = '%s'", 'A Testpage')
); );
$resultPagesDefaultLangIDs = $resultPagesDefaultLang->column('ID');
array_walk($resultPagesDefaultLangIDs, 'intval');
$this->assertEquals($resultPagesDefaultLang->Count(), 2); $this->assertEquals($resultPagesDefaultLang->Count(), 2);
$this->assertContains($origTestPage->ID, $resultPagesDefaultLang->column('ID')); $this->assertContains((int)$origTestPage->ID, $resultPagesDefaultLangIDs);
$this->assertContains($otherTestPage->ID, $resultPagesDefaultLang->column('ID')); $this->assertContains((int)$otherTestPage->ID, $resultPagesDefaultLangIDs);
$this->assertNotContains($translatedPage->ID, $resultPagesDefaultLang->column('ID')); $this->assertNotContains((int)$translatedPage->ID, $resultPagesDefaultLangIDs);
// test in custom language // test in custom language
Translatable::set_current_locale('de_DE'); Translatable::set_current_locale('de_DE');
@ -260,10 +264,12 @@ class TranslatableTest extends FunctionalTest {
'Page', 'Page',
sprintf("\"SiteTree\".\"MenuTitle\" = '%s'", 'A Testpage') sprintf("\"SiteTree\".\"MenuTitle\" = '%s'", 'A Testpage')
); );
$resultPagesCustomLangIDs = $resultPagesCustomLang->column('ID');
array_walk($resultPagesCustomLangIDs, 'intval');
$this->assertEquals($resultPagesCustomLang->Count(), 1); $this->assertEquals($resultPagesCustomLang->Count(), 1);
$this->assertNotContains($origTestPage->ID, $resultPagesCustomLang->column('ID')); $this->assertNotContains((int)$origTestPage->ID, $resultPagesCustomLangIDs);
$this->assertNotContains($otherTestPage->ID, $resultPagesCustomLang->column('ID')); $this->assertNotContains((int)$otherTestPage->ID, $resultPagesCustomLangIDs);
$this->assertContains($translatedPage->ID, $resultPagesCustomLang->column('ID')); $this->assertContains((int)$translatedPage->ID, $resultPagesCustomLangIDs);
Translatable::set_current_locale('en_US'); Translatable::set_current_locale('en_US');
} }
@ -367,13 +373,16 @@ class TranslatableTest extends FunctionalTest {
$child4PageTranslated->write(); $child4PageTranslated->write();
Translatable::set_current_locale('en_US'); Translatable::set_current_locale('en_US');
$actual = $parentPage->Children()->column('ID');
sort($actual);
$expected = array(
$child1Page->ID,
$child2Page->ID,
$child3Page->ID
);
$this->assertEquals( $this->assertEquals(
$parentPage->Children()->column('ID'), $actual,
array( $expected,
$child1Page->ID,
$child2Page->ID,
$child3Page->ID
),
"Showing Children() in default language doesnt show children in other languages" "Showing Children() in default language doesnt show children in other languages"
); );
@ -420,13 +429,17 @@ class TranslatableTest extends FunctionalTest {
"Showing liveChildren() in default language doesnt show children in other languages" "Showing liveChildren() in default language doesnt show children in other languages"
); );
$this->assertNotNull($parentPage->stageChildren()); $this->assertNotNull($parentPage->stageChildren());
$actual = $parentPage->stageChildren()->column('ID');
sort($actual);
$expected = array(
$child1Page->ID,
$child2Page->ID,
$child3Page->ID
);
sort($expected);
$this->assertEquals( $this->assertEquals(
$parentPage->stageChildren()->column('ID'), $actual,
array( $expected,
$child1Page->ID,
$child2Page->ID,
$child3Page->ID
),
"Showing stageChildren() in default language doesnt show children in other languages" "Showing stageChildren() in default language doesnt show children in other languages"
); );
@ -612,13 +625,17 @@ class TranslatableTest extends FunctionalTest {
SiteTree::flush_and_destroy_cache(); SiteTree::flush_and_destroy_cache();
$parentPage = $this->objFromFixture('Page', 'parent'); $parentPage = $this->objFromFixture('Page', 'parent');
$children = $parentPage->AllChildrenIncludingDeleted(); $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( $this->assertEquals(
$parentPage->AllChildrenIncludingDeleted()->column('ID'), $actual,
array( $expected,
$child2PageID,
$child3PageID,
$child1PageID // $child1Page was deleted from stage, so the original record doesn't have the ID set
),
"Showing AllChildrenIncludingDeleted() in default language doesnt show deleted children in other languages" "Showing AllChildrenIncludingDeleted() in default language doesnt show deleted children in other languages"
); );