4 +--------------------------------------------------------------------+
5 | CiviCRM version 4.3 |
6 +--------------------------------------------------------------------+
7 | Copyright CiviCRM LLC (c) 2004-2013 |
8 +--------------------------------------------------------------------+
9 | This file is a part of CiviCRM. |
11 | CiviCRM is free software; you can copy, modify, and distribute it |
12 | under the terms of the GNU Affero General Public License |
13 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
15 | CiviCRM is distributed in the hope that it will be useful, but |
16 | WITHOUT ANY WARRANTY; without even the implied warranty of |
17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
18 | See the GNU Affero General Public License for more details. |
20 | You should have received a copy of the GNU Affero General Public |
21 | License and the CiviCRM Licensing Exception along |
22 | with this program; if not, contact CiviCRM LLC |
23 | at info[AT]civicrm[DOT]org. If you have questions about the |
24 | GNU Affero General Public License or the licensing of CiviCRM, |
25 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
26 +--------------------------------------------------------------------+
29 require_once 'CiviTest/CiviUnitTestCase.php';
32 * Class contains api test cases for "civicrm_payment_processor"
35 class api_v3_PaymentProcessorTest
extends CiviUnitTestCase
{
36 protected $_paymentProcessorType;
37 protected $_apiversion;
39 public $_eNoticeCompliant = TRUE;
42 'name' => 'PaymentProcessor Create',
43 'description' => 'Test all PaymentProcessor Create API methods.',
44 'group' => 'CiviCRM API Tests',
50 $this->_apiversion
= 3;
51 // Create dummy processor
53 'version' => $this->_apiversion
,
54 'name' => 'API_Test_PP_Type',
55 'title' => 'API Test Payment Processor Type',
56 'class_name' => 'CRM_Core_Payment_APITest',
57 'billing_mode' => 'form',
60 $result = civicrm_api('payment_processor_type', 'create', $params);
61 $this->_paymentProcessorType
= $result['id'];
62 $this->_params
= array(
63 'version' => $this->_apiversion
,
64 'name' => 'API Test PP',
65 'payment_processor_type_id' => $this->_paymentProcessorType
,
66 'class_name' => 'CRM_Core_Payment_APITest',
74 $tablesToTruncate = array(
75 'civicrm_payment_processor',
76 'civicrm_payment_processor_type',
78 $this->quickCleanup($tablesToTruncate);
81 ///////////////// civicrm_payment_processor_add methods
86 function testPaymentProcessorCreateWithoutName() {
87 $payProcParams = array(
89 'version' => $this->_apiversion
,
91 $result = $this->callAPIFailure('payment_processor', 'create', $payProcParams);
95 * create payment processor
97 function testPaymentProcessorCreate() {
98 $params = $this->_params
;
99 $result = civicrm_api('payment_processor', 'create', $params);
100 $this->assertAPISuccess($result);
101 $this->documentMe($params, $result, __FUNCTION__
, __FILE__
);
102 $this->assertNotNull($result['id'], 'in line ' . __LINE__
);
104 // mutate $params to match expected return value
105 unset($params['version']);
106 //assertDBState compares expected values in $result to actual values in the DB
107 $this->assertDBState('CRM_Financial_DAO_PaymentProcessor', $result['id'], $params);
108 return $result['id'];
112 * Test using example code
114 function testPaymentProcessorCreateExample() {
115 require_once 'api/v3/examples/PaymentProcessorCreate.php';
116 $result = payment_processor_create_example();
117 $expectedResult = payment_processor_create_expectedresult();
118 $this->assertAPISuccess($result);
121 ///////////////// civicrm_payment_processor_delete methods
124 * check payment processor type delete
126 function testPaymentProcessorDelete() {
127 $id = $this->testPaymentProcessorCreate();
128 // create sample payment processor type.
131 'version' => $this->_apiversion
,
134 $result = civicrm_api('payment_processor', 'delete', $params);
135 $this->documentMe($params, $result, __FUNCTION__
, __FILE__
);
136 $this->assertAPISuccess($result);
139 ///////////////// civicrm_payment_processors_get methods
142 * check with valid params array.
144 function testPaymentProcessorsGet() {
145 $params = $this->_params
;
146 $params['user_name'] = 'test@test.com';
147 civicrm_api('payment_processor', 'create', $params);
150 'user_name' => 'test@test.com',
151 'version' => $this->_apiversion
,
153 $results = civicrm_api('payment_processor', 'get', $params);
155 $this->assertEquals(0, $results['is_error'], ' in line ' . __LINE__
);
156 $this->assertEquals(1, $results['count'], ' in line ' . __LINE__
);
157 $this->assertEquals('test@test.com', $results['values'][$results['id']]['user_name'], ' in line ' . __LINE__
);