add missing comments - tests directory
[civicrm-core.git] / tests / phpunit / CRM / Financial / BAO / PaymentProcessorTypeTest.php
CommitLineData
6a488035
TO
1<?php
2/*
3 +--------------------------------------------------------------------+
06a1bc01 4 | CiviCRM version 4.5 |
6a488035 5 +--------------------------------------------------------------------+
06a1bc01 6 | Copyright CiviCRM LLC (c) 2004-2014 |
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 +--------------------------------------------------------------------+
26*/
27require_once 'CiviTest/CiviUnitTestCase.php';
28require_once 'CRM/Financial/DAO/FinancialAccount.php';
29require_once 'CRM/Financial/BAO/FinancialAccount.php';
30require_once 'CRM/Financial/BAO/FinancialTypeAccount.php';
31
4cbe18b8
EM
32/**
33 * Class CRM_Financial_BAO_PaymentProcessorTypeTest
34 */
6a488035
TO
35class CRM_Financial_BAO_PaymentProcessorTypeTest extends CiviUnitTestCase {
36
4cbe18b8
EM
37 /**
38 * @return array
39 */
6a488035
TO
40 function get_info() {
41 return array(
42 'name' => 'PaymentProcessorType BAOs',
43 'description' => 'Test all Contribute_BAO_Contribution methods.',
44 'group' => 'CiviCRM BAO Tests',
45 );
46 }
47
48 function setUp() {
49 parent::setUp();
50 }
51
52 /**
53 * check method create()
54 */
55 function testCreate() {
56 $params = array(
57 'name' => 'Test_Payment_Processor',
58 'title' => 'Test Payment Processor',
59 'billing_mode' => 1,
60 );
61 $paymentProcessor = CRM_Financial_BAO_PaymentProcessorType::create($params);
62 $result = $this->assertDBNotNull(
63 'CRM_Financial_DAO_PaymentProcessorType',
64 $paymentProcessor->name,
65 'title',
66 'name',
67 'Database check on added payment processor type record.'
68 );
69 $this->assertEquals( $result, 'Test Payment Processor', 'Verify Payment Processor Type');
70 }
71
72 /**
73 * check method retrieve()
74 */
75 function testRetrieve() {
76 $params = array(
77 'name' => 'Test_Retrieve_Payment_Processor',
78 'title' => 'Test Retrieve Payment Processor',
79 'billing_mode' => 1,
80 );
81 $defaults = array();
82 CRM_Financial_BAO_PaymentProcessorType::create($params);
83 $result = CRM_Financial_BAO_PaymentProcessorType::retrieve($params, $defaults);
84 $this->assertEquals( $result->name, 'Test_Retrieve_Payment_Processor', 'Verify Payment Processor Type');
85 }
86
87 /**
88 * check method setIsActive()
89 */
90 function testSetIsActive() {
91 $params = array(
92 'name' => 'Test_Set_Payment_Processor',
93 'title' => 'Test Set Payment Processor',
94 'billing_mode' => 1,
95 'is_active' => 1,
96 );
97
98 $paymentProcessor = CRM_Financial_BAO_PaymentProcessorType::create($params);
99 $result = CRM_Financial_BAO_PaymentProcessorType::setIsActive($paymentProcessor->id, 0);
100 $this->assertEquals($result, TRUE, 'Verify financial type record updation for is_active.');
101
102 $isActive = $this->assertDBNotNull(
103 'CRM_Financial_DAO_PaymentProcessorType',
104 $paymentProcessor->id,
105 'is_active',
106 'id',
107 'Database check on updated for payment processor type is_active.'
108 );
109 $this->assertEquals($isActive, 0, 'Verify payment processor types is_active.');
110 }
111
112 /**
113 * check method getDefault()
114 */
115 function testGetDefault() {
116 $params = array('is_default' => 1);
117 $defaults = array();
118 $result = CRM_Financial_BAO_PaymentProcessorType::retrieve($params, $defaults);
119
120 $default = CRM_Financial_BAO_PaymentProcessorType::getDefault();
121 $this->assertEquals($result->name, $default->name, 'Verify default payment processor.');
122 }
123
124 /**
125 * check method del()
126 */
127 function testDel() {
128 $params = array(
129 'name' => 'Test_Del_Payment_Processor',
130 'title' => 'Test Del Payment Processor',
131 'billing_mode' => 1,
132 'is_active' => 1,
133 );
134
135 $defaults = array();
136 $paymentProcessor = CRM_Financial_BAO_PaymentProcessorType::create($params);
137 CRM_Financial_BAO_PaymentProcessorType::del($paymentProcessor->id);
138
139 $params = array('id' => $paymentProcessor->id);
140 $result = CRM_Financial_BAO_PaymentProcessorType::retrieve($params, $defaults);
141 $this->assertEquals(empty($result), TRUE, 'Verify financial types record deletion.');
142 }
232624b1 143}