3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.7 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2015 |
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"
32 class api_v3_PaymentProcessorTest
extends CiviUnitTestCase
{
33 protected $_paymentProcessorType;
34 protected $_apiversion = 3;
37 public function setUp() {
39 $this->useTransaction(TRUE);
40 // Create dummy processor
42 'name' => 'API_Test_PP_Type',
43 'title' => 'API Test Payment Processor Type',
44 'class_name' => 'CRM_Core_Payment_APITest',
45 'billing_mode' => 'form',
48 $result = $this->callAPISuccess('payment_processor_type', 'create', $params);
49 $this->_paymentProcessorType
= $result['id'];
50 $this->_params
= array(
51 'name' => 'API Test PP',
52 'payment_processor_type_id' => $this->_paymentProcessorType
,
53 'class_name' => 'CRM_Core_Payment_APITest',
59 ///////////////// civicrm_payment_processor_add methods
64 public function testPaymentProcessorCreateWithoutName() {
65 $payProcParams = array(
68 $result = $this->callAPIFailure('payment_processor', 'create', $payProcParams);
72 * Create payment processor.
74 public function testPaymentProcessorCreate() {
75 $params = $this->_params
;
76 $result = $this->callAPIAndDocument('payment_processor', 'create', $params, __FUNCTION__
, __FILE__
);
77 $this->assertNotNull($result['id']);
79 //assertDBState compares expected values in $result to actual values in the DB
80 $this->assertDBState('CRM_Financial_DAO_PaymentProcessor', $result['id'], $params);
85 * Test using example code.
87 public function testPaymentProcessorCreateExample() {
88 require_once 'api/v3/examples/PaymentProcessor/Create.php';
89 $result = payment_processor_create_example();
90 $expectedResult = payment_processor_create_expectedresult();
91 $this->assertAPISuccess($result);
94 ///////////////// civicrm_payment_processor_delete methods
97 * Check payment processor delete.
99 public function testPaymentProcessorDelete() {
100 $id = $this->testPaymentProcessorCreate();
105 $result = $this->callAPIAndDocument('payment_processor', 'delete', $params, __FUNCTION__
, __FILE__
);
108 ///////////////// civicrm_payment_processors_get methods
111 * Check with valid params array.
113 public function testPaymentProcessorsGet() {
114 $params = $this->_params
;
115 $params['user_name'] = 'test@test.com';
116 $this->callAPISuccess('payment_processor', 'create', $params);
119 'user_name' => 'test@test.com',
121 $results = $this->callAPISuccess('payment_processor', 'get', $params);
123 $this->assertEquals(1, $results['count'], ' in line ' . __LINE__
);
124 $this->assertEquals('test@test.com', $results['values'][$results['id']]['user_name'], ' in line ' . __LINE__
);