mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-04 08:47:23 +08:00
Fix unit test
This commit is contained in:
parent
1725d2da18
commit
8005ea39c3
1 changed files with 12 additions and 5 deletions
|
@ -2,15 +2,19 @@
|
|||
|
||||
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);
|
||||
|
@ -18,13 +22,15 @@ class SettingsListenerTest extends TestCase
|
|||
$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
|
||||
$state,
|
||||
$bearer
|
||||
);
|
||||
|
||||
$_REQUEST['section'] = 'ppcp-gateway';
|
||||
|
@ -32,6 +38,8 @@ class SettingsListenerTest extends TestCase
|
|||
$_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);
|
||||
|
@ -49,11 +57,10 @@ class SettingsListenerTest extends TestCase
|
|||
$settings->shouldReceive('get')
|
||||
->with('client_secret')
|
||||
->andReturn('client_secret');
|
||||
$settings->shouldReceive('persist');
|
||||
$cache->shouldReceive('has')
|
||||
->andReturn(false);
|
||||
|
||||
// run
|
||||
$testee->listen();
|
||||
|
||||
// assert
|
||||
$this->assertTrue(true);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue