Merge pull request #23467 from christianwach/event-caps
[civicrm-core.git] / tests / phpunit / CRM / Financial / BAO / PaymentProcessorTypeTest.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
5 | |
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
10 */
11
12 /**
13 * Class CRM_Financial_BAO_PaymentProcessorTypeTest
14 * @group headless
15 */
16 class CRM_Financial_BAO_PaymentProcessorTypeTest extends CiviUnitTestCase {
17
18 /**
19 * Check method create()
20 */
21 public function testCreate() {
22 $params = [
23 'name' => 'Test_Payment_Processor',
24 'title' => 'Test Payment Processor',
25 'billing_mode' => 1,
26 'class_name' => 'Payment_Dummy',
27 ];
28 $paymentProcessor = CRM_Financial_BAO_PaymentProcessorType::create($params);
29 $result = $this->assertDBNotNull(
30 'CRM_Financial_DAO_PaymentProcessorType',
31 $paymentProcessor->name,
32 'title',
33 'name',
34 'Database check on added payment processor type record.'
35 );
36 $this->assertEquals($result, 'Test Payment Processor', 'Verify Payment Processor Type');
37 }
38
39 /**
40 * Check method retrieve()
41 */
42 public function testRetrieve() {
43 $params = [
44 'name' => 'Test_Retrieve_Payment_Processor',
45 'title' => 'Test Retrieve Payment Processor',
46 'billing_mode' => 1,
47 'class_name' => 'Payment_Dummy',
48 ];
49 $defaults = [];
50 CRM_Financial_BAO_PaymentProcessorType::create($params);
51 $result = CRM_Financial_BAO_PaymentProcessorType::retrieve($params, $defaults);
52 $this->assertEquals($result->name, 'Test_Retrieve_Payment_Processor', 'Verify Payment Processor Type');
53 }
54
55 /**
56 * Check method setIsActive()
57 */
58 public function testSetIsActive() {
59 $params = [
60 'name' => 'Test_Set_Payment_Processor',
61 'title' => 'Test Set Payment Processor',
62 'billing_mode' => 1,
63 'is_active' => 1,
64 'class_name' => 'Payment_Dummy',
65 ];
66
67 $paymentProcessor = CRM_Financial_BAO_PaymentProcessorType::create($params);
68 $result = CRM_Financial_BAO_PaymentProcessorType::setIsActive($paymentProcessor->id, 0);
69 $this->assertEquals($result, TRUE, 'Verify financial type record updation for is_active.');
70
71 $isActive = $this->assertDBNotNull(
72 'CRM_Financial_DAO_PaymentProcessorType',
73 $paymentProcessor->id,
74 'is_active',
75 'id',
76 'Database check on updated for payment processor type is_active.'
77 );
78 $this->assertEquals($isActive, 0, 'Verify payment processor types is_active.');
79 }
80
81 /**
82 * Check method getDefault()
83 */
84 public function testGetDefault() {
85 $params = ['is_default' => 1];
86 $defaults = [];
87 $result = CRM_Financial_BAO_PaymentProcessorType::retrieve($params, $defaults);
88
89 $default = CRM_Financial_BAO_PaymentProcessorType::getDefault();
90 $this->assertEquals($result->name, $default->name, 'Verify default payment processor.');
91 }
92
93 /**
94 * Check method del()
95 */
96 public function testDel() {
97 $params = [
98 'name' => 'Test_Del_Payment_Processor',
99 'title' => 'Test Del Payment Processor',
100 'billing_mode' => 1,
101 'is_active' => 1,
102 'class_name' => 'Payment_Dummy',
103 ];
104
105 $defaults = [];
106 $paymentProcessor = CRM_Financial_BAO_PaymentProcessorType::create($params);
107 CRM_Financial_BAO_PaymentProcessorType::del($paymentProcessor->id);
108
109 $params = ['id' => $paymentProcessor->id];
110 $result = CRM_Financial_BAO_PaymentProcessorType::retrieve($params, $defaults);
111 $this->assertEquals(empty($result), TRUE, 'Verify financial types record deletion.');
112 }
113
114 }