fix tests

This commit is contained in:
Kirill Braslavsky 2021-04-01 13:48:10 +03:00
parent 1eb9643ff3
commit 9a29bf07ca
2 changed files with 17 additions and 6 deletions

View file

@ -49,7 +49,9 @@ class PaymentTokenEndpointTest extends TestCase
$id = 1;
$token = Mockery::mock(Token::class);
$rawResponse = ['body' => '{"payment_tokens":[{"id": "123abc"}]}'];
$paymentToken = new PaymentToken('foo', 'PAYMENT_METHOD_TOKEN');
$paymentToken = Mockery::mock(PaymentToken::class);
$paymentToken->shouldReceive('id')
->andReturn('foo');
$this->bearer->shouldReceive('bearer')
->andReturn($token);
@ -131,7 +133,9 @@ class PaymentTokenEndpointTest extends TestCase
public function testDeleteToken()
{
$paymentToken = new PaymentToken('foo', 'PAYMENT_METHOD_TOKEN');
$paymentToken = $paymentToken = Mockery::mock(PaymentToken::class);
$paymentToken->shouldReceive('id')
->andReturn('foo');
$token = Mockery::mock(Token::class);
$this->bearer->shouldReceive('bearer')
->andReturn($token);
@ -147,7 +151,9 @@ class PaymentTokenEndpointTest extends TestCase
public function testDeleteTokenFails()
{
$paymentToken = new PaymentToken('foo', 'PAYMENT_METHOD_TOKEN');
$paymentToken = Mockery::mock(PaymentToken::class);
$paymentToken->shouldReceive('id')
->andReturn('foo');
$token = Mockery::mock(Token::class);
$this->bearer->shouldReceive('bearer')
->andReturn($token);

View file

@ -33,7 +33,9 @@ class PaymentTokenRepositoryTest extends TestCase
{
$id = 1;
$token = ['id' => 'foo'];
$paymentToken = new PaymentToken('foo', 'PAYMENT_METHOD_TOKEN');
$paymentToken = Mockery::mock(PaymentToken::class);
$paymentToken->shouldReceive('id')
->andReturn('foo');
expect('get_user_meta')->with($id, $this->sut::USER_META, true)
->andReturn($token);
@ -48,7 +50,8 @@ class PaymentTokenRepositoryTest extends TestCase
public function testFetchForUserId()
{
$id = 1;
$paymentToken = new PaymentToken('foo', 'PAYMENT_METHOD_TOKEN');
$source = new \stdClass();
$paymentToken = new PaymentToken('foo', 'PAYMENT_METHOD_TOKEN', $source);
when('get_user_meta')->justReturn([]);
$this->endpoint->shouldReceive('for_user')
@ -77,7 +80,9 @@ class PaymentTokenRepositoryTest extends TestCase
public function testDeleteToken()
{
$id = 1;
$paymentToken = new PaymentToken('foo', 'PAYMENT_METHOD_TOKEN');
$paymentToken = Mockery::mock(PaymentToken::class);
$paymentToken->shouldReceive('id')
->andReturn('foo');
expect('delete_user_meta')->with($id, $this->sut::USER_META);
$this->endpoint->shouldReceive('delete_token')