<?php
-
/*
+--------------------------------------------------------------------+
| CiviCRM version 4.3 |
*/
class api_v3_PaymentProcessorTest extends CiviUnitTestCase {
protected $_paymentProcessorType;
- protected $_apiversion;
+ protected $_apiversion = 3;
protected $_params;
public $_eNoticeCompliant = TRUE;
function get_info() {
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',
function testPaymentProcessorCreateWithoutName() {
$payProcParams = array(
'is_active' => 1,
- 'version' => $this->_apiversion,
);
$result = $this->callAPIFailure('payment_processor', 'create', $payProcParams);
}
*/
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'];
///////////////// 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
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__);
}
<?php
-
/*
+--------------------------------------------------------------------+
| CiviCRM version 4.3 |
*/
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'
* 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
* 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'));
}
/**
*/
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
'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);
}
* 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(
'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);
'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__);