3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
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 +--------------------------------------------------------------------+
13 * Class CRM_Financial_BAO_PaymentProcessorTypeTest
16 class CRM_Financial_BAO_PaymentProcessorTypeTest
extends CiviUnitTestCase
{
19 * Check method create()
21 public function testCreate() {
23 'name' => 'Test_Payment_Processor',
24 'title' => 'Test Payment Processor',
26 'class_name' => 'Payment_Dummy',
28 $paymentProcessor = CRM_Financial_BAO_PaymentProcessorType
::create($params);
29 $result = $this->assertDBNotNull(
30 'CRM_Financial_DAO_PaymentProcessorType',
31 $paymentProcessor->name
,
34 'Database check on added payment processor type record.'
36 $this->assertEquals($result, 'Test Payment Processor', 'Verify Payment Processor Type');
40 * Check method retrieve()
42 public function testRetrieve() {
44 'name' => 'Test_Retrieve_Payment_Processor',
45 'title' => 'Test Retrieve Payment Processor',
47 'class_name' => 'Payment_Dummy',
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');
56 * Check method setIsActive()
58 public function testSetIsActive() {
60 'name' => 'Test_Set_Payment_Processor',
61 'title' => 'Test Set Payment Processor',
64 'class_name' => 'Payment_Dummy',
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.');
71 $isActive = $this->assertDBNotNull(
72 'CRM_Financial_DAO_PaymentProcessorType',
73 $paymentProcessor->id
,
76 'Database check on updated for payment processor type is_active.'
78 $this->assertEquals($isActive, 0, 'Verify payment processor types is_active.');
82 * Check method getDefault()
84 public function testGetDefault() {
85 $params = ['is_default' => 1];
87 $result = CRM_Financial_BAO_PaymentProcessorType
::retrieve($params, $defaults);
89 $default = CRM_Financial_BAO_PaymentProcessorType
::getDefault();
90 $this->assertEquals($result->name
, $default->name
, 'Verify default payment processor.');
96 public function testDel() {
98 'name' => 'Test_Del_Payment_Processor',
99 'title' => 'Test Del Payment Processor',
102 'class_name' => 'Payment_Dummy',
106 $paymentProcessor = CRM_Financial_BAO_PaymentProcessorType
::create($params);
107 CRM_Financial_BAO_PaymentProcessorType
::del($paymentProcessor->id
);
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.');