CRM-13072 upgrade PaymentProcessTypeTest & PaymentProcessorTest to pass post update...
[civicrm-core.git] / tests / phpunit / api / v3 / PaymentProcessorTest.php
index 701a2e79557e25ca27869a57fbe48b2f2f6e4a41..f3b21bb82439626555b7e4fc7d015bb591f2513b 100644 (file)
@@ -1,5 +1,4 @@
 <?php
-
 /*
  +--------------------------------------------------------------------+
  | CiviCRM version 4.3                                                |
@@ -34,7 +33,7 @@ require_once 'CiviTest/CiviUnitTestCase.php';
  */
 class api_v3_PaymentProcessorTest extends CiviUnitTestCase {
   protected $_paymentProcessorType;
-  protected $_apiversion;
+  protected $_apiversion = 3;
   protected $_params;
   public $_eNoticeCompliant = TRUE;
   function get_info() {
@@ -47,20 +46,17 @@ class api_v3_PaymentProcessorTest extends CiviUnitTestCase {
 
   function setUp() {
     parent::setUp();
-    $this->_apiversion = 3;
     // Create dummy processor
     $params = array(
-      'version' => $this->_apiversion,
       'name' => 'API_Test_PP_Type',
       'title' => 'API Test Payment Processor Type',
       'class_name' => 'CRM_Core_Payment_APITest',
       'billing_mode' => 'form',
       'is_recur' => 0,
     );
-    $result = civicrm_api('payment_processor_type', 'create', $params);
+    $result = $this->callAPISuccess('payment_processor_type', 'create', $params);
     $this->_paymentProcessorType = $result['id'];
     $this->_params = array(
-      'version' => $this->_apiversion,
       'name' => 'API Test PP',
       'payment_processor_type_id' => $this->_paymentProcessorType,
       'class_name' => 'CRM_Core_Payment_APITest',
@@ -86,7 +82,6 @@ class api_v3_PaymentProcessorTest extends CiviUnitTestCase {
   function testPaymentProcessorCreateWithoutName() {
     $payProcParams = array(
       'is_active' => 1,
-      'version' => $this->_apiversion,
     );
     $result = $this->callAPIFailure('payment_processor', 'create', $payProcParams);
   }
@@ -96,13 +91,9 @@ class api_v3_PaymentProcessorTest extends CiviUnitTestCase {
    */
   function testPaymentProcessorCreate() {
     $params = $this->_params;
-    $result = civicrm_api('payment_processor', 'create', $params);
-    $this->assertAPISuccess($result);
-    $this->documentMe($params, $result, __FUNCTION__, __FILE__);
+    $result = $this->callAPIAndDocument('payment_processor', 'create', $params, __FUNCTION__, __FILE__);
     $this->assertNotNull($result['id'], 'in line ' . __LINE__);
 
-    // mutate $params to match expected return value
-    unset($params['version']);
     //assertDBState compares expected values in $result to actual values in the DB
     $this->assertDBState('CRM_Financial_DAO_PaymentProcessor', $result['id'], $params);
     return $result['id'];
@@ -121,19 +112,15 @@ class api_v3_PaymentProcessorTest extends CiviUnitTestCase {
   ///////////////// civicrm_payment_processor_delete methods
 
   /**
-   * check payment processor type delete
+   * check payment processor delete
    */
   function testPaymentProcessorDelete() {
     $id = $this->testPaymentProcessorCreate();
-    // create sample payment processor type.
     $params = array(
       'id' => $id,
-      'version' => $this->_apiversion,
     );
 
-    $result = civicrm_api('payment_processor', 'delete', $params);
-    $this->documentMe($params, $result, __FUNCTION__, __FILE__);
-    $this->assertAPISuccess($result);
+    $result = $this->callAPIAndDocument('payment_processor', 'delete', $params, __FUNCTION__, __FILE__);
   }
 
   ///////////////// civicrm_payment_processors_get methods
@@ -144,15 +131,13 @@ class api_v3_PaymentProcessorTest extends CiviUnitTestCase {
   function testPaymentProcessorsGet() {
     $params = $this->_params;
     $params['user_name'] = 'test@test.com';
-    civicrm_api('payment_processor', 'create', $params);
+    $this->callAPISuccess('payment_processor', 'create', $params);
 
     $params = array(
       'user_name' => 'test@test.com',
-      'version' => $this->_apiversion,
     );
-    $results = civicrm_api('payment_processor', 'get', $params);
+    $results = $this->callAPISuccess('payment_processor', 'get', $params);
 
-    $this->assertEquals(0, $results['is_error'], ' in line ' . __LINE__);
     $this->assertEquals(1, $results['count'], ' in line ' . __LINE__);
     $this->assertEquals('test@test.com', $results['values'][$results['id']]['user_name'], ' in line ' . __LINE__);
   }