mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-04 08:47:23 +08:00
Merge pull request #150 from woocommerce/PCP-141-disable-vault-setting-if-not-in-
Disable vault setting if vaulting feature is not available
This commit is contained in:
commit
0e1f345f8e
8 changed files with 145 additions and 11 deletions
66
tests/PHPUnit/WcGateway/Settings/SettingsListenerTest.php
Normal file
66
tests/PHPUnit/WcGateway/Settings/SettingsListenerTest.php
Normal file
|
@ -0,0 +1,66 @@
|
|||
<?php
|
||||
|
||||
namespace WooCommerce\PayPalCommerce\WcGateway\Settings;
|
||||
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Authentication\Bearer;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Helper\Cache;
|
||||
use WooCommerce\PayPalCommerce\Onboarding\State;
|
||||
use WooCommerce\PayPalCommerce\TestCase;
|
||||
use Mockery;
|
||||
use WooCommerce\PayPalCommerce\Webhooks\WebhookRegistrar;
|
||||
use function Brain\Monkey\Functions\when;
|
||||
use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
|
||||
|
||||
class SettingsListenerTest extends TestCase
|
||||
{
|
||||
use MockeryPHPUnitIntegration;
|
||||
|
||||
public function testListen()
|
||||
{
|
||||
$settings = Mockery::mock(Settings::class);
|
||||
$setting_fields = [];
|
||||
$webhook_registrar = Mockery::mock(WebhookRegistrar::class);
|
||||
$cache = Mockery::mock(Cache::class);
|
||||
$state = Mockery::mock(State::class);
|
||||
$bearer = Mockery::mock(Bearer::class);
|
||||
|
||||
$testee = new SettingsListener(
|
||||
$settings,
|
||||
$setting_fields,
|
||||
$webhook_registrar,
|
||||
$cache,
|
||||
$state,
|
||||
$bearer
|
||||
);
|
||||
|
||||
$_REQUEST['section'] = 'ppcp-gateway';
|
||||
$_POST['ppcp-nonce'] = 'foo';
|
||||
$_POST['ppcp'] = [
|
||||
'client_id' => 'client_id',
|
||||
];
|
||||
$_GET['ppcp-tab'] = 'just-a-tab';
|
||||
|
||||
when('sanitize_text_field')->justReturn('ppcp-gateway');
|
||||
when('wp_unslash')->justReturn('ppcp-gateway');
|
||||
when('current_user_can')->justReturn(true);
|
||||
when('wp_verify_nonce')->justReturn(true);
|
||||
|
||||
$settings->shouldReceive('has')
|
||||
->with('client_id')
|
||||
->andReturn('client_id');
|
||||
$settings->shouldReceive('get')
|
||||
->with('client_id')
|
||||
->andReturn('client_id');
|
||||
$settings->shouldReceive('has')
|
||||
->with('client_secret')
|
||||
->andReturn('client_secret');
|
||||
$settings->shouldReceive('get')
|
||||
->with('client_secret')
|
||||
->andReturn('client_secret');
|
||||
$settings->shouldReceive('persist');
|
||||
$cache->shouldReceive('has')
|
||||
->andReturn(false);
|
||||
|
||||
$testee->listen();
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue