/**
* Cleanup after tests.
+ *
+ * @throws \CRM_Core_Exception
*/
public function tearDown() {
$this->quickCleanup(['civicrm_contact'], TRUE);
* 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;
$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]);
}
/**
* 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]));
}
}