3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.7 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2016 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
19 | You should have received a copy of the GNU Affero General Public |
20 | License and the CiviCRM Licensing Exception along |
21 | with this program; if not, contact CiviCRM LLC |
22 | at info[AT]civicrm[DOT]org. If you have questions about the |
23 | GNU Affero General Public License or the licensing of CiviCRM, |
24 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
25 +--------------------------------------------------------------------+
29 * Class contains api test cases for "civicrm_payment_processor"
33 class api_v3_PaymentProcessorTest
extends CiviUnitTestCase
{
34 protected $_paymentProcessorType;
35 protected $_apiversion = 3;
38 public function setUp() {
40 $this->useTransaction(TRUE);
41 // Create dummy processor
43 'name' => 'API_Test_PP_Type',
44 'title' => 'API Test Payment Processor Type',
45 'class_name' => 'CRM_Core_Payment_APITest',
46 'billing_mode' => 'form',
49 $result = $this->callAPISuccess('payment_processor_type', 'create', $params);
50 $this->_paymentProcessorType
= $result['id'];
51 $this->_params
= array(
52 'name' => 'API Test PP',
53 'payment_processor_type_id' => $this->_paymentProcessorType
,
54 'class_name' => 'CRM_Core_Payment_APITest',
60 ///////////////// civicrm_payment_processor_add methods
65 public function testPaymentProcessorCreateWithoutName() {
66 $payProcParams = array(
69 $result = $this->callAPIFailure('payment_processor', 'create', $payProcParams);
73 * Create payment processor.
75 public function testPaymentProcessorCreate() {
76 $params = $this->_params
;
77 $result = $this->callAPIAndDocument('payment_processor', 'create', $params, __FUNCTION__
, __FILE__
);
78 $this->assertNotNull($result['id']);
80 //assertDBState compares expected values in $result to actual values in the DB
81 $this->assertDBState('CRM_Financial_DAO_PaymentProcessor', $result['id'], $params);
86 * Test using example code.
88 public function testPaymentProcessorCreateExample() {
89 require_once 'api/v3/examples/PaymentProcessor/Create.php';
90 $result = payment_processor_create_example();
91 $expectedResult = payment_processor_create_expectedresult();
92 $this->assertAPISuccess($result);
95 ///////////////// civicrm_payment_processor_delete methods
98 * Check payment processor delete.
100 public function testPaymentProcessorDelete() {
101 $id = $this->testPaymentProcessorCreate();
106 $result = $this->callAPIAndDocument('payment_processor', 'delete', $params, __FUNCTION__
, __FILE__
);
109 ///////////////// civicrm_payment_processors_get methods
112 * Check with valid params array.
114 public function testPaymentProcessorsGet() {
115 $params = $this->_params
;
116 $params['user_name'] = 'test@test.com';
117 $this->callAPISuccess('payment_processor', 'create', $params);
120 'user_name' => 'test@test.com',
122 $results = $this->callAPISuccess('payment_processor', 'get', $params);
124 $this->assertEquals(1, $results['count'], ' in line ' . __LINE__
);
125 $this->assertEquals('test@test.com', $results['values'][$results['id']]['user_name'], ' in line ' . __LINE__
);