🧪 Update OrderFactoryTest to support consolidated factory method

This commit is contained in:
Daniel Dudzic 2025-07-03 10:16:58 +02:00
parent 59503b29b3
commit c54f82ea94
No known key found for this signature in database
GPG key ID: 31B40D33E3465483

View file

@ -28,6 +28,7 @@ class OrderFactoryTest extends TestCase
$order->expects('create_time')->andReturn($createTime);
$order->expects('update_time')->andReturn($updateTime);
$order->expects('payment_source')->andReturnNull();
$order->expects('links')->andReturnNull();
$wcOrder = Mockery::mock(\WC_Order::class);
$purchaseUnitFactory = Mockery::mock(PurchaseUnitFactory::class);
$purchaseUnit = Mockery::mock(PurchaseUnit::class);
@ -89,6 +90,11 @@ class OrderFactoryTest extends TestCase
} else {
$this->assertEquals($orderData->update_time, $order->update_time()->format(\DateTime::ISO8601));
}
if ( isset($orderData->links) ) {
$this->assertEquals($orderData->links, $order->links());
} else {
$this->assertNull($order->links());
}
}
public function dataForTestFromPayPalResponseTest() : array
@ -135,6 +141,20 @@ class OrderFactoryTest extends TestCase
'update_time' => '2005-09-15T15:52:01+0000',
],
],
'with_links' => [
(object) [
'id' => 'id',
'purchase_units' => [new \stdClass(), new \stdClass()],
'status' => OrderStatus::PAYER_ACTION_REQUIRED,
'intent' => 'CAPTURE',
'create_time' => '2005-08-15T15:52:01+0000',
'update_time' => '2005-09-15T15:52:01+0000',
'payer' => new \stdClass(),
'links' => [
(object) ['rel' => 'payer-action', 'href' => 'https://example.com/3ds']
],
],
],
];
}