(dev/core#4188) Update APIv4 tests for phpunit9 compatibility
authorTim Otten <totten@civicrm.org>
Tue, 28 Mar 2023 23:02:01 +0000 (16:02 -0700)
committerTim Otten <totten@civicrm.org>
Tue, 28 Mar 2023 23:02:01 +0000 (16:02 -0700)
These tests failed on `phpunit9` because upstream swapped out around the semantics of `assertContains()`.

The specific issue is whether an array like `["1","2","3"]` contains the value `2`.

* `assertContains()` in phpunit8 says yes.
* `assertContains()` in phpunit9 says no.
* `assertContainsEquals()` in both phpunit8+phpunit9 says yes.

tests/phpunit/api/v4/Action/ContactDuplicatesTest.php
tests/phpunit/api/v4/Custom/BasicCustomFieldTest.php

index 5c2442ad7bfdd585cd0e40de0e4f13f3c0965871..3e3b1914dea987ef198e9c1381c968066dbe4c6a 100644 (file)
@@ -124,9 +124,9 @@ class ContactDuplicatesTest extends CustomTestBase {
       ->execute()->column('id');
 
     $this->assertCount(3, $found);
-    $this->assertContains($testContacts[0], $found);
-    $this->assertContains($testContacts[1], $found);
-    $this->assertContains($testContacts[3], $found);
+    $this->assertContainsEquals($testContacts[0], $found);
+    $this->assertContainsEquals($testContacts[1], $found);
+    $this->assertContainsEquals($testContacts[3], $found);
 
     $found = Contact::getDuplicates(FALSE)
       ->setDedupeRule('customRule')
@@ -136,8 +136,8 @@ class ContactDuplicatesTest extends CustomTestBase {
       ->execute()->column('id');
 
     $this->assertCount(2, $found);
-    $this->assertContains($testContacts[2], $found);
-    $this->assertContains($testContacts[4], $found);
+    $this->assertContainsEquals($testContacts[2], $found);
+    $this->assertContainsEquals($testContacts[4], $found);
   }
 
   public function testMergeDuplicates():void {
index 5772a7e31220f62c78437b72c51e12fd8d5f5571..d086558d27ae52ef97cda007d4345f53edc2339e 100644 (file)
@@ -589,7 +589,7 @@ class BasicCustomFieldTest extends CustomTestBase {
         ->addValue('html_type', 'Text')
       )
       ->execute()->single();
-    $this->assertContains($financialType['id'], $contributionGroup['extends_entity_column_value']);
+    $this->assertContainsEquals($financialType['id'], $contributionGroup['extends_entity_column_value']);
 
     $getFieldsWithTestType = Contribution::getFields(FALSE)
       ->addValue('financial_type_id:name', 'Test_Type')