mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-05 08:59:14 +08:00
Add ppcp_create_paypal_order_for_wc_order
This commit is contained in:
parent
a61e9303e9
commit
b2ba72c06c
2 changed files with 66 additions and 0 deletions
52
tests/PHPUnit/Api/CreateOrderForWcOrderTest.php
Normal file
52
tests/PHPUnit/Api/CreateOrderForWcOrderTest.php
Normal file
|
@ -0,0 +1,52 @@
|
|||
<?php
|
||||
|
||||
namespace WooCommerce\PayPalCommerce\Api;
|
||||
|
||||
use Mockery;
|
||||
use RuntimeException;
|
||||
use WC_Order;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Entity\Order;
|
||||
use WooCommerce\PayPalCommerce\ModularTestCase;
|
||||
use WooCommerce\PayPalCommerce\WcGateway\Processor\OrderProcessor;
|
||||
|
||||
class CreateOrderForWcOrderTest extends ModularTestCase
|
||||
{
|
||||
private $orderProcesor;
|
||||
|
||||
public function setUp(): void {
|
||||
parent::setUp();
|
||||
|
||||
$this->orderProcesor = Mockery::mock(OrderProcessor::class);
|
||||
|
||||
$this->bootstrapModule([
|
||||
'wcgateway.order-processor' => function () {
|
||||
return $this->orderProcesor;
|
||||
},
|
||||
]);
|
||||
}
|
||||
|
||||
public function testSuccess(): void {
|
||||
$wcOrder = Mockery::mock(WC_Order::class);
|
||||
$ret = Mockery::mock(Order::class);
|
||||
$this->orderProcesor
|
||||
->expects('create_order')
|
||||
->with($wcOrder)
|
||||
->andReturn($ret)
|
||||
->once();
|
||||
|
||||
self::assertEquals($ret, ppcp_create_paypal_order_for_wc_order($wcOrder));
|
||||
}
|
||||
|
||||
public function testFailure(): void {
|
||||
$wcOrder = Mockery::mock(WC_Order::class);
|
||||
$this->orderProcesor
|
||||
->expects('create_order')
|
||||
->with($wcOrder)
|
||||
->andThrow(new RuntimeException())
|
||||
->once();
|
||||
|
||||
$this->expectException(RuntimeException::class);
|
||||
|
||||
ppcp_create_paypal_order_for_wc_order($wcOrder);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue