[REF] Clarify variable & tighten use.
[civicrm-core.git] / tests / phpunit / api / v3 / JobTestCustomDataTest.php
index 2ab1dc37dd2804356ea065d9c077fcb1897b635a..33062c5848abb4fac12b5b0e656faed6d07b2f03 100644 (file)
@@ -108,6 +108,8 @@ class api_v3_JobTestCustomDataTest extends CiviUnitTestCase {
 
   /**
    * Cleanup after tests.
+   *
+   * @throws \CRM_Core_Exception
    */
   public function tearDown() {
     $this->quickCleanup(['civicrm_contact'], TRUE);
@@ -129,6 +131,10 @@ class api_v3_JobTestCustomDataTest extends CiviUnitTestCase {
    * 4) NULL (ie not set)
    *  - in safe mode NULL is not a conflict with any option but the other
    *   combos are a conflict.
+   *
+   * @param array $dataSet
+   *
+   * @throws \CRM_Core_Exception
    */
   public function testBatchMergeCheckboxCustomFieldHandling($dataSet) {
     $customFieldLabel = 'custom_' . $this->customStringCheckboxID;
@@ -137,8 +143,8 @@ class api_v3_JobTestCustomDataTest extends CiviUnitTestCase {
     $contactID = $this->individualCreate($contact1Params);
     $this->individualCreate($contact2Params);
     $result = $this->callAPISuccess('Job', 'process_batch_merge', ['mode' => $dataSet['mode']]);
-    $this->assertEquals($dataSet['merged'], count($result['values']['merged']));
-    $this->assertEquals($dataSet['skipped'], count($result['values']['skipped']));
+    $this->assertCount($dataSet['merged'], $result['values']['merged']);
+    $this->assertCount($dataSet['skipped'], $result['values']['skipped']);
     $contact = $this->callAPISuccess('Contact', 'getsingle', ['id' => $contactID, 'return' => $customFieldLabel]);
     $this->assertEquals($dataSet['expected'], $contact[$customFieldLabel]);
   }
@@ -393,24 +399,29 @@ class api_v3_JobTestCustomDataTest extends CiviUnitTestCase {
 
   /**
    * Check we get a conflict on the customs field when the data conflicts for booleans (reverse).
+   *
+   * @throws \CRM_Core_Exception
    */
-  public function testBatchMergeCustomFieldConflictsOneBlank() {
+  public function testBatchMergeCustomFieldNoConflictsOneBlank() {
     $this->individualCreate(['custom_' . $this->customBoolFieldID => 1]);
     $this->individualCreate();
     $result = $this->callAPISuccess('Job', 'process_batch_merge', []);
-    $this->assertEquals(1, count($result['values']['merged']));
-    $this->assertEquals(0, count($result['values']['skipped']));
+    $this->assertCount(1, $result['values']['merged']);
+    $this->assertCount(0, $result['values']['skipped']);
   }
 
   /**
    * Check we get a conflict on the customs field when the data conflicts for booleans (reverse).
+   *
+   * @throws \CRM_Core_Exception
    */
-  public function testBatchMergeCustomFieldConflictsOneBlankReverse() {
-    $this->individualCreate();
+  public function testBatchMergeCustomFieldNoConflictsOneBlankReverse() {
+    $contactID = $this->individualCreate();
     $this->individualCreate(['custom_' . $this->customBoolFieldID => 1]);
     $result = $this->callAPISuccess('Job', 'process_batch_merge', []);
-    $this->assertEquals(1, count($result['values']['merged']));
-    $this->assertEquals(0, count($result['values']['skipped']));
+    $this->assertCount(1, $result['values']['merged']);
+    $this->assertCount(0, $result['values']['skipped']);
+    $this->assertEquals(1, $this->callAPISuccessGetValue('Contact', ['id' => $contactID, 'return' => 'custom_' . $this->customBoolFieldID]));
   }
 
 }