[NFC] Fix test failure on MySQL8 because of lack of order in API
authorSeamus Lee <seamuslee001@gmail.com>
Tue, 15 Jun 2021 02:50:50 +0000 (12:50 +1000)
committerSeamus Lee <seamuslee001@gmail.com>
Tue, 15 Jun 2021 02:50:50 +0000 (12:50 +1000)
tests/phpunit/api/v3/ContactTest.php

index b7cd5c74c0c03da32060e64c8daefa6084bf3e5f..e3a56d0bb3d34c90a19444be73289ebe891d8635 100644 (file)
@@ -305,7 +305,11 @@ class api_v3_ContactTest extends CiviUnitTestCase {
 
     // get all students and parents
     $result = $this->callAPISuccess('Contact', 'get', ['return' => 'id', 'contact_sub_type' => ['IN' => ['Parent', 'Student']]])['values'];
-    $this->assertEquals([$student['id'], $parent['id']], array_keys($result));
+    // check that we retrieved the student and the parent.
+    // On MySQL 8 this can have different order in the array as there is no specific order set.
+    $this->assertArrayHasKey($student['id'], $result);
+    $this->assertArrayHasKey($parent['id'], $result);
+    $this->assertCount(2, $result);
   }
 
   /**