mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 18:16:38 +08:00
Fix phpunit tests
This commit is contained in:
parent
6609759c9d
commit
7e575eef5d
1 changed files with 11 additions and 1 deletions
|
@ -11,6 +11,7 @@ use WooCommerce\PayPalCommerce\ApiClient\Exception\PayPalApiException;
|
||||||
use WooCommerce\PayPalCommerce\ApiClient\Exception\RuntimeException;
|
use WooCommerce\PayPalCommerce\ApiClient\Exception\RuntimeException;
|
||||||
use WooCommerce\PayPalCommerce\ApiClient\TestCase;
|
use WooCommerce\PayPalCommerce\ApiClient\TestCase;
|
||||||
use Mockery;
|
use Mockery;
|
||||||
|
use WooCommerce\PayPalCommerce\WcGateway\Settings\Settings;
|
||||||
use function Brain\Monkey\Functions\expect;
|
use function Brain\Monkey\Functions\expect;
|
||||||
use function Brain\Monkey\Functions\when;
|
use function Brain\Monkey\Functions\when;
|
||||||
|
|
||||||
|
@ -20,6 +21,7 @@ class IdentityTokenTest extends TestCase
|
||||||
private $bearer;
|
private $bearer;
|
||||||
private $logger;
|
private $logger;
|
||||||
private $prefix;
|
private $prefix;
|
||||||
|
private $settings;
|
||||||
private $sut;
|
private $sut;
|
||||||
|
|
||||||
public function setUp(): void
|
public function setUp(): void
|
||||||
|
@ -30,7 +32,9 @@ class IdentityTokenTest extends TestCase
|
||||||
$this->bearer = Mockery::mock(Bearer::class);
|
$this->bearer = Mockery::mock(Bearer::class);
|
||||||
$this->logger = Mockery::mock(LoggerInterface::class);
|
$this->logger = Mockery::mock(LoggerInterface::class);
|
||||||
$this->prefix = 'prefix';
|
$this->prefix = 'prefix';
|
||||||
$this->sut = new IdentityToken($this->host, $this->bearer, $this->logger, $this->prefix);
|
$this->settings = Mockery::mock(Settings::class);
|
||||||
|
|
||||||
|
$this->sut = new IdentityToken($this->host, $this->bearer, $this->logger, $this->prefix, $this->settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGenerateForCustomerReturnsToken()
|
public function testGenerateForCustomerReturnsToken()
|
||||||
|
@ -46,6 +50,8 @@ class IdentityTokenTest extends TestCase
|
||||||
$headers = Mockery::mock(Requests_Utility_CaseInsensitiveDictionary::class);
|
$headers = Mockery::mock(Requests_Utility_CaseInsensitiveDictionary::class);
|
||||||
$headers->shouldReceive('getAll');
|
$headers->shouldReceive('getAll');
|
||||||
$this->logger->shouldReceive('debug');
|
$this->logger->shouldReceive('debug');
|
||||||
|
$this->settings->shouldReceive('has')->andReturn(true);
|
||||||
|
$this->settings->shouldReceive('get')->andReturn(true);
|
||||||
|
|
||||||
$rawResponse = [
|
$rawResponse = [
|
||||||
'body' => '{"client_token":"abc123", "expires_in":3600}',
|
'body' => '{"client_token":"abc123", "expires_in":3600}',
|
||||||
|
@ -96,6 +102,8 @@ class IdentityTokenTest extends TestCase
|
||||||
when('wc_print_r')->returnArg();
|
when('wc_print_r')->returnArg();
|
||||||
$this->logger->shouldReceive('log');
|
$this->logger->shouldReceive('log');
|
||||||
$this->logger->shouldReceive('debug');
|
$this->logger->shouldReceive('debug');
|
||||||
|
$this->settings->shouldReceive('has')->andReturn(true);
|
||||||
|
$this->settings->shouldReceive('get')->andReturn(true);
|
||||||
|
|
||||||
$this->expectException(RuntimeException::class);
|
$this->expectException(RuntimeException::class);
|
||||||
$this->sut->generate_for_customer(1);
|
$this->sut->generate_for_customer(1);
|
||||||
|
@ -120,6 +128,8 @@ class IdentityTokenTest extends TestCase
|
||||||
when('wc_print_r')->returnArg();
|
when('wc_print_r')->returnArg();
|
||||||
$this->logger->shouldReceive('log');
|
$this->logger->shouldReceive('log');
|
||||||
$this->logger->shouldReceive('debug');
|
$this->logger->shouldReceive('debug');
|
||||||
|
$this->settings->shouldReceive('has')->andReturn(true);
|
||||||
|
$this->settings->shouldReceive('get')->andReturn(true);
|
||||||
|
|
||||||
$this->expectException(PayPalApiException::class);
|
$this->expectException(PayPalApiException::class);
|
||||||
$this->sut->generate_for_customer(1);
|
$this->sut->generate_for_customer(1);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue