Merge pull request #22291 from eileenmcnaughton/amount_block
[civicrm-core.git] / tests / phpunit / CRM / Financial / BAO / PaymentProcessorTypeTest.php
CommitLineData
6a488035
TO
1<?php
2/*
3 +--------------------------------------------------------------------+
7d61e75f 4 | Copyright CiviCRM LLC. All rights reserved. |
6a488035 5 | |
7d61e75f
TO
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 |
6a488035 9 +--------------------------------------------------------------------+
d25dd0ee 10 */
6a488035 11
4cbe18b8
EM
12/**
13 * Class CRM_Financial_BAO_PaymentProcessorTypeTest
acb109b7 14 * @group headless
4cbe18b8 15 */
6a488035
TO
16class CRM_Financial_BAO_PaymentProcessorTypeTest extends CiviUnitTestCase {
17
6a488035 18 /**
100fef9d 19 * Check method create()
6a488035 20 */
00be9182 21 public function testCreate() {
9099cab3 22 $params = [
6a488035
TO
23 'name' => 'Test_Payment_Processor',
24 'title' => 'Test Payment Processor',
25 'billing_mode' => 1,
2f859d0a 26 'class_name' => 'Payment_Dummy',
9099cab3 27 ];
6a488035
TO
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 );
481a74f4 36 $this->assertEquals($result, 'Test Payment Processor', 'Verify Payment Processor Type');
6a488035
TO
37 }
38
39 /**
100fef9d 40 * Check method retrieve()
6a488035 41 */
00be9182 42 public function testRetrieve() {
9099cab3 43 $params = [
6a488035
TO
44 'name' => 'Test_Retrieve_Payment_Processor',
45 'title' => 'Test Retrieve Payment Processor',
46 'billing_mode' => 1,
2f859d0a 47 'class_name' => 'Payment_Dummy',
9099cab3
CW
48 ];
49 $defaults = [];
6a488035
TO
50 CRM_Financial_BAO_PaymentProcessorType::create($params);
51 $result = CRM_Financial_BAO_PaymentProcessorType::retrieve($params, $defaults);
481a74f4 52 $this->assertEquals($result->name, 'Test_Retrieve_Payment_Processor', 'Verify Payment Processor Type');
6a488035
TO
53 }
54
55 /**
100fef9d 56 * Check method setIsActive()
6a488035 57 */
00be9182 58 public function testSetIsActive() {
9099cab3 59 $params = [
6a488035
TO
60 'name' => 'Test_Set_Payment_Processor',
61 'title' => 'Test Set Payment Processor',
62 'billing_mode' => 1,
63 'is_active' => 1,
2f859d0a 64 'class_name' => 'Payment_Dummy',
9099cab3 65 ];
6a488035
TO
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 /**
100fef9d 82 * Check method getDefault()
6a488035 83 */
00be9182 84 public function testGetDefault() {
9099cab3
CW
85 $params = ['is_default' => 1];
86 $defaults = [];
6a488035
TO
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 /**
100fef9d 94 * Check method del()
6a488035 95 */
00be9182 96 public function testDel() {
9099cab3 97 $params = [
6a488035
TO
98 'name' => 'Test_Del_Payment_Processor',
99 'title' => 'Test Del Payment Processor',
100 'billing_mode' => 1,
101 'is_active' => 1,
2f859d0a 102 'class_name' => 'Payment_Dummy',
9099cab3 103 ];
6a488035 104
9099cab3 105 $defaults = [];
6a488035
TO
106 $paymentProcessor = CRM_Financial_BAO_PaymentProcessorType::create($params);
107 CRM_Financial_BAO_PaymentProcessorType::del($paymentProcessor->id);
108
9099cab3 109 $params = ['id' => $paymentProcessor->id];
6a488035
TO
110 $result = CRM_Financial_BAO_PaymentProcessorType::retrieve($params, $defaults);
111 $this->assertEquals(empty($result), TRUE, 'Verify financial types record deletion.');
112 }
96025800 113
232624b1 114}