mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 18:16:38 +08:00
Fix the tests
This commit is contained in:
parent
4b6e2ab2d5
commit
4c89caf0d9
1 changed files with 8 additions and 2 deletions
|
@ -46,6 +46,7 @@ class IdentityTokenTest extends TestCase
|
||||||
|
|
||||||
public function testGenerateForCustomerReturnsToken()
|
public function testGenerateForCustomerReturnsToken()
|
||||||
{
|
{
|
||||||
|
$id = 1;
|
||||||
define( 'PPCP_FLAG_SUBSCRIPTION', true );
|
define( 'PPCP_FLAG_SUBSCRIPTION', true );
|
||||||
$token = Mockery::mock(Token::class);
|
$token = Mockery::mock(Token::class);
|
||||||
$token
|
$token
|
||||||
|
@ -60,6 +61,7 @@ class IdentityTokenTest extends TestCase
|
||||||
$this->settings->shouldReceive('has')->andReturn(true);
|
$this->settings->shouldReceive('has')->andReturn(true);
|
||||||
$this->settings->shouldReceive('get')->andReturn(true);
|
$this->settings->shouldReceive('get')->andReturn(true);
|
||||||
$this->customer_repository->shouldReceive('customer_id_for_user')->andReturn('prefix1');
|
$this->customer_repository->shouldReceive('customer_id_for_user')->andReturn('prefix1');
|
||||||
|
expect('update_user_meta')->with($id, 'ppcp_customer_id', 'prefix1');
|
||||||
|
|
||||||
$rawResponse = [
|
$rawResponse = [
|
||||||
'body' => '{"client_token":"abc123", "expires_in":3600}',
|
'body' => '{"client_token":"abc123", "expires_in":3600}',
|
||||||
|
@ -97,6 +99,7 @@ class IdentityTokenTest extends TestCase
|
||||||
|
|
||||||
public function testGenerateForCustomerFailsBecauseWpError()
|
public function testGenerateForCustomerFailsBecauseWpError()
|
||||||
{
|
{
|
||||||
|
$id = 1;
|
||||||
$token = Mockery::mock(Token::class);
|
$token = Mockery::mock(Token::class);
|
||||||
$token
|
$token
|
||||||
->expects('token')->andReturn('bearer');
|
->expects('token')->andReturn('bearer');
|
||||||
|
@ -111,7 +114,8 @@ class IdentityTokenTest extends TestCase
|
||||||
$this->logger->shouldReceive('debug');
|
$this->logger->shouldReceive('debug');
|
||||||
$this->settings->shouldReceive('has')->andReturn(true);
|
$this->settings->shouldReceive('has')->andReturn(true);
|
||||||
$this->settings->shouldReceive('get')->andReturn(true);
|
$this->settings->shouldReceive('get')->andReturn(true);
|
||||||
$this->customer_repository->shouldReceive('customer_id_for_user');
|
$this->customer_repository->shouldReceive('customer_id_for_user')->andReturn('prefix1');
|
||||||
|
expect('update_user_meta')->with($id, 'ppcp_customer_id', 'prefix1');
|
||||||
|
|
||||||
$this->expectException(RuntimeException::class);
|
$this->expectException(RuntimeException::class);
|
||||||
$this->sut->generate_for_user(1);
|
$this->sut->generate_for_user(1);
|
||||||
|
@ -119,6 +123,7 @@ class IdentityTokenTest extends TestCase
|
||||||
|
|
||||||
public function testGenerateForCustomerFailsBecauseResponseCodeIsNot200()
|
public function testGenerateForCustomerFailsBecauseResponseCodeIsNot200()
|
||||||
{
|
{
|
||||||
|
$id = 1;
|
||||||
$token = Mockery::mock(Token::class);
|
$token = Mockery::mock(Token::class);
|
||||||
$token
|
$token
|
||||||
->expects('token')->andReturn('bearer');
|
->expects('token')->andReturn('bearer');
|
||||||
|
@ -137,7 +142,8 @@ class IdentityTokenTest extends TestCase
|
||||||
$this->logger->shouldReceive('debug');
|
$this->logger->shouldReceive('debug');
|
||||||
$this->settings->shouldReceive('has')->andReturn(true);
|
$this->settings->shouldReceive('has')->andReturn(true);
|
||||||
$this->settings->shouldReceive('get')->andReturn(true);
|
$this->settings->shouldReceive('get')->andReturn(true);
|
||||||
$this->customer_repository->shouldReceive('customer_id_for_user');
|
$this->customer_repository->shouldReceive('customer_id_for_user')->andReturn('prefix1');
|
||||||
|
expect('update_user_meta')->with($id, 'ppcp_customer_id', 'prefix1');
|
||||||
|
|
||||||
$this->expectException(PayPalApiException::class);
|
$this->expectException(PayPalApiException::class);
|
||||||
$this->sut->generate_for_user(1);
|
$this->sut->generate_for_user(1);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue