From cd61b61a848915a967680b3265070ab30ab3d365 Mon Sep 17 00:00:00 2001 From: Simon Welsh Date: Thu, 23 Aug 2012 17:34:17 +1200 Subject: [PATCH] FIX Use array_intersect() with expected values so that the order matches. The values in $values aren't returned in any order, so this test can randomly fail. This changes the check from expected = $values to $values \cap expected = $value. PHP's array_intersect maintains the keys of the first array, so order is preserved. The intersect also guarentees that the only accepted values are the expected ones. --- tests/model/DataObjectTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/model/DataObjectTest.php b/tests/model/DataObjectTest.php index 344c9d3ee..03a5a699f 100644 --- a/tests/model/DataObjectTest.php +++ b/tests/model/DataObjectTest.php @@ -863,7 +863,7 @@ class DataObjectTest extends SapphireTest { // Check that the values of those fields are properly read from the database $values = DataObject::get("DataObjectTest_Team", "\"DataObjectTest_Team\".\"ID\" IN ($obj1->ID, $obj2->ID)")->column("SubclassDatabaseField"); - $this->assertEquals(array('obj1', 'obj2'), $values); + $this->assertEquals(array_intersect($values, array('obj1', 'obj2')), $values); } function testClassNameSetForNewObjects() {