Merge pull request #7743 from eileenmcnaughton/entityFinancialAccount
[civicrm-core.git] / tests / phpunit / CRM / Financial / BAO / PaymentProcessorTypeTest.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.7 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2015 |
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 +--------------------------------------------------------------------+
26 */
27
28 /**
29 * Class CRM_Financial_BAO_PaymentProcessorTypeTest
30 */
31 class CRM_Financial_BAO_PaymentProcessorTypeTest extends CiviUnitTestCase {
32
33 public function setUp() {
34 parent::setUp();
35 }
36
37 /**
38 * Check method create()
39 */
40 public function testCreate() {
41 $params = array(
42 'name' => 'Test_Payment_Processor',
43 'title' => 'Test Payment Processor',
44 'billing_mode' => 1,
45 );
46 $paymentProcessor = CRM_Financial_BAO_PaymentProcessorType::create($params);
47 $result = $this->assertDBNotNull(
48 'CRM_Financial_DAO_PaymentProcessorType',
49 $paymentProcessor->name,
50 'title',
51 'name',
52 'Database check on added payment processor type record.'
53 );
54 $this->assertEquals($result, 'Test Payment Processor', 'Verify Payment Processor Type');
55 }
56
57 /**
58 * Check method retrieve()
59 */
60 public function testRetrieve() {
61 $params = array(
62 'name' => 'Test_Retrieve_Payment_Processor',
63 'title' => 'Test Retrieve Payment Processor',
64 'billing_mode' => 1,
65 );
66 $defaults = array();
67 CRM_Financial_BAO_PaymentProcessorType::create($params);
68 $result = CRM_Financial_BAO_PaymentProcessorType::retrieve($params, $defaults);
69 $this->assertEquals($result->name, 'Test_Retrieve_Payment_Processor', 'Verify Payment Processor Type');
70 }
71
72 /**
73 * Check method setIsActive()
74 */
75 public function testSetIsActive() {
76 $params = array(
77 'name' => 'Test_Set_Payment_Processor',
78 'title' => 'Test Set Payment Processor',
79 'billing_mode' => 1,
80 'is_active' => 1,
81 );
82
83 $paymentProcessor = CRM_Financial_BAO_PaymentProcessorType::create($params);
84 $result = CRM_Financial_BAO_PaymentProcessorType::setIsActive($paymentProcessor->id, 0);
85 $this->assertEquals($result, TRUE, 'Verify financial type record updation for is_active.');
86
87 $isActive = $this->assertDBNotNull(
88 'CRM_Financial_DAO_PaymentProcessorType',
89 $paymentProcessor->id,
90 'is_active',
91 'id',
92 'Database check on updated for payment processor type is_active.'
93 );
94 $this->assertEquals($isActive, 0, 'Verify payment processor types is_active.');
95 }
96
97 /**
98 * Check method getDefault()
99 */
100 public function testGetDefault() {
101 $params = array('is_default' => 1);
102 $defaults = array();
103 $result = CRM_Financial_BAO_PaymentProcessorType::retrieve($params, $defaults);
104
105 $default = CRM_Financial_BAO_PaymentProcessorType::getDefault();
106 $this->assertEquals($result->name, $default->name, 'Verify default payment processor.');
107 }
108
109 /**
110 * Check method del()
111 */
112 public function testDel() {
113 $params = array(
114 'name' => 'Test_Del_Payment_Processor',
115 'title' => 'Test Del Payment Processor',
116 'billing_mode' => 1,
117 'is_active' => 1,
118 );
119
120 $defaults = array();
121 $paymentProcessor = CRM_Financial_BAO_PaymentProcessorType::create($params);
122 CRM_Financial_BAO_PaymentProcessorType::del($paymentProcessor->id);
123
124 $params = array('id' => $paymentProcessor->id);
125 $result = CRM_Financial_BAO_PaymentProcessorType::retrieve($params, $defaults);
126 $this->assertEquals(empty($result), TRUE, 'Verify financial types record deletion.');
127 }
128
129 }