CRM-13072 upgrade PaymentProcessTypeTest & PaymentProcessorTest to pass post update...
[civicrm-core.git] / tests / phpunit / api / v3 / PaymentProcessorTypeTest.php
index 50d857e52847516b5581ffcf3e74cd3855cbc739..0b11710a9f6c7c4281bce5772380e263beeb614c 100644 (file)
@@ -1,5 +1,4 @@
 <?php
-
 /*
  +--------------------------------------------------------------------+
  | CiviCRM version 4.3                                                |
@@ -65,9 +64,7 @@ class api_v3_PaymentProcessorTypeTest extends CiviUnitTestCase {
    */
   function testPaymentProcessorTypeCreateWithoutName() {
     $payProcParams = array(
-      'is_active' => 1,
-      'version' => $this->_apiversion,
-    );
+      'is_active' => 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'
@@ -78,22 +75,17 @@ class api_v3_PaymentProcessorTypeTest extends CiviUnitTestCase {
    * create payment processor type
    */
   function testPaymentProcessorTypeCreate() {
-    $params = array(
-      'version' => $this->_apiversion,
-      'sequential' => 1,
+    $params = array(      'sequential' => 1,
       'name' => 'API_Test_PP',
       'title' => 'API Test Payment Processor',
       'class_name' => 'CRM_Core_Payment_APITest',
       'billing_mode' => 'form',
       'is_recur' => 0,
     );
-    $result = civicrm_api('payment_processor_type', 'create', $params);
-    $this->documentMe($params, $result, __FUNCTION__, __FILE__);
-    $this->assertAPISuccess($result);
+    $result = $this->callAPIAndDocument('payment_processor_type', 'create', $params, __FUNCTION__, __FILE__);
     $this->assertNotNull($result['values'][0]['id'], 'in line ' . __LINE__);
 
     // mutate $params to match expected return value
-    unset($params['version']);
     unset($params['sequential']);
     $params['billing_mode'] = CRM_Core_Payment::BILLING_MODE_FORM;
     //assertDBState compares expected values in $result to actual values in the DB
@@ -145,13 +137,7 @@ class api_v3_PaymentProcessorTypeTest extends CiviUnitTestCase {
    * check with incorrect required fields
    */
   function testPaymentProcessorTypeDeleteWithIncorrectData() {
-    $params = array(
-      'id' => 'abcd',
-      'version' => $this->_apiversion,
-    );
-
-    $result = $this->callAPIFailure('payment_processor_type', 'delete', $params);
-    $this->assertEquals($result['error_message'], 'Invalid value for payment processor type ID');
+    $result = $this->callAPIFailure('payment_processor_type', 'delete', array('id' => 'abcd'));
   }
 
   /**
@@ -159,15 +145,11 @@ class api_v3_PaymentProcessorTypeTest extends CiviUnitTestCase {
    */
   function testPaymentProcessorTypeDelete() {
     $payProcType = $this->paymentProcessorTypeCreate();
-    // create sample payment processor type.
     $params = array(
       'id' => $payProcType,
-      'version' => $this->_apiversion,
     );
 
-    $result = civicrm_api('payment_processor_type', 'delete', $params);
-    $this->documentMe($params, $result, __FUNCTION__, __FILE__);
-    $this->assertAPISuccess($result);
+    $result = $this->callAPIAndDocument('payment_processor_type', 'delete', $params, __FUNCTION__, __FILE__);
   }
 
   ///////////////// civicrm_payment_processor_type_update
@@ -202,13 +184,10 @@ class api_v3_PaymentProcessorTypeTest extends CiviUnitTestCase {
       'title' => 'API Test Payment Processor 2',
       'class_name' => 'CRM_Core_Payment_APITest 2',
       'billing_mode' => 2,
-      'is_recur' => 0,
-      'version' => $this->_apiversion,
-    );
+      'is_recur' => 0,    );
 
-    $result = civicrm_api('payment_processor_type', 'create', $params);
+    $result = $this->callAPISuccess('payment_processor_type', 'create', $params);
     $this->assertNotNull($result['id']);
-    unset($params['version']);
     // assertDBState compares expected values in $result to actual values in the DB
     $this->assertDBState('CRM_Financial_DAO_PaymentProcessorType', $this->_ppTypeID, $params);
   }
@@ -219,9 +198,7 @@ class api_v3_PaymentProcessorTypeTest extends CiviUnitTestCase {
    * check with empty array
    */
   function testPaymentProcessorTypesGetEmptyParams() {
-    $results = civicrm_api('payment_processor_type', 'get', array(
-      'version' => $this->_apiversion,
-    ));
+    $results = $this->callAPISuccess('payment_processor_type', 'get', array(    ));
     $baselineCount = $results['count'];
 
     $firstRelTypeParams = array(
@@ -229,24 +206,18 @@ class api_v3_PaymentProcessorTypeTest extends CiviUnitTestCase {
       'title' => 'API Test Payment Processor',
       'class_name' => 'CRM_Core_Payment_APITest',
       'billing_mode' => 1,
-      'is_recur' => 0,
-      'version' => $this->_apiversion,
-    );
+      'is_recur' => 0,    );
 
-    $first = civicrm_api('PaymentProcessorType', 'Create', $firstRelTypeParams);
+    $first = $this->callAPISuccess('PaymentProcessorType', 'Create', $firstRelTypeParams);
 
     $secondRelTypeParams = array(
       'name' => 'API_Test_PP2',
       'title' => 'API Test Payment Processor 2',
       'class_name' => 'CRM_Core_Payment_APITest 2',
       'billing_mode' => 2,
-      'is_recur' => 0,
-      'version' => $this->_apiversion,
-    );
-    $second = civicrm_api('PaymentProcessorType', 'Create', $secondRelTypeParams);
-    $result = civicrm_api('payment_processor_type', 'get', array(
-      'version' => $this->_apiversion,
-    ));
+      'is_recur' => 0,    );
+    $second = $this->callAPISuccess('PaymentProcessorType', 'Create', $secondRelTypeParams);
+    $result = $this->callAPISuccess('payment_processor_type', 'get', array(    ));
 
     $this->assertEquals($baselineCount + 2, $result['count']);
     $this->assertAPISuccess($result);
@@ -261,27 +232,21 @@ class api_v3_PaymentProcessorTypeTest extends CiviUnitTestCase {
       'title' => 'API Test Payment Processor 11',
       'class_name' => 'CRM_Core_Payment_APITest_11',
       'billing_mode' => 1,
-      'is_recur' => 0,
-      'version' => $this->_apiversion,
-    );
+      'is_recur' => 0,    );
 
-    $first = civicrm_api('PaymentProcessorType', 'Create', $firstRelTypeParams);
+    $first = $this->callAPISuccess('PaymentProcessorType', 'Create', $firstRelTypeParams);
 
     $secondRelTypeParams = array(
       'name' => 'API_Test_PP_12',
       'title' => 'API Test Payment Processor 12',
       'class_name' => 'CRM_Core_Payment_APITest_12',
       'billing_mode' => 2,
-      'is_recur' => 0,
-      'version' => $this->_apiversion,
-    );
-    $second = civicrm_api('PaymentProcessorType', 'Create', $secondRelTypeParams);
+      'is_recur' => 0,    );
+    $second = $this->callAPISuccess('PaymentProcessorType', 'Create', $secondRelTypeParams);
 
     $params = array(
-      'name' => 'API_Test_PP_12',
-      'version' => $this->_apiversion,
-    );
-    $result = civicrm_api('payment_processor_type', 'get', $params);
+      'name' => 'API_Test_PP_12',    );
+    $result = $this->callAPISuccess('payment_processor_type', 'get', $params);
 
     $this->assertAPISuccess($result);
     $this->assertEquals(1, $result['count'], ' in line ' . __LINE__);