Commit | Line | Data |
---|---|---|
c294dbbc SL |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
4 | | CiviCRM version 4.7 | | |
5 | +--------------------------------------------------------------------+ | |
6 | | Copyright CiviCRM LLC (c) 2004-2016 | | |
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 | * @group headless | |
31 | */ | |
8d79abbe | 32 | class CRM_Financial_BAO_PaymentProcessorTest extends CiviUnitTestCase { |
c294dbbc SL |
33 | public function setUp() { |
34 | parent::setUp(); | |
35 | } | |
36 | ||
37 | /** | |
38 | * Check method create() | |
39 | */ | |
40 | public function testGetCreditCards() { | |
41 | $params = array( | |
42 | 'name' => 'API_Test_PP_Type', | |
43 | 'title' => 'API Test Payment Processor Type', | |
44 | 'class_name' => 'CRM_Core_Payment_APITest', | |
45 | 'billing_mode' => 'form', | |
46 | 'payment_processor_type_id' => 1, | |
47 | 'is_recur' => 0, | |
48 | 'domain_id' => 1, | |
49 | 'accepted_credit_cards' => json_encode(array( | |
50 | 'Visa' => 'Visa', | |
51 | 'Mastercard' => 'Mastercard', | |
52 | 'Amex' => 'Amex', | |
53 | )), | |
54 | ); | |
55 | $paymentProcessor = CRM_Financial_BAO_PaymentProcessor::create($params); | |
56 | $expectedCards = array( | |
57 | 'Visa' => 'Visa', | |
58 | 'Mastercard' => 'Mastercard', | |
59 | 'Amex' => 'Amex', | |
60 | ); | |
61 | $cards = CRM_Financial_BAO_PaymentProcessor::getCreditCards($paymentProcessor->id); | |
62 | $this->assertEquals($cards, $expectedCards, 'Verify correct credit card types are returned'); | |
63 | } | |
64 | ||
65 | public function testCreditCardCSSName() { | |
66 | $params = array( | |
67 | 'name' => 'API_Test_PP_Type', | |
68 | 'title' => 'API Test Payment Processor Type', | |
69 | 'class_name' => 'CRM_Core_Payment_APITest', | |
70 | 'billing_mode' => 'form', | |
71 | 'payment_processor_type_id' => 1, | |
72 | 'is_recur' => 0, | |
73 | 'domain_id' => 1, | |
74 | 'accepted_credit_cards' => json_encode(array( | |
75 | 'Visa' => 'Visa', | |
76 | 'Mastercard' => 'Mastercard', | |
77 | 'Amex' => 'Amex', | |
78 | )), | |
79 | ); | |
80 | $paymentProcessor = CRM_Financial_BAO_PaymentProcessor::create($params); | |
81 | $cards = CRM_Financial_BAO_PaymentProcessor::getCreditCards($paymentProcessor->id); | |
82 | $CSSCards = CRM_Core_Payment_Form::getCreditCardCSSNames($cards); | |
83 | $expectedCSSCards = array( | |
84 | 'visa' => 'Visa', | |
85 | 'mastercard' => 'Mastercard', | |
86 | 'amex' => 'Amex', | |
87 | ); | |
88 | $this->assertEquals($CSSCards, $expectedCSSCards, 'Verify correct credit card types are returned'); | |
89 | $CSSCards2 = CRM_Core_Payment_Form::getCreditCardCSSNames(array()); | |
90 | $allCards = array( | |
91 | 'visa' => 'Visa', | |
92 | 'mastercard' => 'MasterCard', | |
93 | 'amex' => 'Amex', | |
94 | 'discover' => 'Discover', | |
95 | ); | |
96 | $this->assertEquals($CSSCards2, $allCards, 'Verify correct credit card types are returned'); | |
97 | } | |
98 | ||
99 | } |