Don't rely on MySQL ordering of index->getAdded()

MySQL is more reliable in its output ordering of elements where the order doesn't matter.
PostgreSQL is not.  This meant that this test "accidentally passed" on MySQL and failed on
PostgreSQL.  The sort function resolves this.
This commit is contained in:
Sam Minnee 2014-02-14 11:32:20 +13:00
parent 995a8a1d01
commit 4b51393e01
1 changed files with 12 additions and 2 deletions

View File

@ -107,7 +107,13 @@ class SearchUpdaterTest extends SapphireTest {
// Check the default "writing a document updates the document"
SearchUpdater::flush_dirty_indexes();
$this->assertEquals(self::$index->getAdded(array('ID')), array(
$added = self::$index->getAdded(array('ID'));
// Some databases don't output $added in a consistent order; that's okay
usort($added, function($a,$b) {return $a['ID']-$b['ID']; });
$this->assertEquals($added, array(
array('ID' => $container1->ID),
array('ID' => $container2->ID),
array('ID' => $container3->ID)
@ -121,7 +127,11 @@ class SearchUpdaterTest extends SapphireTest {
$hasOne->write();
SearchUpdater::flush_dirty_indexes();
$this->assertEquals(self::$index->getAdded(array('ID')), array(
$added = self::$index->getAdded(array('ID'));
// Some databases don't output $added in a consistent order; that's okay
usort($added, function($a,$b) {return $a['ID']-$b['ID']; });
$this->assertEquals($added, array(
array('ID' => $container1->ID),
array('ID' => $container2->ID)
));