-
Notifications
You must be signed in to change notification settings - Fork 210
/
Copy pathtest-class-wc-stripe-upe-payment-method-cc.php
63 lines (60 loc) · 1.59 KB
/
test-class-wc-stripe-upe-payment-method-cc.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<?php
/**
* These tests make assertions against class WC_Stripe_UPE_Payment_Method_CC.
*/
class WC_Stripe_UPE_Payment_Method_CC_Test extends WP_UnitTestCase {
/**
* Tests for `get_title`.
*
* @param array $settings Settings.
* @param array|bool $payment_details Payment details.
* @param string $expected Expected title.
* @return void
* @dataProvider provide_test_get_title
*/
public function test_get_title( $settings, $payment_details, $expected ) {
if ( is_array( $payment_details ) ) {
$payment_details = json_decode( wp_json_encode( $payment_details ) );
}
if ( ! empty( $settings['key'] ) ) {
update_option( $settings['key'], $settings['value'] );
}
$payment_method = new WC_Stripe_UPE_Payment_Method_CC();
$this->assertEquals( $expected, $payment_method->get_title( $payment_details ) );
}
/**
* Data provider for `test_get_title`.
*
* @return array
*/
public function provide_test_get_title() {
return [
'Google Pay' => [
'settings' => [],
'payment details' => [
'card' => [
'wallet' => [
'type' => 'google_pay',
],
],
],
'expected' => 'Google Pay (Stripe)',
],
'default, from settings' => [
'settings' => [
'key' => 'woocommerce_stripe_card_settings',
'value' => [
'title' => 'Card Custom Title',
],
],
'payment details' => false,
'expected' => 'Card Custom Title',
],
'default, hardcoded' => [
'settings' => [],
'payment details' => false,
'expected' => 'Credit / Debit Card',
],
];
}
}