Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
2fe49090 | 4 | | CiviCRM version 5 | |
6a488035 | 5 | +--------------------------------------------------------------------+ |
8c9251b3 | 6 | | Copyright CiviCRM LLC (c) 2004-2018 | |
6a488035 TO |
7 | +--------------------------------------------------------------------+ |
8 | | This file is a part of CiviCRM. | | |
9 | | | | |
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. | | |
13 | | | | |
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. | | |
18 | | | | |
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 | +--------------------------------------------------------------------+ | |
d25dd0ee | 26 | */ |
6a488035 | 27 | |
4cbe18b8 EM |
28 | /** |
29 | * Class CRM_Financial_BAO_PaymentProcessorTypeTest | |
acb109b7 | 30 | * @group headless |
4cbe18b8 | 31 | */ |
6a488035 TO |
32 | class CRM_Financial_BAO_PaymentProcessorTypeTest extends CiviUnitTestCase { |
33 | ||
00be9182 | 34 | public function setUp() { |
6a488035 TO |
35 | parent::setUp(); |
36 | } | |
37 | ||
38 | /** | |
100fef9d | 39 | * Check method create() |
6a488035 | 40 | */ |
00be9182 | 41 | public function testCreate() { |
6a488035 TO |
42 | $params = array( |
43 | 'name' => 'Test_Payment_Processor', | |
44 | 'title' => 'Test Payment Processor', | |
45 | 'billing_mode' => 1, | |
46 | ); | |
47 | $paymentProcessor = CRM_Financial_BAO_PaymentProcessorType::create($params); | |
48 | $result = $this->assertDBNotNull( | |
49 | 'CRM_Financial_DAO_PaymentProcessorType', | |
50 | $paymentProcessor->name, | |
51 | 'title', | |
52 | 'name', | |
53 | 'Database check on added payment processor type record.' | |
54 | ); | |
481a74f4 | 55 | $this->assertEquals($result, 'Test Payment Processor', 'Verify Payment Processor Type'); |
6a488035 TO |
56 | } |
57 | ||
58 | /** | |
100fef9d | 59 | * Check method retrieve() |
6a488035 | 60 | */ |
00be9182 | 61 | public function testRetrieve() { |
6a488035 TO |
62 | $params = array( |
63 | 'name' => 'Test_Retrieve_Payment_Processor', | |
64 | 'title' => 'Test Retrieve Payment Processor', | |
65 | 'billing_mode' => 1, | |
66 | ); | |
67 | $defaults = array(); | |
68 | CRM_Financial_BAO_PaymentProcessorType::create($params); | |
69 | $result = CRM_Financial_BAO_PaymentProcessorType::retrieve($params, $defaults); | |
481a74f4 | 70 | $this->assertEquals($result->name, 'Test_Retrieve_Payment_Processor', 'Verify Payment Processor Type'); |
6a488035 TO |
71 | } |
72 | ||
73 | /** | |
100fef9d | 74 | * Check method setIsActive() |
6a488035 | 75 | */ |
00be9182 | 76 | public function testSetIsActive() { |
6a488035 TO |
77 | $params = array( |
78 | 'name' => 'Test_Set_Payment_Processor', | |
79 | 'title' => 'Test Set Payment Processor', | |
80 | 'billing_mode' => 1, | |
81 | 'is_active' => 1, | |
82 | ); | |
83 | ||
84 | $paymentProcessor = CRM_Financial_BAO_PaymentProcessorType::create($params); | |
85 | $result = CRM_Financial_BAO_PaymentProcessorType::setIsActive($paymentProcessor->id, 0); | |
86 | $this->assertEquals($result, TRUE, 'Verify financial type record updation for is_active.'); | |
87 | ||
88 | $isActive = $this->assertDBNotNull( | |
89 | 'CRM_Financial_DAO_PaymentProcessorType', | |
90 | $paymentProcessor->id, | |
91 | 'is_active', | |
92 | 'id', | |
93 | 'Database check on updated for payment processor type is_active.' | |
94 | ); | |
95 | $this->assertEquals($isActive, 0, 'Verify payment processor types is_active.'); | |
96 | } | |
97 | ||
98 | /** | |
100fef9d | 99 | * Check method getDefault() |
6a488035 | 100 | */ |
00be9182 | 101 | public function testGetDefault() { |
6a488035 TO |
102 | $params = array('is_default' => 1); |
103 | $defaults = array(); | |
104 | $result = CRM_Financial_BAO_PaymentProcessorType::retrieve($params, $defaults); | |
105 | ||
106 | $default = CRM_Financial_BAO_PaymentProcessorType::getDefault(); | |
107 | $this->assertEquals($result->name, $default->name, 'Verify default payment processor.'); | |
108 | } | |
109 | ||
110 | /** | |
100fef9d | 111 | * Check method del() |
6a488035 | 112 | */ |
00be9182 | 113 | public function testDel() { |
6a488035 TO |
114 | $params = array( |
115 | 'name' => 'Test_Del_Payment_Processor', | |
116 | 'title' => 'Test Del Payment Processor', | |
117 | 'billing_mode' => 1, | |
118 | 'is_active' => 1, | |
119 | ); | |
120 | ||
121 | $defaults = array(); | |
122 | $paymentProcessor = CRM_Financial_BAO_PaymentProcessorType::create($params); | |
123 | CRM_Financial_BAO_PaymentProcessorType::del($paymentProcessor->id); | |
124 | ||
125 | $params = array('id' => $paymentProcessor->id); | |
126 | $result = CRM_Financial_BAO_PaymentProcessorType::retrieve($params, $defaults); | |
127 | $this->assertEquals(empty($result), TRUE, 'Verify financial types record deletion.'); | |
128 | } | |
96025800 | 129 | |
232624b1 | 130 | } |