mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-08 21:52:55 +08:00
Add test to check the payments are added when the PayPal response contains it
This commit is contained in:
parent
f1b8ee128a
commit
60e979a4a2
1 changed files with 51 additions and 0 deletions
|
@ -552,4 +552,55 @@ class PurchaseUnitFactoryTest extends TestCase
|
||||||
$testee->fromPayPalResponse($response);
|
$testee->fromPayPalResponse($response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testFromPayPalResponsePaymentsGetAppended()
|
||||||
|
{
|
||||||
|
$rawItem = (object)['items' => 1];
|
||||||
|
$rawAmount = (object)['amount' => 1];
|
||||||
|
$rawPayee = (object)['payee' => 1];
|
||||||
|
$rawShipping = (object)['shipping' => 1];
|
||||||
|
$rawPayments = (object)['payments' => 1];
|
||||||
|
|
||||||
|
$amountFactory = Mockery::mock(AmountFactory::class);
|
||||||
|
$amount = Mockery::mock(Amount::class);
|
||||||
|
$amountFactory->expects('fromPayPalResponse')->with($rawAmount)->andReturn($amount);
|
||||||
|
$payeeFactory = Mockery::mock(PayeeFactory::class);
|
||||||
|
$payee = Mockery::mock(Payee::class);
|
||||||
|
$payeeFactory->expects('fromPayPalResponse')->with($rawPayee)->andReturn($payee);
|
||||||
|
$payeeRepository = Mockery::mock(PayeeRepository::class);
|
||||||
|
$itemFactory = Mockery::mock(ItemFactory::class);
|
||||||
|
$item = Mockery::mock(Item::class);
|
||||||
|
$itemFactory->expects('fromPayPalResponse')->with($rawItem)->andReturn($item);
|
||||||
|
$shippingFactory = Mockery::mock(ShippingFactory::class);
|
||||||
|
$shipping = Mockery::mock(Shipping::class);
|
||||||
|
$shippingFactory->expects('fromPayPalResponse')->with($rawShipping)->andReturn($shipping);
|
||||||
|
|
||||||
|
$paymentsFactory = Mockery::mock(PaymentsFactory::class);
|
||||||
|
$payments = Mockery::mock(Payments::class);
|
||||||
|
$paymentsFactory->expects('fromPayPalResponse')->with($rawPayments)->andReturn($payments);
|
||||||
|
|
||||||
|
$testee = new PurchaseUnitFactory(
|
||||||
|
$amountFactory,
|
||||||
|
$payeeRepository,
|
||||||
|
$payeeFactory,
|
||||||
|
$itemFactory,
|
||||||
|
$shippingFactory,
|
||||||
|
$paymentsFactory
|
||||||
|
);
|
||||||
|
|
||||||
|
$response = (object)[
|
||||||
|
'reference_id' => 'default',
|
||||||
|
'description' => 'description',
|
||||||
|
'customId' => 'customId',
|
||||||
|
'invoiceId' => 'invoiceId',
|
||||||
|
'softDescriptor' => 'softDescriptor',
|
||||||
|
'amount' => $rawAmount,
|
||||||
|
'items' => [$rawItem],
|
||||||
|
'payee' => $rawPayee,
|
||||||
|
'shipping' => $rawShipping,
|
||||||
|
'payments' => $rawPayments,
|
||||||
|
];
|
||||||
|
|
||||||
|
$unit = $testee->fromPayPalResponse($response);
|
||||||
|
$this->assertEquals($payments, $unit->payments());
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Add table
Add a link
Reference in a new issue