Skip to content

Commit c85f8d7

Browse files
Unit test Payment_Gateway\External_Checkout\Google_Pay\Admin::get_settings method
1 parent e4f61ce commit c85f8d7

File tree

1 file changed

+91
-0
lines changed
  • tests/unit/Payment_Gateway/External_Checkout/Google_Pay

1 file changed

+91
-0
lines changed
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
<?php
2+
3+
namespace SkyVerge\WooCommerce\PluginFramework\v5_15_1\Tests\Unit\Payment_Gateway\External_Checkout\Google_Pay;
4+
5+
use Mockery;
6+
use SkyVerge\WooCommerce\PluginFramework\v5_15_3\Payment_Gateway\External_Checkout\Google_Pay\Admin;
7+
use SkyVerge\WooCommerce\PluginFramework\v5_15_3\Tests\TestCase;
8+
use WP_Mock;
9+
10+
/**
11+
* @coversDefaultClass \SkyVerge\WooCommerce\PluginFramework\v5_15_3\Payment_Gateway\External_Checkout\Google_Pay\Admin
12+
*/
13+
class AdminTest extends TestCase
14+
{
15+
/** @var Mockery\MockInterface&Admin */
16+
private $testObject;
17+
18+
public function setUp() : void
19+
{
20+
parent::setUp();
21+
22+
$this->testObject = Mockery::mock(Admin::class)
23+
->shouldAllowMockingProtectedMethods()
24+
->makePartial();
25+
}
26+
27+
/**
28+
* @covers ::get_settings()
29+
*/
30+
public function testCanGetSettings() : void
31+
{
32+
$this->testObject->expects('get_display_location_options')
33+
->twice()
34+
->andReturn($displayLocationOptions = [
35+
'TEST_DISPLAY_LOCATION_OPTION_KEY' => 'TEST_DISPLAY_LOCATION_OPTION_VALUE',
36+
]);
37+
38+
$this->testObject->expects('get_connection_settings')
39+
->once()
40+
->andReturn($connectionSettings = ['TEST_CONNECTION_SETTINGS']);
41+
42+
$expectedSettings = [
43+
[
44+
'title' => 'Google Pay',
45+
'type' => 'title',
46+
],
47+
[
48+
'id' => 'sv_wc_google_pay_enabled',
49+
'title' => 'Enable / Disable',
50+
'desc' => 'Accept Google Pay',
51+
'type' => 'checkbox',
52+
'default' => 'no',
53+
],
54+
[
55+
'id' => 'sv_wc_google_pay_merchant_id',
56+
'title' => 'Merchant ID',
57+
'desc' => 'A Google merchant identifier issued after registration with the <a href="https://pay.google.com/business/console" target="_blank">Google Pay & Wallet Console</a>. 12-18 characters. Required in production environment.',
58+
'type' => 'text',
59+
],
60+
[
61+
'id' => 'sv_wc_google_pay_display_locations',
62+
'title' => 'Allow Google Pay on',
63+
'type' => 'multiselect',
64+
'class' => 'wc-enhanced-select',
65+
'css' => 'width: 350px;',
66+
'options' => $displayLocationOptions,
67+
'default' => array_keys($displayLocationOptions),
68+
],
69+
[
70+
'id' => 'sv_wc_google_pay_button_style',
71+
'title' => 'Button Style',
72+
'type' => 'select',
73+
'options' => [
74+
'black' => 'Black',
75+
'white' => 'White',
76+
],
77+
'default' => 'black',
78+
],
79+
[
80+
'type' => 'sectionend',
81+
],
82+
...$connectionSettings,
83+
];
84+
85+
WP_Mock::onFilter('woocommerce_get_settings_google_pay')
86+
->with($expectedSettings)
87+
->reply($expectedSettings);
88+
89+
$this->assertSame($expectedSettings, $this->testObject->get_settings());
90+
}
91+
}

0 commit comments

Comments
 (0)