mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 12:25:15 +08:00
Another test for CheckoutPayPalAddressPreset PCP-28
This commit is contained in:
parent
781760a82c
commit
a90b1addc6
1 changed files with 44 additions and 0 deletions
|
@ -157,6 +157,50 @@ class CheckoutPayPalAddressPresetTest extends TestCase
|
|||
];
|
||||
}
|
||||
|
||||
public function testReadShippingFromOrder(): void
|
||||
{
|
||||
$shipping = \Mockery::mock(Shipping::class);
|
||||
$purchaseUnit = \Mockery::mock(PurchaseUnit::class);
|
||||
$purchaseUnit->shouldReceive('shipping')
|
||||
->once()
|
||||
->andReturn($shipping);
|
||||
$purchaseUnitLast = \Mockery::mock(PurchaseUnit::class);
|
||||
$purchaseUnitLast->shouldReceive('shipping')
|
||||
->never();
|
||||
$order = \Mockery::mock(
|
||||
Order::class,
|
||||
[
|
||||
'id' => 'whatever',
|
||||
]
|
||||
);
|
||||
$order->shouldReceive('purchaseUnits')
|
||||
->once()
|
||||
->andReturn(
|
||||
[
|
||||
\Mockery::mock(PurchaseUnit::class, ['shipping' => null]),
|
||||
$purchaseUnit,
|
||||
$purchaseUnitLast,
|
||||
]
|
||||
);
|
||||
|
||||
$this->buildTestee()[0]->shouldReceive('order')
|
||||
->andReturn($order);
|
||||
|
||||
$testee = $this->buildTestee()[1];
|
||||
$method = (new \ReflectionClass($testee))
|
||||
->getMethod('readShippingFromOrder');
|
||||
$method->setAccessible(true);
|
||||
|
||||
self::assertSame(
|
||||
$shipping,
|
||||
$method->invoke($testee)
|
||||
);
|
||||
self::assertSame(
|
||||
$shipping,
|
||||
$method->invoke($testee)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return MockInterface[]
|
||||
*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue