Mass update tests to use callAPIFailure
[civicrm-core.git] / tests / phpunit / api / v3 / PaymentProcessorTypeTest.php
index fe1dc4137893defb12d56160f44233a3f1ad5e6a..50d857e52847516b5581ffcf3e74cd3855cbc739 100644 (file)
@@ -68,9 +68,7 @@ class api_v3_PaymentProcessorTypeTest extends CiviUnitTestCase {
       'is_active' => 1,
       'version' => $this->_apiversion,
     );
-    $result = civicrm_api('payment_processor_type', 'create', $payProcParams);
-
-    $this->assertEquals($result['is_error'], 1);
+    $result = $this->callAPIFailure('payment_processor_type', 'create', $payProcParams);
     $this->assertEquals($result['error_message'],
       'Mandatory key(s) missing from params array: name, title, class_name, billing_mode'
     );
@@ -91,6 +89,7 @@ class api_v3_PaymentProcessorTypeTest extends CiviUnitTestCase {
     );
     $result = civicrm_api('payment_processor_type', 'create', $params);
     $this->documentMe($params, $result, __FUNCTION__, __FILE__);
+    $this->assertAPISuccess($result);
     $this->assertNotNull($result['values'][0]['id'], 'in line ' . __LINE__);
 
     // mutate $params to match expected return value
@@ -108,7 +107,7 @@ class api_v3_PaymentProcessorTypeTest extends CiviUnitTestCase {
     require_once 'api/v3/examples/PaymentProcessorTypeCreate.php';
     $result = payment_processor_type_create_example();
     $expectedResult = payment_processor_type_create_expectedresult();
-    $this->assertEquals($result['is_error'], 0);
+    $this->assertAPISuccess($result);
   }
 
   ///////////////// civicrm_payment_processor_type_delete methods
@@ -118,18 +117,14 @@ class api_v3_PaymentProcessorTypeTest extends CiviUnitTestCase {
    */
   function testPaymentProcessorTypeDeleteEmpty() {
     $params = array();
-    $result = civicrm_api('payment_processor_type', 'delete', $params);
-
-    $this->assertEquals($result['is_error'], 1);
+    $result = $this->callAPIFailure('payment_processor_type', 'delete', $params);
   }
 
   /**
    * check with No array
    */
   function testPaymentProcessorTypeDeleteParamsNotArray() {
-    $result = civicrm_api('payment_processor_type', 'delete', 'string');
-
-    $this->assertEquals($result['is_error'], 1);
+    $result = $this->callAPIFailure('payment_processor_type', 'delete', 'string');
   }
 
   /**
@@ -142,10 +137,8 @@ class api_v3_PaymentProcessorTypeTest extends CiviUnitTestCase {
       'class_name' => 'CRM_Core_Payment_APITest',
     );
 
-    $result = civicrm_api('payment_processor_type', 'delete', $params);
-
-    $this->assertEquals($result['is_error'], 1);
-    $this->assertEquals($result['error_message'], 'Mandatory key(s) missing from params array: version, id');
+    $result = $this->callAPIFailure('payment_processor_type', 'delete', $params);
+    $this->assertEquals($result['error_message'], 'Mandatory key(s) missing from params array: id');
   }
 
   /**
@@ -157,9 +150,7 @@ class api_v3_PaymentProcessorTypeTest extends CiviUnitTestCase {
       'version' => $this->_apiversion,
     );
 
-    $result = civicrm_api('payment_processor_type', 'delete', $params);
-
-    $this->assertEquals($result['is_error'], 1);
+    $result = $this->callAPIFailure('payment_processor_type', 'delete', $params);
     $this->assertEquals($result['error_message'], 'Invalid value for payment processor type ID');
   }
 
@@ -176,7 +167,7 @@ class api_v3_PaymentProcessorTypeTest extends CiviUnitTestCase {
 
     $result = civicrm_api('payment_processor_type', 'delete', $params);
     $this->documentMe($params, $result, __FUNCTION__, __FILE__);
-    $this->assertEquals($result['is_error'], 0);
+    $this->assertAPISuccess($result);
   }
 
   ///////////////// civicrm_payment_processor_type_update
@@ -186,19 +177,15 @@ class api_v3_PaymentProcessorTypeTest extends CiviUnitTestCase {
    */
   function testPaymentProcessorTypeUpdateEmpty() {
     $params = array();
-    $result = civicrm_api('payment_processor_type', 'create', $params);
-
-    $this->assertEquals($result['is_error'], 1);
-    $this->assertEquals($result['error_message'], 'Mandatory key(s) missing from params array: version, name, title, class_name, billing_mode');
+    $result = $this->callAPIFailure('payment_processor_type', 'create', $params);
+    $this->assertEquals($result['error_message'], 'Mandatory key(s) missing from params array: name, title, class_name, billing_mode');
   }
 
   /**
    * check with No array
    */
   function testPaymentProcessorTypeUpdateParamsNotArray() {
-    $result = civicrm_api('payment_processor_type', 'create', 'string');
-
-    $this->assertEquals($result['is_error'], 1);
+    $result = $this->callAPIFailure('payment_processor_type', 'create', 'string');
     $this->assertEquals($result['error_message'], 'Input variable `params` is not an array');
   }
 
@@ -257,20 +244,12 @@ class api_v3_PaymentProcessorTypeTest extends CiviUnitTestCase {
       'version' => $this->_apiversion,
     );
     $second = civicrm_api('PaymentProcessorType', 'Create', $secondRelTypeParams);
-    $results = civicrm_api('payment_processor_type', 'get', array(
+    $result = civicrm_api('payment_processor_type', 'get', array(
       'version' => $this->_apiversion,
     ));
 
-    $this->assertEquals($baselineCount + 2, $results['count']);
-    $this->assertEquals(0, $results['is_error']);
-  }
-
-  /**
-   * check with params Not Array.
-   */
-  function testPaymentProcessorTypesGetParamsNotArray() {
-    $results = civicrm_api('payment_processor_type', 'get', 'string');
-    $this->assertEquals(1, $results['is_error']);
+    $this->assertEquals($baselineCount + 2, $result['count']);
+    $this->assertAPISuccess($result);
   }
 
   /**
@@ -302,11 +281,11 @@ class api_v3_PaymentProcessorTypeTest extends CiviUnitTestCase {
       'name' => 'API_Test_PP_12',
       'version' => $this->_apiversion,
     );
-    $results = civicrm_api('payment_processor_type', 'get', $params);
+    $result = civicrm_api('payment_processor_type', 'get', $params);
 
-    $this->assertEquals(0, $results['is_error'], ' in line ' . __LINE__);
-    $this->assertEquals(1, $results['count'], ' in line ' . __LINE__);
-    $this->assertEquals('CRM_Core_Payment_APITest_12', $results['values'][$results['id']]['class_name'], ' in line ' . __LINE__);
+    $this->assertAPISuccess($result);
+    $this->assertEquals(1, $result['count'], ' in line ' . __LINE__);
+    $this->assertEquals('CRM_Core_Payment_APITest_12', $result['values'][$result['id']]['class_name'], ' in line ' . __LINE__);
   }
 }