fix tests

This commit is contained in:
David Remer 2020-09-01 09:47:36 +03:00
parent 86de597fb7
commit 81637ebe6d
31 changed files with 475 additions and 449 deletions

View file

@ -147,7 +147,7 @@ class Order {
*
* @return \DateTime|null
*/
public function udpate_time(): ?\DateTime {
public function update_time(): ?\DateTime {
return $this->update_time;
}
@ -230,8 +230,8 @@ class Order {
if ( $this->payer() ) {
$order['payer'] = $this->payer()->to_array();
}
if ( $this->udpate_time() ) {
$order['update_time'] = $this->udpate_time()->format( \DateTimeInterface::ISO8601 );
if ( $this->update_time() ) {
$order['update_time'] = $this->update_time()->format( \DateTimeInterface::ISO8601 );
}
if ( $this->application_context() ) {
$order['application_context'] = $this->application_context()->to_array();

View file

@ -99,7 +99,7 @@ class OrderFactory {
$order->payer(),
$order->intent(),
$order->create_time(),
$order->udpate_time()
$order->update_time()
);
}

View file

@ -14,8 +14,9 @@ use function Brain\Monkey\Functions\expect;
class PayPalBearerTest extends TestCase
{
public function testDefault()
public function testDefault()
{
expect('wp_json_encode')->andReturnUsing('json_encode');
$json = '{"access_token":"abc","expires_in":100, "created":' . time() . '}';
$cache = Mockery::mock(CacheInterface::class);
$cache
@ -59,11 +60,12 @@ class PayPalBearerTest extends TestCase
$token = $bearer->bearer();
$this->assertEquals("abc", $token->token());
$this->assertTrue($token->isValid());
$this->assertTrue($token->is_valid());
}
public function testNoTokenCached()
{
expect('wp_json_encode')->andReturnUsing('json_encode');
$json = '{"access_token":"abc","expires_in":100, "created":' . time() . '}';
$cache = Mockery::mock(CacheInterface::class);
$cache
@ -107,7 +109,7 @@ class PayPalBearerTest extends TestCase
$token = $bearer->bearer();
$this->assertEquals("abc", $token->token());
$this->assertTrue($token->isValid());
$this->assertTrue($token->is_valid());
}
public function testCachedTokenIsStillValid()
@ -127,7 +129,7 @@ class PayPalBearerTest extends TestCase
$token = $bearer->bearer();
$this->assertEquals("abc", $token->token());
$this->assertTrue($token->isValid());
$this->assertTrue($token->is_valid());
}
public function testExceptionThrownOnError()

View file

@ -31,6 +31,7 @@ class OrderEndpointTest extends TestCase
public function testOrderDefault()
{
expect('wp_json_encode')->andReturnUsing('json_encode');
$orderId = 'id';
$host = 'https://example.com/';
$token = Mockery::mock(Token::class);
@ -42,7 +43,7 @@ class OrderEndpointTest extends TestCase
$orderFactory = Mockery::mock(OrderFactory::class);
$order = Mockery::mock(Order::class);
$orderFactory
->expects('fromPayPalResponse')
->expects('from_paypal_response')
->andReturnUsing(function (\stdClass $object) use ($order) : ?Order {
return ($object->is_correct) ? $order : null;
});
@ -53,7 +54,7 @@ class OrderEndpointTest extends TestCase
$applicationContextRepository = Mockery::mock(ApplicationContextRepository::class);
$paypalRequestIdRepository = Mockery::mock(PayPalRequestIdRepository::class);
$paypalRequestIdRepository
->expects('getForOrderId')->with($orderId)->andReturn('uniqueRequestId');
->expects('get_for_order_id')->with($orderId)->andReturn('uniqueRequestId');
$testee = new OrderEndpoint(
$host,
$bearer,
@ -88,6 +89,7 @@ class OrderEndpointTest extends TestCase
public function testOrderResponseIsWpError()
{
expect('wp_json_encode')->andReturnUsing('json_encode');
$host = 'https://example.com/';
$orderId = 'id';
$token = Mockery::mock(Token::class);
@ -104,7 +106,7 @@ class OrderEndpointTest extends TestCase
$applicationContextRepository = Mockery::mock(ApplicationContextRepository::class);
$paypalRequestIdRepository = Mockery::mock(PayPalRequestIdRepository::class);
$paypalRequestIdRepository
->expects('getForOrderId')->with($orderId)->andReturn('uniqueRequestId');
->expects('get_for_order_id')->with($orderId)->andReturn('uniqueRequestId');
$testee = new OrderEndpoint(
$host,
$bearer,
@ -126,6 +128,7 @@ class OrderEndpointTest extends TestCase
public function testOrderResponseIsNot200()
{
expect('wp_json_encode')->andReturnUsing('json_encode');
$host = 'https://example.com/';
$orderId = 'id';
$token = Mockery::mock(Token::class);
@ -143,7 +146,7 @@ class OrderEndpointTest extends TestCase
$applicationContextRepository = Mockery::mock(ApplicationContextRepository::class);
$paypalRequestIdRepository = Mockery::mock(PayPalRequestIdRepository::class);
$paypalRequestIdRepository
->expects('getForOrderId')->with($orderId)->andReturn('uniqueRequestId');
->expects('get_for_order_id')->with($orderId)->andReturn('uniqueRequestId');
$testee = new OrderEndpoint(
$host,
@ -166,6 +169,7 @@ class OrderEndpointTest extends TestCase
public function testCaptureDefault()
{
expect('wp_json_encode')->andReturnUsing('json_encode');
$orderId = 'id';
$orderToCaptureStatus = Mockery::mock(OrderStatus::class);
$orderToCaptureStatus->expects('is')->with('COMPLETED')->andReturn(false);
@ -184,7 +188,7 @@ class OrderEndpointTest extends TestCase
->expects('bearer')->andReturn($token);
$orderFactory = Mockery::mock(OrderFactory::class);
$orderFactory
->expects('fromPayPalResponse')
->expects('from_paypal_response')
->andReturnUsing(
function ($json) use ($expectedOrder) {
if ($json->is_correct) {
@ -201,7 +205,7 @@ class OrderEndpointTest extends TestCase
$applicationContextRepository = Mockery::mock(ApplicationContextRepository::class);
$paypalRequestIdRepository = Mockery::mock(PayPalRequestIdRepository::class);
$paypalRequestIdRepository
->expects('getForOrder')->with($orderToCapture)->andReturn('uniqueRequestId');
->expects('get_for_order')->with($orderToCapture)->andReturn('uniqueRequestId');
$testee = new OrderEndpoint(
$host,
$bearer,
@ -243,6 +247,7 @@ class OrderEndpointTest extends TestCase
public function testCaptureAlreadyCompletedOrder()
{
expect('wp_json_encode')->andReturnUsing('json_encode');
$orderToCaptureStatus = Mockery::mock(OrderStatus::class);
$orderToCaptureStatus->expects('is')->with('COMPLETED')->andReturn(true);
$orderToCapture = Mockery::mock(Order::class);
@ -275,6 +280,7 @@ class OrderEndpointTest extends TestCase
public function testCaptureIsWpError()
{
expect('wp_json_encode')->andReturnUsing('json_encode');
$orderId = 'id';
$orderToCaptureStatus = Mockery::mock(OrderStatus::class);
$orderToCaptureStatus->expects('is')->with('COMPLETED')->andReturn(false);
@ -297,7 +303,7 @@ class OrderEndpointTest extends TestCase
$applicationContextRepository = Mockery::mock(ApplicationContextRepository::class);
$paypalRequestIdRepository = Mockery::mock(PayPalRequestIdRepository::class);
$paypalRequestIdRepository
->expects('getForOrder')->with($orderToCapture)->andReturn('uniqueRequestId');
->expects('get_for_order')->with($orderToCapture)->andReturn('uniqueRequestId');
$testee = new OrderEndpoint(
$host,
$bearer,
@ -318,6 +324,7 @@ class OrderEndpointTest extends TestCase
public function testCaptureIsNot201()
{
expect('wp_json_encode')->andReturnUsing('json_encode');
$orderId = 'id';
$orderToCaptureStatus = Mockery::mock(OrderStatus::class);
$orderToCaptureStatus->expects('is')->with('COMPLETED')->andReturn(false);
@ -340,7 +347,7 @@ class OrderEndpointTest extends TestCase
$applicationContextRepository = Mockery::mock(ApplicationContextRepository::class);
$paypalRequestIdRepository = Mockery::mock(PayPalRequestIdRepository::class);
$paypalRequestIdRepository
->expects('getForOrder')->with($orderToCapture)->andReturn('uniqueRequestId');
->expects('get_for_order')->with($orderToCapture)->andReturn('uniqueRequestId');
$testee = new OrderEndpoint(
$host,
$bearer,
@ -362,6 +369,7 @@ class OrderEndpointTest extends TestCase
public function testCaptureIsNot201ButAlreadyCaptured()
{
expect('wp_json_encode')->andReturnUsing('json_encode');
$orderId = 'id';
$orderToCaptureStatus = Mockery::mock(OrderStatus::class);
$orderToCaptureStatus->expects('is')->with('COMPLETED')->andReturn(false);
@ -384,7 +392,7 @@ class OrderEndpointTest extends TestCase
$applicationContextRepository = Mockery::mock(ApplicationContextRepository::class);
$paypalRequestIdRepository = Mockery::mock(PayPalRequestIdRepository::class);
$paypalRequestIdRepository
->expects('getForOrder')->with($orderToCapture)->andReturn('uniqueRequestId');
->expects('get_for_order')->with($orderToCapture)->andReturn('uniqueRequestId');
$testee = Mockery::mock(
OrderEndpoint::class,
[
@ -411,6 +419,7 @@ class OrderEndpointTest extends TestCase
public function testPatchOrderWithDefault()
{
expect('wp_json_encode')->andReturnUsing('json_encode');
$orderId = 'id';
$orderToUpdate = Mockery::mock(Order::class);
$orderToUpdate
@ -434,11 +443,11 @@ class OrderEndpointTest extends TestCase
->expects('patches')
->andReturn($patches);
$patchCollection
->expects('toArray')
->expects('to_array')
->andReturn($patches);
$patchCollectionFactory = Mockery::mock(PatchCollectionFactory::class);
$patchCollectionFactory
->expects('fromOrders')
->expects('from_orders')
->with($orderToUpdate, $orderToCompare)
->andReturn($patchCollection);
$intent = 'CAPTURE';
@ -448,7 +457,7 @@ class OrderEndpointTest extends TestCase
$applicationContextRepository = Mockery::mock(ApplicationContextRepository::class);
$paypalRequestIdRepository = Mockery::mock(PayPalRequestIdRepository::class);
$paypalRequestIdRepository
->expects('getForOrder')->with($orderToUpdate)->andReturn('uniqueRequestId');
->expects('get_for_order')->with($orderToUpdate)->andReturn('uniqueRequestId');
$testee = Mockery::mock(
OrderEndpoint::class,
[
@ -498,12 +507,13 @@ class OrderEndpointTest extends TestCase
);
expect('is_wp_error')->with($rawResponse)->andReturn(false);
expect('wp_remote_retrieve_response_code')->with($rawResponse)->andReturn(204);
$result = $testee->patchOrderWith($orderToUpdate, $orderToCompare);
$result = $testee->patch_order_with($orderToUpdate, $orderToCompare);
$this->assertEquals($expectedOrder, $result);
}
public function testPatchOrderWithIsNot204()
{
expect('wp_json_encode')->andReturnUsing('json_encode');
$orderId = 'id';
$orderToUpdate = Mockery::mock(Order::class);
$orderToUpdate
@ -527,11 +537,11 @@ class OrderEndpointTest extends TestCase
->expects('patches')
->andReturn($patches);
$patchCollection
->expects('toArray')
->expects('to_array')
->andReturn($patches);
$patchCollectionFactory = Mockery::mock(PatchCollectionFactory::class);
$patchCollectionFactory
->expects('fromOrders')
->expects('from_orders')
->with($orderToUpdate, $orderToCompare)
->andReturn($patchCollection);
$intent = 'CAPTURE';
@ -541,7 +551,7 @@ class OrderEndpointTest extends TestCase
$applicationContextRepository = Mockery::mock(ApplicationContextRepository::class);
$paypalRequestIdRepository = Mockery::mock(PayPalRequestIdRepository::class);
$paypalRequestIdRepository
->expects('getForOrder')->with($orderToUpdate)->andReturn('uniqueRequestId');
->expects('get_for_order')->with($orderToUpdate)->andReturn('uniqueRequestId');
$testee = new OrderEndpoint(
$host,
@ -586,11 +596,12 @@ class OrderEndpointTest extends TestCase
expect('is_wp_error')->with($rawResponse)->andReturn(false);
expect('wp_remote_retrieve_response_code')->with($rawResponse)->andReturn(500);
$this->expectException(RuntimeException::class);
$testee->patchOrderWith($orderToUpdate, $orderToCompare);
$testee->patch_order_with($orderToUpdate, $orderToCompare);
}
public function testPatchOrderWithIsWpError()
{
expect('wp_json_encode')->andReturnUsing('json_encode');
$orderId = 'id';
$orderToUpdate = Mockery::mock(Order::class);
$orderToUpdate
@ -614,11 +625,11 @@ class OrderEndpointTest extends TestCase
->expects('patches')
->andReturn($patches);
$patchCollection
->expects('toArray')
->expects('to_array')
->andReturn($patches);
$patchCollectionFactory = Mockery::mock(PatchCollectionFactory::class);
$patchCollectionFactory
->expects('fromOrders')
->expects('from_orders')
->with($orderToUpdate, $orderToCompare)
->andReturn($patchCollection);
$intent = 'CAPTURE';
@ -629,7 +640,7 @@ class OrderEndpointTest extends TestCase
$applicationContextRepository = Mockery::mock(ApplicationContextRepository::class);
$paypalRequestIdRepository = Mockery::mock(PayPalRequestIdRepository::class);
$paypalRequestIdRepository
->expects('getForOrder')->with($orderToUpdate)->andReturn('uniqueRequestId');
->expects('get_for_order')->with($orderToUpdate)->andReturn('uniqueRequestId');
$testee = Mockery::mock(
OrderEndpoint::class,
[
@ -675,11 +686,12 @@ class OrderEndpointTest extends TestCase
);
expect('is_wp_error')->with($rawResponse)->andReturn(true);
$this->expectException(RuntimeException::class);
$testee->patchOrderWith($orderToUpdate, $orderToCompare);
$testee->patch_order_with($orderToUpdate, $orderToCompare);
}
public function testPatchOrderWithNoPatches()
{
expect('wp_json_encode')->andReturnUsing('json_encode');
$orderToUpdate = Mockery::mock(Order::class);
$orderToCompare = Mockery::mock(Order::class);
@ -693,7 +705,7 @@ class OrderEndpointTest extends TestCase
->andReturn($patches);
$patchCollectionFactory = Mockery::mock(PatchCollectionFactory::class);
$patchCollectionFactory
->expects('fromOrders')
->expects('from_orders')
->with($orderToUpdate, $orderToCompare)
->andReturn($patchCollection);
$intent = 'CAPTURE';
@ -713,12 +725,13 @@ class OrderEndpointTest extends TestCase
$paypalRequestIdRepository
);
$result = $testee->patchOrderWith($orderToUpdate, $orderToCompare);
$result = $testee->patch_order_with($orderToUpdate, $orderToCompare);
$this->assertEquals($orderToUpdate, $result);
}
public function testCreateForPurchaseUnitsDefault()
{
expect('wp_json_encode')->andReturnUsing('json_encode');
$rawResponse = ['body' => '{"success":true}'];
$host = 'https://example.com/';
$bearer = Mockery::mock(Bearer::class);
@ -731,7 +744,7 @@ class OrderEndpointTest extends TestCase
$orderFactory = Mockery::mock(OrderFactory::class);
$expectedOrder = Mockery::mock(Order::class);
$orderFactory
->expects('fromPayPalResponse')
->expects('from_paypal_response')
->andReturnUsing(function ($json) use ($expectedOrder, $rawResponse) {
if (! $json->success) {
return Mockery::mock(Order::class);
@ -745,16 +758,16 @@ class OrderEndpointTest extends TestCase
$logger->shouldNotReceive('log');
$applicationContext = Mockery::mock(ApplicationContext::class);
$applicationContext
->expects('toArray')
->expects('to_array')
->andReturn(['applicationContext']);
$applicationContextRepository = Mockery::mock(ApplicationContextRepository::class);
$applicationContextRepository
->expects('currentContext')
->expects('current_context')
->with(Matchers::identicalTo(ApplicationContext::SHIPPING_PREFERENCE_NO_SHIPPING))
->andReturn($applicationContext);
$paypalRequestIdRepository = Mockery::mock(PayPalRequestIdRepository::class);
$paypalRequestIdRepository
->expects('setForOrder')->andReturnUsing(function ($order, $id) use ($expectedOrder) : bool {
->expects('set_for_order')->andReturnUsing(function ($order, $id) use ($expectedOrder) : bool {
if ($order !== $expectedOrder) {
return false;
}
@ -773,9 +786,9 @@ class OrderEndpointTest extends TestCase
$paypalRequestIdRepository
);
$purchaseUnit = Mockery::mock(PurchaseUnit::class, ['containsPhysicalGoodsItems' => false]);
$purchaseUnit = Mockery::mock(PurchaseUnit::class, ['contains_physical_goods' => false]);
$purchaseUnit
->expects('toArray')
->expects('to_array')
->andReturn(['singlePurchaseUnit']);
expect('wp_remote_get')
@ -808,12 +821,13 @@ class OrderEndpointTest extends TestCase
);
expect('is_wp_error')->with($rawResponse)->andReturn(false);
expect('wp_remote_retrieve_response_code')->with($rawResponse)->andReturn(201);
$result = $testee->createForPurchaseUnits([$purchaseUnit]);
$result = $testee->create([$purchaseUnit]);
$this->assertEquals($expectedOrder, $result);
}
public function testCreateForPurchaseUnitsWithPayer()
{
expect('wp_json_encode')->andReturnUsing('json_encode');
$rawResponse = ['body' => '{"success":true}'];
$host = 'https://example.com/';
$token = Mockery::mock(Token::class);
@ -826,7 +840,7 @@ class OrderEndpointTest extends TestCase
$orderFactory = Mockery::mock(OrderFactory::class);
$expectedOrder = Mockery::mock(Order::class);
$orderFactory
->expects('fromPayPalResponse')
->expects('from_paypal_response')
->andReturnUsing(function ($json) use ($expectedOrder, $rawResponse) {
if (! $json->success) {
return Mockery::mock(Order::class);
@ -840,16 +854,16 @@ class OrderEndpointTest extends TestCase
$logger->shouldNotReceive('log');
$applicationContext = Mockery::mock(ApplicationContext::class);
$applicationContext
->expects('toArray')
->expects('to_array')
->andReturn(['applicationContext']);
$applicationContextRepository = Mockery::mock(ApplicationContextRepository::class);
$applicationContextRepository
->expects('currentContext')
->expects('current_context')
->with(Matchers::identicalTo(ApplicationContext::SHIPPING_PREFERENCE_GET_FROM_FILE))
->andReturn($applicationContext);
$paypalRequestIdRepository = Mockery::mock(PayPalRequestIdRepository::class);
$paypalRequestIdRepository
->expects('setForOrder')->andReturnUsing(function ($order, $id) use ($expectedOrder) : bool {
->expects('set_for_order')->andReturnUsing(function ($order, $id) use ($expectedOrder) : bool {
if ($order !== $expectedOrder) {
return false;
}
@ -868,9 +882,9 @@ class OrderEndpointTest extends TestCase
$paypalRequestIdRepository
);
$purchaseUnit = Mockery::mock(PurchaseUnit::class, ['containsPhysicalGoodsItems' => true]);
$purchaseUnit = Mockery::mock(PurchaseUnit::class, ['contains_physical_goods' => true]);
$purchaseUnit
->expects('toArray')
->expects('to_array')
->andReturn(['singlePurchaseUnit']);
expect('wp_remote_get')
@ -890,13 +904,14 @@ class OrderEndpointTest extends TestCase
expect('wp_remote_retrieve_response_code')->with($rawResponse)->andReturn(201);
$payer = Mockery::mock(Payer::class);
$payer->expects('toArray')->andReturn(['payer']);
$result = $testee->createForPurchaseUnits([$purchaseUnit], $payer);
$payer->expects('to_array')->andReturn(['payer']);
$result = $testee->create([$purchaseUnit], $payer);
$this->assertEquals($expectedOrder, $result);
}
public function testCreateForPurchaseUnitsIsWpError()
{
expect('wp_json_encode')->andReturnUsing('json_encode');
$rawResponse = ['body' => '{"success":true}'];
$host = 'https://example.com/';
$token = Mockery::mock(Token::class);
@ -914,11 +929,11 @@ class OrderEndpointTest extends TestCase
$logger->shouldReceive('log');
$applicationContext = Mockery::mock(ApplicationContext::class);
$applicationContext
->expects('toArray')
->expects('to_array')
->andReturn(['applicationContext']);
$applicationContextRepository = Mockery::mock(ApplicationContextRepository::class);
$applicationContextRepository
->expects('currentContext')
->expects('current_context')
->with(Matchers::identicalTo(ApplicationContext::SHIPPING_PREFERENCE_NO_SHIPPING))
->andReturn($applicationContext);
$paypalRequestIdRepository = Mockery::mock(PayPalRequestIdRepository::class);
@ -934,9 +949,9 @@ class OrderEndpointTest extends TestCase
$paypalRequestIdRepository
);
$purchaseUnit = Mockery::mock(PurchaseUnit::class, ['containsPhysicalGoodsItems' => false]);
$purchaseUnit = Mockery::mock(PurchaseUnit::class, ['contains_physical_goods' => false]);
$purchaseUnit
->expects('toArray')
->expects('to_array')
->andReturn(['singlePurchaseUnit']);
expect('wp_remote_get')
@ -969,11 +984,12 @@ class OrderEndpointTest extends TestCase
);
expect('is_wp_error')->with($rawResponse)->andReturn(true);
$this->expectException(RuntimeException::class);
$testee->createForPurchaseUnits([$purchaseUnit]);
$testee->create([$purchaseUnit]);
}
public function testCreateForPurchaseUnitsIsNot201()
{
expect('wp_json_encode')->andReturnUsing('json_encode');
$rawResponse = ['body' => '{"has_error":true}'];
$host = 'https://example.com/';
$token = Mockery::mock(Token::class);
@ -991,11 +1007,11 @@ class OrderEndpointTest extends TestCase
$logger->shouldReceive('log');
$applicationContext = Mockery::mock(ApplicationContext::class);
$applicationContext
->expects('toArray')
->expects('to_array')
->andReturn(['applicationContext']);
$applicationContextRepository = Mockery::mock(ApplicationContextRepository::class);
$applicationContextRepository
->expects('currentContext')
->expects('current_context')
->with(Matchers::identicalTo(ApplicationContext::SHIPPING_PREFERENCE_GET_FROM_FILE))
->andReturn($applicationContext);
$paypalRequestIdRepository = Mockery::mock(PayPalRequestIdRepository::class);
@ -1010,9 +1026,9 @@ class OrderEndpointTest extends TestCase
$paypalRequestIdRepository
);
$purchaseUnit = Mockery::mock(PurchaseUnit::class, ['containsPhysicalGoodsItems' => true]);
$purchaseUnit = Mockery::mock(PurchaseUnit::class, ['contains_physical_goods' => true]);
$purchaseUnit
->expects('toArray')
->expects('to_array')
->andReturn(['singlePurchaseUnit']);
expect('wp_remote_get')
@ -1046,6 +1062,6 @@ class OrderEndpointTest extends TestCase
expect('is_wp_error')->with($rawResponse)->andReturn(false);
expect('wp_remote_retrieve_response_code')->with($rawResponse)->andReturn(500);
$this->expectException(RuntimeException::class);
$testee->createForPurchaseUnits([$purchaseUnit]);
$testee->create([$purchaseUnit]);
}
}

View file

@ -21,20 +21,20 @@ class OrderTest extends TestCase
$createTime = new \DateTime();
$updateTime = new \DateTime();
$unit = Mockery::mock(PurchaseUnit::class);
$unit->expects('toArray')->andReturn([1]);
$unit->expects('to_array')->andReturn([1]);
$status = Mockery::mock(OrderStatus::class);
$status->expects('name')->andReturn('CREATED');
$payer = Mockery::mock(Payer::class);
$payer
->expects('toArray')->andReturn(['payer']);
->expects('to_array')->andReturn(['payer']);
$intent = 'AUTHORIZE';
$applicationContext = Mockery::mock(ApplicationContext::class);
$applicationContext
->expects('toArray')
->expects('to_array')
->andReturn(['applicationContext']);
$paymentSource = Mockery::mock(PaymentSource::class);
$paymentSource
->expects('toArray')
->expects('to_array')
->andReturn(['paymentSource']);
$testee = new Order(
@ -50,9 +50,9 @@ class OrderTest extends TestCase
);
$this->assertEquals($id, $testee->id());
$this->assertEquals($createTime, $testee->createTime());
$this->assertEquals($updateTime, $testee->updateTime());
$this->assertEquals([$unit], $testee->purchaseUnits());
$this->assertEquals($createTime, $testee->create_time());
$this->assertEquals($updateTime, $testee->update_time());
$this->assertEquals([$unit], $testee->purchase_units());
$this->assertEquals($payer, $testee->payer());
$this->assertEquals($intent, $testee->intent());
$this->assertEquals($status, $testee->status());
@ -70,14 +70,14 @@ class OrderTest extends TestCase
'application_context' => ['applicationContext'],
'payment_source' => ['paymentSource']
];
$this->assertEquals($expected, $testee->toArray());
$this->assertEquals($expected, $testee->to_array());
}
public function testOrderNoDatesOrPayer()
{
$id = 'id';
$unit = Mockery::mock(PurchaseUnit::class);
$unit->expects('toArray')->andReturn([1]);
$unit->expects('to_array')->andReturn([1]);
$status = Mockery::mock(OrderStatus::class);
$status->expects('name')->andReturn('CREATED');
@ -87,12 +87,12 @@ class OrderTest extends TestCase
$status
);
$this->assertEquals(null, $testee->createTime());
$this->assertEquals(null, $testee->updateTime());
$this->assertEquals(null, $testee->create_time());
$this->assertEquals(null, $testee->update_time());
$this->assertEquals(null, $testee->payer());
$this->assertEquals('CAPTURE', $testee->intent());
$array = $testee->toArray();
$array = $testee->to_array();
$this->assertFalse(array_key_exists('payer', $array));
$this->assertFalse(array_key_exists('create_time', $array));
$this->assertFalse(array_key_exists('update_time', $array));

View file

@ -21,6 +21,7 @@ class PaymentsEndpointTest extends TestCase
{
public function testAuthorizationDefault()
{
expect('wp_json_encode')->andReturnUsing('json_encode');
$host = 'https://example.com/';
$authorizationId = 'somekindofid';
@ -34,7 +35,7 @@ class PaymentsEndpointTest extends TestCase
$authorization = Mockery::mock(Authorization::class);
$authorizationFactory = Mockery::mock(AuthorizationFactory::class);
$authorizationFactory
->expects('fromPayPalRequest')
->expects('from_paypal_response')
->andReturn($authorization);
$logger = Mockery::mock(LoggerInterface::class);
@ -73,6 +74,7 @@ class PaymentsEndpointTest extends TestCase
public function testAuthorizationWpError()
{
expect('wp_json_encode')->andReturnUsing('json_encode');
$host = 'https://example.com/';
$authorizationId = 'somekindofid';
@ -105,6 +107,7 @@ class PaymentsEndpointTest extends TestCase
public function testAuthorizationIsNot200()
{
expect('wp_json_encode')->andReturnUsing('json_encode');
$host = 'https://example.com/';
$authorizationId = 'somekindofid';
@ -138,6 +141,7 @@ class PaymentsEndpointTest extends TestCase
public function testCaptureDefault()
{
expect('wp_json_encode')->andReturnUsing('json_encode');
$host = 'https://example.com/';
$authorizationId = 'somekindofid';
@ -151,7 +155,7 @@ class PaymentsEndpointTest extends TestCase
$authorization = Mockery::mock(Authorization::class);
$authorizationFactory = Mockery::mock(AuthorizationFactory::class);
$authorizationFactory
->expects('fromPayPalRequest')
->expects('from_paypal_response')
->andReturn($authorization);
@ -194,6 +198,7 @@ class PaymentsEndpointTest extends TestCase
public function testCaptureIsWpError()
{
expect('wp_json_encode')->andReturnUsing('json_encode');
$host = 'https://example.com/';
$authorizationId = 'somekindofid';
@ -226,6 +231,7 @@ class PaymentsEndpointTest extends TestCase
public function testAuthorizationIsNot201()
{
expect('wp_json_encode')->andReturnUsing('json_encode');
$host = 'https://example.com/';
$authorizationId = 'somekindofid';

View file

@ -19,12 +19,12 @@ class AddressTest extends TestCase
'postalCode'
);
$this->assertEquals('countryCode', $testee->countryCode());
$this->assertEquals('addressLine1', $testee->addressLine1());
$this->assertEquals('addressLine2', $testee->addressLine2());
$this->assertEquals('adminArea1', $testee->adminArea1());
$this->assertEquals('adminArea2', $testee->adminArea2());
$this->assertEquals('postalCode', $testee->postalCode());
$this->assertEquals('countryCode', $testee->country_code());
$this->assertEquals('addressLine1', $testee->address_line_1());
$this->assertEquals('addressLine2', $testee->address_line_2());
$this->assertEquals('adminArea1', $testee->admin_area_1());
$this->assertEquals('adminArea2', $testee->admin_area_2());
$this->assertEquals('postalCode', $testee->postal_code());
}
public function testToArray()
@ -47,7 +47,7 @@ class AddressTest extends TestCase
'postal_code' => 'postalCode',
];
$actual = $testee->toArray();
$actual = $testee->to_array();
$this->assertEquals($expected, $actual);
}
}

View file

@ -13,25 +13,25 @@ class AmountBreakdownTest extends TestCase
{
$itemTotal = Mockery::mock(Money::class);
$itemTotal
->expects('toArray')->andReturn(['itemTotal']);
->expects('to_array')->andReturn(['itemTotal']);
$shipping = Mockery::mock(Money::class);
$shipping
->expects('toArray')->andReturn(['shipping']);
->expects('to_array')->andReturn(['shipping']);
$taxTotal = Mockery::mock(Money::class);
$taxTotal
->expects('toArray')->andReturn(['taxTotal']);
->expects('to_array')->andReturn(['taxTotal']);
$handling = Mockery::mock(Money::class);
$handling
->expects('toArray')->andReturn(['handling']);
->expects('to_array')->andReturn(['handling']);
$insurance = Mockery::mock(Money::class);
$insurance
->expects('toArray')->andReturn(['insurance']);
->expects('to_array')->andReturn(['insurance']);
$shippingDiscount = Mockery::mock(Money::class);
$shippingDiscount
->expects('toArray')->andReturn(['shippingDiscount']);
->expects('to_array')->andReturn(['shippingDiscount']);
$discount = Mockery::mock(Money::class);
$discount
->expects('toArray')->andReturn(['discount']);
->expects('to_array')->andReturn(['discount']);
$testee = new AmountBreakdown(
$itemTotal,
$shipping,
@ -42,12 +42,12 @@ class AmountBreakdownTest extends TestCase
$discount
);
$this->assertEquals($itemTotal, $testee->itemTotal());
$this->assertEquals($itemTotal, $testee->item_total());
$this->assertEquals($shipping, $testee->shipping());
$this->assertEquals($taxTotal, $testee->taxTotal());
$this->assertEquals($taxTotal, $testee->tax_total());
$this->assertEquals($handling, $testee->handling());
$this->assertEquals($insurance, $testee->insurance());
$this->assertEquals($shippingDiscount, $testee->shippingDiscount());
$this->assertEquals($shippingDiscount, $testee->shipping_discount());
$this->assertEquals($discount, $testee->discount());
$expected = [
@ -60,7 +60,7 @@ class AmountBreakdownTest extends TestCase
'discount' => ['discount'],
];
$this->assertEquals($expected, $testee->toArray());
$this->assertEquals($expected, $testee->to_array());
}
/**
@ -70,25 +70,25 @@ class AmountBreakdownTest extends TestCase
{
$itemTotal = Mockery::mock(Money::class);
$itemTotal
->shouldReceive('toArray')->zeroOrMoreTimes()->andReturn(['itemTotal']);
->shouldReceive('to_array')->zeroOrMoreTimes()->andReturn(['itemTotal']);
$shipping = Mockery::mock(Money::class);
$shipping
->shouldReceive('toArray')->zeroOrMoreTimes()->andReturn(['shipping']);
->shouldReceive('to_array')->zeroOrMoreTimes()->andReturn(['shipping']);
$taxTotal = Mockery::mock(Money::class);
$taxTotal
->shouldReceive('toArray')->zeroOrMoreTimes()->andReturn(['taxTotal']);
->shouldReceive('to_array')->zeroOrMoreTimes()->andReturn(['taxTotal']);
$handling = Mockery::mock(Money::class);
$handling
->shouldReceive('toArray')->zeroOrMoreTimes()->andReturn(['handling']);
->shouldReceive('to_array')->zeroOrMoreTimes()->andReturn(['handling']);
$insurance = Mockery::mock(Money::class);
$insurance
->shouldReceive('toArray')->zeroOrMoreTimes()->andReturn(['insurance']);
->shouldReceive('to_array')->zeroOrMoreTimes()->andReturn(['insurance']);
$shippingDiscount = Mockery::mock(Money::class);
$shippingDiscount
->shouldReceive('toArray')->zeroOrMoreTimes()->andReturn(['shippingDiscount']);
->shouldReceive('to_array')->zeroOrMoreTimes()->andReturn(['shippingDiscount']);
$discount = Mockery::mock(Money::class);
$discount
->shouldReceive('toArray')->zeroOrMoreTimes()->andReturn(['discount']);
->shouldReceive('to_array')->zeroOrMoreTimes()->andReturn(['discount']);
$items = [
'item_total' => $itemTotal,
@ -102,7 +102,7 @@ class AmountBreakdownTest extends TestCase
$items[$keyMissing] = null;
$testee = new AmountBreakdown(...array_values($items));
$array = $testee->toArray();
$array = $testee->to_array();
$result = ! array_key_exists($keyMissing, $array);
$this->assertTrue($result);
$this->assertNull($testee->{$methodName}(), "$methodName should return null");
@ -111,12 +111,12 @@ class AmountBreakdownTest extends TestCase
public function dataDropArrayKeyIfNoValueGiven() : array
{
return [
['item_total', 'itemTotal'],
['item_total', 'item_total'],
['shipping', 'shipping'],
['tax_total', 'taxTotal'],
['tax_total', 'tax_total'],
['handling', 'handling'],
['insurance', 'insurance'],
['shipping_discount', 'shippingDiscount'],
['shipping_discount', 'shipping_discount'],
['discount', 'discount'],
];
}

View file

@ -12,18 +12,18 @@ class AmountTest extends TestCase
public function test()
{
$money = Mockery::mock(Money::class);
$money->shouldReceive('currencyCode')->andReturn('currencyCode');
$money->shouldReceive('currency_code')->andReturn('currencyCode');
$money->shouldReceive('value')->andReturn(1.10);
$testee = new Amount($money);
$this->assertEquals('currencyCode', $testee->currencyCode());
$this->assertEquals('currencyCode', $testee->currency_code());
$this->assertEquals(1.10, $testee->value());
}
public function testBreakdownIsNull()
{
$money = Mockery::mock(Money::class);
$money->shouldReceive('currencyCode')->andReturn('currencyCode');
$money->shouldReceive('currency_code')->andReturn('currencyCode');
$money->shouldReceive('value')->andReturn(1.10);
$testee = new Amount($money);
@ -33,16 +33,16 @@ class AmountTest extends TestCase
'currency_code' => 'currencyCode',
'value' => 1.10,
];
$this->assertEquals($expectedArray, $testee->toArray());
$this->assertEquals($expectedArray, $testee->to_array());
}
public function testBreakdown()
{
$money = Mockery::mock(Money::class);
$money->shouldReceive('currencyCode')->andReturn('currencyCode');
$money->shouldReceive('currency_code')->andReturn('currencyCode');
$money->shouldReceive('value')->andReturn(1.10);
$breakdown = Mockery::mock(AmountBreakdown::class);
$breakdown->shouldReceive('toArray')->andReturn([1]);
$breakdown->shouldReceive('to_array')->andReturn([1]);
$testee = new Amount($money, $breakdown);
$this->assertEquals($breakdown, $testee->breakdown());
@ -52,6 +52,6 @@ class AmountTest extends TestCase
'value' => 1.10,
'breakdown' => [1],
];
$this->assertEquals($expectedArray, $testee->toArray());
$this->assertEquals($expectedArray, $testee->to_array());
}
}

View file

@ -28,6 +28,6 @@ class AuthorizationTest extends TestCase
'id' => 'foo',
'status' => 'CAPTURED',
];
$this->assertEquals($expected, $testee->toArray());
$this->assertEquals($expected, $testee->to_array());
}
}

View file

@ -24,7 +24,7 @@ class ItemTest extends TestCase
);
$this->assertEquals('name', $testee->name());
$this->assertEquals($unitAmount, $testee->unitAmount());
$this->assertEquals($unitAmount, $testee->unit_amount());
$this->assertEquals(1, $testee->quantity());
$this->assertEquals('description', $testee->description());
$this->assertEquals($tax, $testee->tax());
@ -53,11 +53,11 @@ class ItemTest extends TestCase
{
$unitAmount = Mockery::mock(Money::class);
$unitAmount
->expects('toArray')
->expects('to_array')
->andReturn([1]);
$tax = Mockery::mock(Money::class);
$tax
->expects('toArray')
->expects('to_array')
->andReturn([2]);
$testee = new Item(
'name',
@ -79,6 +79,6 @@ class ItemTest extends TestCase
'tax' => [2],
];
$this->assertEquals($expected, $testee->toArray());
$this->assertEquals($expected, $testee->to_array());
}
}

View file

@ -12,12 +12,12 @@ class MoneyTest extends TestCase
{
$testee = new Money(1.10, 'currencyCode');
$this->assertEquals(1.10, $testee->value());
$this->assertEquals('currencyCode', $testee->currencyCode());
$this->assertEquals('currencyCode', $testee->currency_code());
$expected = [
'currency_code' => 'currencyCode',
'value' => 1.10,
];
$this->assertEquals($expected, $testee->toArray());
$this->assertEquals($expected, $testee->to_array());
}
}

View file

@ -14,19 +14,19 @@ class PayerTest extends TestCase
$birthday = new \DateTime();
$address = Mockery::mock(Address::class);
$address
->expects('toArray')
->expects('to_array')
->andReturn(['address']);
$phone = Mockery::mock(PhoneWithType::class);
$phone
->expects('toArray')
->expects('to_array')
->andReturn(['phone']);
$taxInfo = Mockery::mock(PayerTaxInfo::class);
$taxInfo
->expects('toArray')
->expects('to_array')
->andReturn(['taxInfo']);
$payerName = Mockery::mock(PayerName::class);
$payerName
->expects('toArray')
->expects('to_array')
->andReturn(['payerName']);
$email = 'email@example.com';
$payerId = 'payerId';
@ -41,14 +41,14 @@ class PayerTest extends TestCase
);
$this->assertEquals($payerName, $payer->name());
$this->assertEquals($email, $payer->emailAddress());
$this->assertEquals($payerId, $payer->payerId());
$this->assertEquals($email, $payer->email_address());
$this->assertEquals($payerId, $payer->payer_id());
$this->assertEquals($address, $payer->address());
$this->assertEquals($birthday, $payer->birthDate());
$this->assertEquals($birthday, $payer->birthdate());
$this->assertEquals($phone, $payer->phone());
$this->assertEquals($taxInfo, $payer->taxInfo());
$this->assertEquals($taxInfo, $payer->tax_info());
$array = $payer->toArray();
$array = $payer->to_array();
$this->assertEquals($birthday->format('Y-m-d'), $array['birth_date']);
$this->assertEquals(['payerName'], $array['name']);
$this->assertEquals($email, $array['email_address']);
@ -63,19 +63,19 @@ class PayerTest extends TestCase
$birthday = new \DateTime();
$address = Mockery::mock(Address::class);
$address
->expects('toArray')
->expects('to_array')
->andReturn(['address']);
$phone = Mockery::mock(PhoneWithType::class);
$phone
->expects('toArray')
->expects('to_array')
->andReturn(['phone']);
$taxInfo = Mockery::mock(PayerTaxInfo::class);
$taxInfo
->expects('toArray')
->expects('to_array')
->andReturn(['taxInfo']);
$payerName = Mockery::mock(PayerName::class);
$payerName
->expects('toArray')
->expects('to_array')
->andReturn(['payerName']);
$email = 'email@example.com';
$payerId = '';
@ -89,9 +89,9 @@ class PayerTest extends TestCase
$taxInfo
);
$this->assertEquals($payerId, $payer->payerId());
$this->assertEquals($payerId, $payer->payer_id());
$array = $payer->toArray();
$array = $payer->to_array();
$this->assertArrayNotHasKey('payer_id', $array);
}
@ -100,16 +100,16 @@ class PayerTest extends TestCase
$birthday = new \DateTime();
$address = Mockery::mock(Address::class);
$address
->expects('toArray')
->expects('to_array')
->andReturn(['address']);
$phone = null;
$taxInfo = Mockery::mock(PayerTaxInfo::class);
$taxInfo
->expects('toArray')
->expects('to_array')
->andReturn(['taxInfo']);
$payerName = Mockery::mock(PayerName::class);
$payerName
->expects('toArray')
->expects('to_array')
->andReturn(['payerName']);
$email = 'email@example.com';
$payerId = 'payerId';
@ -125,7 +125,7 @@ class PayerTest extends TestCase
$this->assertEquals($phone, $payer->phone());
$array = $payer->toArray();
$array = $payer->to_array();
$this->assertArrayNotHasKey('phone', $array);
}
@ -134,16 +134,16 @@ class PayerTest extends TestCase
$birthday = new \DateTime();
$address = Mockery::mock(Address::class);
$address
->expects('toArray')
->expects('to_array')
->andReturn(['address']);
$phone = Mockery::mock(PhoneWithType::class);
$phone
->expects('toArray')
->expects('to_array')
->andReturn(['phone']);
$taxInfo = null;
$payerName = Mockery::mock(PayerName::class);
$payerName
->expects('toArray')
->expects('to_array')
->andReturn(['payerName']);
$email = 'email@example.com';
$payerId = 'payerId';
@ -157,9 +157,9 @@ class PayerTest extends TestCase
$taxInfo
);
$this->assertEquals($taxInfo, $payer->taxInfo());
$this->assertEquals($taxInfo, $payer->tax_info());
$array = $payer->toArray();
$array = $payer->to_array();
$this->assertArrayNotHasKey('tax_info', $array);
}
@ -168,19 +168,19 @@ class PayerTest extends TestCase
$birthday = null;
$address = Mockery::mock(Address::class);
$address
->expects('toArray')
->expects('to_array')
->andReturn(['address']);
$phone = Mockery::mock(PhoneWithType::class);
$phone
->expects('toArray')
->expects('to_array')
->andReturn(['phone']);
$taxInfo = Mockery::mock(PayerTaxInfo::class);
$taxInfo
->expects('toArray')
->expects('to_array')
->andReturn(['taxInfo']);
$payerName = Mockery::mock(PayerName::class);
$payerName
->expects('toArray')
->expects('to_array')
->andReturn(['payerName']);
$email = 'email@example.com';
$payerId = 'payerId';
@ -194,9 +194,9 @@ class PayerTest extends TestCase
$taxInfo
);
$this->assertEquals($birthday, $payer->birthDate());
$this->assertEquals($birthday, $payer->birthdate());
$array = $payer->toArray();
$array = $payer->to_array();
$this->assertArrayNotHasKey('birth_date', $array);
}
}

View file

@ -21,7 +21,7 @@ class PaymentsTest extends TestCase
public function testToArray()
{
$authorization = \Mockery::mock(Authorization::class);
$authorization->shouldReceive('toArray')->andReturn(
$authorization->shouldReceive('to_array')->andReturn(
[
'id' => 'foo',
'status' => 'CREATED',
@ -40,7 +40,7 @@ class PaymentsTest extends TestCase
],
],
],
$testee->toArray()
$testee->to_array()
);
}
}

View file

@ -16,14 +16,14 @@ class PurchaseUnitTest extends TestCase
Amount::class,
[
'breakdown' => null,
'toArray' => ['amount'],
'to_array' => ['amount'],
]
);
$item1 = Mockery::mock(
Item::class,
[
'toArray' => ['item1'],
'to_array' => ['item1'],
'category' => Item::DIGITAL_GOODS,
]
);
@ -31,12 +31,12 @@ class PurchaseUnitTest extends TestCase
$item2 = Mockery::mock(
Item::class,
[
'toArray' => ['item2'],
'to_array' => ['item2'],
'category' => Item::PHYSICAL_GOODS,
]
);
$shipping = Mockery::mock(Shipping::class, ['toArray' => ['shipping']]);
$shipping = Mockery::mock(Shipping::class, ['to_array' => ['shipping']]);
$testee = new PurchaseUnit(
$amount,
@ -51,15 +51,15 @@ class PurchaseUnitTest extends TestCase
);
$this->assertEquals($amount, $testee->amount());
$this->assertEquals('referenceId', $testee->referenceId());
$this->assertEquals('referenceId', $testee->reference_id());
$this->assertEquals('description', $testee->description());
$this->assertNull($testee->payee());
$this->assertEquals('customId', $testee->customId());
$this->assertEquals('invoiceId', $testee->invoiceId());
$this->assertEquals('softDescriptor', $testee->softDescriptor());
$this->assertEquals('customId', $testee->custom_id());
$this->assertEquals('invoiceId', $testee->invoice_id());
$this->assertEquals('softDescriptor', $testee->soft_descriptor());
$this->assertEquals($shipping, $testee->shipping());
$this->assertEquals([$item1, $item2], $testee->items());
self::assertTrue($testee->containsPhysicalGoodsItems());
self::assertTrue($testee->contains_physical_goods());
$expected = [
'reference_id' => 'referenceId',
@ -72,7 +72,7 @@ class PurchaseUnitTest extends TestCase
'soft_descriptor' => 'softDescriptor',
];
$this->assertEquals($expected, $testee->toArray());
$this->assertEquals($expected, $testee->to_array());
}
/**
@ -88,7 +88,7 @@ class PurchaseUnitTest extends TestCase
$items
);
$array = $testee->toArray();
$array = $testee->to_array();
$resultItems = $doDitch === ! array_key_exists('items', $array);
$resultBreakdown = $doDitch === ! array_key_exists('breakdown', $array['amount']);
$this->assertTrue($resultItems, $message);
@ -111,11 +111,11 @@ class PurchaseUnitTest extends TestCase
],
'amount' => 26,
'breakdown' => [
'itemTotal' => 20,
'taxTotal' => 6,
'item_total' => 20,
'tax_total' => 6,
'shipping' => null,
'discount' => null,
'shippingDiscount' => null,
'shipping_discount' => null,
'handling' => null,
'insurance' => null,
],
@ -133,11 +133,11 @@ class PurchaseUnitTest extends TestCase
],
'amount' => 23,
'breakdown' => [
'itemTotal' => 20,
'taxTotal' => 6,
'item_total' => 20,
'tax_total' => 6,
'shipping' => null,
'discount' => 3,
'shippingDiscount' => null,
'shipping_discount' => null,
'handling' => null,
'insurance' => null,
],
@ -155,11 +155,11 @@ class PurchaseUnitTest extends TestCase
],
'amount' => 25,
'breakdown' => [
'itemTotal' => 20,
'taxTotal' => 6,
'item_total' => 20,
'tax_total' => 6,
'shipping' => null,
'discount' => 3,
'shippingDiscount' => null,
'shipping_discount' => null,
'handling' => null,
'insurance' => null,
],
@ -177,11 +177,11 @@ class PurchaseUnitTest extends TestCase
],
'amount' => 23,
'breakdown' => [
'itemTotal' => 20,
'taxTotal' => 6,
'item_total' => 20,
'tax_total' => 6,
'shipping' => null,
'discount' => null,
'shippingDiscount' => 3,
'shipping_discount' => 3,
'handling' => null,
'insurance' => null,
],
@ -199,11 +199,11 @@ class PurchaseUnitTest extends TestCase
],
'amount' => 26,
'breakdown' => [
'itemTotal' => 20,
'taxTotal' => 6,
'item_total' => 20,
'tax_total' => 6,
'shipping' => null,
'discount' => null,
'shippingDiscount' => null,
'shipping_discount' => null,
'handling' => 3,
'insurance' => null,
],
@ -221,11 +221,11 @@ class PurchaseUnitTest extends TestCase
],
'amount' => 29,
'breakdown' => [
'itemTotal' => 20,
'taxTotal' => 6,
'item_total' => 20,
'tax_total' => 6,
'shipping' => null,
'discount' => null,
'shippingDiscount' => null,
'shipping_discount' => null,
'handling' => 3,
'insurance' => null,
],
@ -243,11 +243,11 @@ class PurchaseUnitTest extends TestCase
],
'amount' => 26,
'breakdown' => [
'itemTotal' => 20,
'taxTotal' => 6,
'item_total' => 20,
'tax_total' => 6,
'shipping' => null,
'discount' => null,
'shippingDiscount' => null,
'shipping_discount' => null,
'handling' => null,
'insurance' => 3,
],
@ -265,11 +265,11 @@ class PurchaseUnitTest extends TestCase
],
'amount' => 29,
'breakdown' => [
'itemTotal' => 20,
'taxTotal' => 6,
'item_total' => 20,
'tax_total' => 6,
'shipping' => null,
'discount' => null,
'shippingDiscount' => null,
'shipping_discount' => null,
'handling' => null,
'insurance' => 3,
],
@ -287,11 +287,11 @@ class PurchaseUnitTest extends TestCase
],
'amount' => 25,
'breakdown' => [
'itemTotal' => 20,
'taxTotal' => 6,
'item_total' => 20,
'tax_total' => 6,
'shipping' => null,
'discount' => null,
'shippingDiscount' => 3,
'shipping_discount' => 3,
'handling' => null,
'insurance' => null,
],
@ -309,11 +309,11 @@ class PurchaseUnitTest extends TestCase
],
'amount' => 29,
'breakdown' => [
'itemTotal' => 20,
'taxTotal' => 6,
'item_total' => 20,
'tax_total' => 6,
'shipping' => 3,
'discount' => null,
'shippingDiscount' => null,
'shipping_discount' => null,
'handling' => null,
'insurance' => null,
],
@ -331,11 +331,11 @@ class PurchaseUnitTest extends TestCase
],
'amount' => 28,
'breakdown' => [
'itemTotal' => 20,
'taxTotal' => 6,
'item_total' => 20,
'tax_total' => 6,
'shipping' => 3,
'discount' => null,
'shippingDiscount' => null,
'shipping_discount' => null,
'handling' => null,
'insurance' => null,
],
@ -353,11 +353,11 @@ class PurchaseUnitTest extends TestCase
],
'amount' => 26,
'breakdown' => [
'itemTotal' => 11,
'taxTotal' => 6,
'item_total' => 11,
'tax_total' => 6,
'shipping' => null,
'discount' => null,
'shippingDiscount' => null,
'shipping_discount' => null,
'handling' => null,
'insurance' => null,
],
@ -375,11 +375,11 @@ class PurchaseUnitTest extends TestCase
],
'amount' => 26,
'breakdown' => [
'itemTotal' => 20,
'taxTotal' => 5,
'item_total' => 20,
'tax_total' => 5,
'shipping' => null,
'discount' => null,
'shippingDiscount' => null,
'shipping_discount' => null,
'handling' => null,
'insurance' => null,
],
@ -397,11 +397,11 @@ class PurchaseUnitTest extends TestCase
],
'amount' => 260,
'breakdown' => [
'itemTotal' => 20,
'taxTotal' => 6,
'item_total' => 20,
'tax_total' => 6,
'shipping' => null,
'discount' => null,
'shippingDiscount' => null,
'shipping_discount' => null,
'handling' => null,
'insurance' => null,
],
@ -419,11 +419,11 @@ class PurchaseUnitTest extends TestCase
$items[$key] = Mockery::mock(
Item::class,
[
'unitAmount' => $unitAmount,
'unit_amount' => $unitAmount,
'tax' => $tax,
'quantity'=> $item['quantity'],
'category' => $item['category'],
'toArray' => [],
'to_array' => [],
]
);
}
@ -443,7 +443,7 @@ class PurchaseUnitTest extends TestCase
}
}
$amount = Mockery::mock(Amount::class);
$amount->shouldReceive('toArray')->andReturn(['value' => [], 'breakdown' => []]);
$amount->shouldReceive('to_array')->andReturn(['value' => [], 'breakdown' => []]);
$amount->shouldReceive('value')->andReturn($test['amount']);
$amount->shouldReceive('breakdown')->andReturn($breakdown);
@ -462,15 +462,15 @@ class PurchaseUnitTest extends TestCase
{
$amount = Mockery::mock(Amount::class);
$amount->shouldReceive('breakdown')->andReturnNull();
$amount->shouldReceive('toArray')->andReturn(['amount']);
$amount->shouldReceive('to_array')->andReturn(['amount']);
$item1 = Mockery::mock(Item::class);
$item1->shouldReceive('toArray')->andReturn(['item1']);
$item1->shouldReceive('to_array')->andReturn(['item1']);
$item2 = Mockery::mock(Item::class);
$item2->shouldReceive('toArray')->andReturn(['item2']);
$item2->shouldReceive('to_array')->andReturn(['item2']);
$shipping = Mockery::mock(Shipping::class);
$shipping->shouldReceive('toArray')->andReturn(['shipping']);
$shipping->shouldReceive('to_array')->andReturn(['shipping']);
$payee = Mockery::mock(Payee::class);
$payee->shouldReceive('toArray')->andReturn(['payee']);
$payee->shouldReceive('to_array')->andReturn(['payee']);
$testee = new PurchaseUnit(
$amount,
[],
@ -497,6 +497,6 @@ class PurchaseUnitTest extends TestCase
'payee' => ['payee'],
];
$this->assertEquals($expected, $testee->toArray());
$this->assertEquals($expected, $testee->to_array());
}
}

View file

@ -5,6 +5,7 @@ namespace Inpsyde\PayPalCommerce\ApiClient\Entity;
use Inpsyde\PayPalCommerce\ApiClient\Exception\RuntimeException;
use Inpsyde\PayPalCommerce\ApiClient\TestCase;
use function Brain\Monkey\Functions\expect;
class TokenTest extends TestCase
{
@ -17,7 +18,7 @@ class TokenTest extends TestCase
{
$token = new Token($data);
$this->assertEquals($data->token, $token->token());
$this->assertTrue($token->isValid());
$this->assertTrue($token->is_valid());
}
public function dataForTestDefault() : array
@ -48,7 +49,7 @@ class TokenTest extends TestCase
];
$token = new Token($data);
$this->assertFalse($token->isValid());
$this->assertFalse($token->is_valid());
}
public function testFromBearerJson()
@ -58,9 +59,9 @@ class TokenTest extends TestCase
'access_token' => 'abc',
]);
$token = Token::fromJson($data);
$token = Token::from_json($data);
$this->assertEquals('abc', $token->token());
$this->assertTrue($token->isValid());
$this->assertTrue($token->is_valid());
}
public function testFromIdentityJson()
@ -70,13 +71,14 @@ class TokenTest extends TestCase
'client_token' => 'abc',
]);
$token = Token::fromJson($data);
$token = Token::from_json($data);
$this->assertEquals('abc', $token->token());
$this->assertTrue($token->isValid());
$this->assertTrue($token->is_valid());
}
public function testAsJson()
{
expect('wp_json_encode')->andReturnUsing('json_encode');
$data = (object) [
'created' => 100,
'expires_in' => 100,
@ -84,7 +86,7 @@ class TokenTest extends TestCase
];
$token = new Token($data);
$json = json_decode($token->asJson());
$json = json_decode($token->as_json());
$this->assertEquals($data->token, $json->token);
$this->assertEquals($data->created, $json->created);
$this->assertEquals($data->expires_in, $json->expires_in);

View file

@ -33,13 +33,13 @@ class AddressFactoryTest extends TestCase
->expects('get_shipping_postcode')
->andReturn('shipping_postcode');
$result = $testee->fromWcCustomer($customer);
$this->assertEquals('shipping_country', $result->countryCode());
$this->assertEquals('shipping_address_1', $result->addressLine1());
$this->assertEquals('shipping_address_2', $result->addressLine2());
$this->assertEquals('shipping_state', $result->adminArea1());
$this->assertEquals('shipping_city', $result->adminArea2());
$this->assertEquals('shipping_postcode', $result->postalCode());
$result = $testee->from_wc_customer($customer);
$this->assertEquals('shipping_country', $result->country_code());
$this->assertEquals('shipping_address_1', $result->address_line_1());
$this->assertEquals('shipping_address_2', $result->address_line_2());
$this->assertEquals('shipping_state', $result->admin_area_1());
$this->assertEquals('shipping_city', $result->admin_area_2());
$this->assertEquals('shipping_postcode', $result->postal_code());
}
public function testFromWcCustomersBillingAddress()
@ -65,13 +65,13 @@ class AddressFactoryTest extends TestCase
->expects('get_billing_postcode')
->andReturn('billing_postcode');
$result = $testee->fromWcCustomer($customer, 'billing');
$this->assertEquals('billing_country', $result->countryCode());
$this->assertEquals('billing_address_1', $result->addressLine1());
$this->assertEquals('billing_address_2', $result->addressLine2());
$this->assertEquals('billing_state', $result->adminArea1());
$this->assertEquals('billing_city', $result->adminArea2());
$this->assertEquals('billing_postcode', $result->postalCode());
$result = $testee->from_wc_customer($customer, 'billing');
$this->assertEquals('billing_country', $result->country_code());
$this->assertEquals('billing_address_1', $result->address_line_1());
$this->assertEquals('billing_address_2', $result->address_line_2());
$this->assertEquals('billing_state', $result->admin_area_1());
$this->assertEquals('billing_city', $result->admin_area_2());
$this->assertEquals('billing_postcode', $result->postal_code());
}
public function testFromWcOrder()
@ -97,13 +97,13 @@ class AddressFactoryTest extends TestCase
->expects('get_shipping_postcode')
->andReturn('shipping_postcode');
$result = $testee->fromWcOrder($order);
$this->assertEquals('shipping_country', $result->countryCode());
$this->assertEquals('shipping_address_1', $result->addressLine1());
$this->assertEquals('shipping_address_2', $result->addressLine2());
$this->assertEquals('shipping_state', $result->adminArea1());
$this->assertEquals('shipping_city', $result->adminArea2());
$this->assertEquals('shipping_postcode', $result->postalCode());
$result = $testee->from_wc_order($order);
$this->assertEquals('shipping_country', $result->country_code());
$this->assertEquals('shipping_address_1', $result->address_line_1());
$this->assertEquals('shipping_address_2', $result->address_line_2());
$this->assertEquals('shipping_state', $result->admin_area_1());
$this->assertEquals('shipping_city', $result->admin_area_2());
$this->assertEquals('shipping_postcode', $result->postal_code());
}
/**
@ -113,18 +113,18 @@ class AddressFactoryTest extends TestCase
{
$testee = new AddressFactory();
$result = $testee->fromPayPalRequest($data);
$result = $testee->from_paypal_response($data);
$expectedAddressLine1 = (isset($data->address_line_1)) ? $data->address_line_1 : '';
$expectedAddressLine2 = (isset($data->address_line_2)) ? $data->address_line_2 : '';
$expectedAdminArea1 = (isset($data->admin_area_1)) ? $data->admin_area_1 : '';
$expectedAdminArea2 = (isset($data->admin_area_2)) ? $data->admin_area_2 : '';
$expectedPostalCode = (isset($data->postal_code)) ? $data->postal_code : '';
$this->assertEquals($data->country_code, $result->countryCode());
$this->assertEquals($expectedAddressLine1, $result->addressLine1());
$this->assertEquals($expectedAddressLine2, $result->addressLine2());
$this->assertEquals($expectedAdminArea1, $result->adminArea1());
$this->assertEquals($expectedAdminArea2, $result->adminArea2());
$this->assertEquals($expectedPostalCode, $result->postalCode());
$this->assertEquals($data->country_code, $result->country_code());
$this->assertEquals($expectedAddressLine1, $result->address_line_1());
$this->assertEquals($expectedAddressLine2, $result->address_line_2());
$this->assertEquals($expectedAdminArea1, $result->admin_area_1());
$this->assertEquals($expectedAdminArea2, $result->admin_area_2());
$this->assertEquals($expectedPostalCode, $result->postal_code());
}
public function testFromPayPalRequestThrowsError()
@ -139,7 +139,7 @@ class AddressFactoryTest extends TestCase
'postal_code' => 'shipping_postcode',
];
$this->expectException(RuntimeException::class);
$testee->fromPayPalRequest($data);
$testee->from_paypal_response($data);
}
public function dataFromPayPalRequest() : array

View file

@ -45,17 +45,17 @@ class AmountFactoryTest extends TestCase
->andReturn(7);
expect('get_woocommerce_currency')->andReturn($expectedCurrency);
$result = $testee->fromWcCart($cart);
$this->assertEquals($expectedCurrency, $result->currencyCode());
$result = $testee->from_wc_cart($cart);
$this->assertEquals($expectedCurrency, $result->currency_code());
$this->assertEquals((float) 1, $result->value());
$this->assertEquals((float) 10, $result->breakdown()->discount()->value());
$this->assertEquals($expectedCurrency, $result->breakdown()->discount()->currencyCode());
$this->assertEquals($expectedCurrency, $result->breakdown()->discount()->currency_code());
$this->assertEquals((float) 9, $result->breakdown()->shipping()->value());
$this->assertEquals($expectedCurrency, $result->breakdown()->shipping()->currencyCode());
$this->assertEquals((float) 5, $result->breakdown()->itemTotal()->value());
$this->assertEquals($expectedCurrency, $result->breakdown()->itemTotal()->currencyCode());
$this->assertEquals((float) 13, $result->breakdown()->taxTotal()->value());
$this->assertEquals($expectedCurrency, $result->breakdown()->taxTotal()->currencyCode());
$this->assertEquals($expectedCurrency, $result->breakdown()->shipping()->currency_code());
$this->assertEquals((float) 5, $result->breakdown()->item_total()->value());
$this->assertEquals($expectedCurrency, $result->breakdown()->item_total()->currency_code());
$this->assertEquals((float) 13, $result->breakdown()->tax_total()->value());
$this->assertEquals($expectedCurrency, $result->breakdown()->tax_total()->currency_code());
}
public function testFromWcCartNoDiscount()
@ -90,7 +90,7 @@ class AmountFactoryTest extends TestCase
->andReturn(0);
expect('get_woocommerce_currency')->andReturn($expectedCurrency);
$result = $testee->fromWcCart($cart);
$result = $testee->from_wc_cart($cart);
$this->assertNull($result->breakdown()->discount());
}
@ -111,13 +111,13 @@ class AmountFactoryTest extends TestCase
->shouldReceive('quantity')
->andReturn(2);
$item
->shouldReceive('unitAmount')
->shouldReceive('unit_amount')
->andReturn($unitAmount);
$item
->shouldReceive('tax')
->andReturn($tax);
$itemFactory
->expects('fromWcOrder')
->expects('from_wc_order')
->with($order)
->andReturn([$item]);
$testee = new AmountFactory($itemFactory);
@ -140,17 +140,17 @@ class AmountFactoryTest extends TestCase
->with(false)
->andReturn(3);
$result = $testee->fromWcOrder($order);
$result = $testee->from_wc_order($order);
$this->assertEquals((float) 3, $result->breakdown()->discount()->value());
$this->assertEquals((float) 6, $result->breakdown()->itemTotal()->value());
$this->assertEquals((float) 6, $result->breakdown()->item_total()->value());
$this->assertEquals((float) 1.5, $result->breakdown()->shipping()->value());
$this->assertEquals((float) 100, $result->value());
$this->assertEquals((float) 2, $result->breakdown()->taxTotal()->value());
$this->assertEquals($expectedCurrency, $result->breakdown()->discount()->currencyCode());
$this->assertEquals($expectedCurrency, $result->breakdown()->itemTotal()->currencyCode());
$this->assertEquals($expectedCurrency, $result->breakdown()->shipping()->currencyCode());
$this->assertEquals($expectedCurrency, $result->breakdown()->taxTotal()->currencyCode());
$this->assertEquals($expectedCurrency, $result->currencyCode());
$this->assertEquals((float) 2, $result->breakdown()->tax_total()->value());
$this->assertEquals($expectedCurrency, $result->breakdown()->discount()->currency_code());
$this->assertEquals($expectedCurrency, $result->breakdown()->item_total()->currency_code());
$this->assertEquals($expectedCurrency, $result->breakdown()->shipping()->currency_code());
$this->assertEquals($expectedCurrency, $result->breakdown()->tax_total()->currency_code());
$this->assertEquals($expectedCurrency, $result->currency_code());
}
public function testFromWcOrderDiscountIsNull()
@ -170,13 +170,13 @@ class AmountFactoryTest extends TestCase
->shouldReceive('quantity')
->andReturn(2);
$item
->shouldReceive('unitAmount')
->shouldReceive('unit_amount')
->andReturn($unitAmount);
$item
->shouldReceive('tax')
->andReturn($tax);
$itemFactory
->expects('fromWcOrder')
->expects('from_wc_order')
->with($order)
->andReturn([$item]);
$testee = new AmountFactory($itemFactory);
@ -199,7 +199,7 @@ class AmountFactoryTest extends TestCase
->with(false)
->andReturn(0);
$result = $testee->fromWcOrder($order);
$result = $testee->from_wc_order($order);
$this->assertNull($result->breakdown()->discount());
}
@ -214,12 +214,12 @@ class AmountFactoryTest extends TestCase
if ($expectsException) {
$this->expectException(RuntimeException::class);
}
$result = $testee->fromPayPalResponse($response);
$result = $testee->from_paypal_response($response);
if ($expectsException) {
return;
}
$this->assertEquals($response->value, $result->value());
$this->assertEquals($response->currency_code, $result->currencyCode());
$this->assertEquals($response->currency_code, $result->currency_code());
$breakdown = $result->breakdown();
if (! isset($response->breakdown)) {
$this->assertNull($breakdown);
@ -227,43 +227,43 @@ class AmountFactoryTest extends TestCase
}
if ($breakdown->shipping()) {
$this->assertEquals($response->breakdown->shipping->value, $breakdown->shipping()->value());
$this->assertEquals($response->breakdown->shipping->currency_code, $breakdown->shipping()->currencyCode());
$this->assertEquals($response->breakdown->shipping->currency_code, $breakdown->shipping()->currency_code());
} else {
$this->assertTrue(! isset($response->breakdown->shipping));
}
if ($breakdown->itemTotal()) {
$this->assertEquals($response->breakdown->item_total->value, $breakdown->itemTotal()->value());
$this->assertEquals($response->breakdown->item_total->currency_code, $breakdown->itemTotal()->currencyCode());
if ($breakdown->item_total()) {
$this->assertEquals($response->breakdown->item_total->value, $breakdown->item_total()->value());
$this->assertEquals($response->breakdown->item_total->currency_code, $breakdown->item_total()->currency_code());
} else {
$this->assertTrue(! isset($response->breakdown->item_total));
}
if ($breakdown->taxTotal()) {
$this->assertEquals($response->breakdown->tax_total->value, $breakdown->taxTotal()->value());
$this->assertEquals($response->breakdown->tax_total->currency_code, $breakdown->taxTotal()->currencyCode());
if ($breakdown->tax_total()) {
$this->assertEquals($response->breakdown->tax_total->value, $breakdown->tax_total()->value());
$this->assertEquals($response->breakdown->tax_total->currency_code, $breakdown->tax_total()->currency_code());
} else {
$this->assertTrue(! isset($response->breakdown->tax_total));
}
if ($breakdown->handling()) {
$this->assertEquals($response->breakdown->handling->value, $breakdown->handling()->value());
$this->assertEquals($response->breakdown->handling->currency_code, $breakdown->handling()->currencyCode());
$this->assertEquals($response->breakdown->handling->currency_code, $breakdown->handling()->currency_code());
} else {
$this->assertTrue(! isset($response->breakdown->handling));
}
if ($breakdown->insurance()) {
$this->assertEquals($response->breakdown->insurance->value, $breakdown->insurance()->value());
$this->assertEquals($response->breakdown->insurance->currency_code, $breakdown->insurance()->currencyCode());
$this->assertEquals($response->breakdown->insurance->currency_code, $breakdown->insurance()->currency_code());
} else {
$this->assertTrue(! isset($response->breakdown->insurance));
}
if ($breakdown->shippingDiscount()) {
$this->assertEquals($response->breakdown->shipping_discount->value, $breakdown->shippingDiscount()->value());
$this->assertEquals($response->breakdown->shipping_discount->currency_code, $breakdown->shippingDiscount()->currencyCode());
if ($breakdown->shipping_discount()) {
$this->assertEquals($response->breakdown->shipping_discount->value, $breakdown->shipping_discount()->value());
$this->assertEquals($response->breakdown->shipping_discount->currency_code, $breakdown->shipping_discount()->currency_code());
} else {
$this->assertTrue(! isset($response->breakdown->shipping_discount));
}
if ($breakdown->discount()) {
$this->assertEquals($response->breakdown->discount->value, $breakdown->discount()->value());
$this->assertEquals($response->breakdown->discount->currency_code, $breakdown->discount()->currencyCode());
$this->assertEquals($response->breakdown->discount->currency_code, $breakdown->discount()->currency_code());
} else {
$this->assertTrue(! isset($response->breakdown->discount));
}

View file

@ -19,7 +19,7 @@ class AuthorizationFactoryTest extends TestCase
];
$testee = new AuthorizationFactory();
$result = $testee->fromPayPalRequest($response);
$result = $testee->from_paypal_response($response);
$this->assertInstanceOf(Authorization::class, $result);
@ -37,7 +37,7 @@ class AuthorizationFactoryTest extends TestCase
];
$testee = new AuthorizationFactory();
$testee->fromPayPalRequest($response);
$testee->from_paypal_response($response);
}
public function testReturnExceptionStatusIsMissing()
@ -48,6 +48,6 @@ class AuthorizationFactoryTest extends TestCase
];
$testee = new AuthorizationFactory();
$testee->fromPayPalRequest($response);
$testee->from_paypal_response($response);
}
}

View file

@ -49,7 +49,7 @@ class ItemFactoryTest extends TestCase
->with($product)
->andReturn(1);
$result = $testee->fromWcCart($cart);
$result = $testee->from_wc_cart($cart);
$this->assertCount(1, $result);
$item = current($result);
@ -62,7 +62,7 @@ class ItemFactoryTest extends TestCase
$this->assertEquals(1, $item->quantity());
$this->assertEquals('name', $item->name());
$this->assertEquals('sku', $item->sku());
$this->assertEquals(1, $item->unitAmount()->value());
$this->assertEquals(1, $item->unit_amount()->value());
$this->assertEquals(2, $item->tax()->value());
}
@ -103,7 +103,7 @@ class ItemFactoryTest extends TestCase
->with($product)
->andReturn(1);
$result = $testee->fromWcCart($cart);
$result = $testee->from_wc_cart($cart);
$item = current($result);
$this->assertEquals(Item::DIGITAL_GOODS, $item->category());
@ -151,7 +151,7 @@ class ItemFactoryTest extends TestCase
->with($item, false)
->andReturn(1);
$result = $testee->fromWcOrder($order);
$result = $testee->from_wc_order($order);
$this->assertCount(1, $result);
$item = current($result);
/**
@ -162,7 +162,7 @@ class ItemFactoryTest extends TestCase
$this->assertEquals('description', $item->description());
$this->assertEquals(1, $item->quantity());
$this->assertEquals(Item::PHYSICAL_GOODS, $item->category());
$this->assertEquals(1, $item->unitAmount()->value());
$this->assertEquals(1, $item->unit_amount()->value());
$this->assertEquals(2, $item->tax()->value());
}
@ -208,7 +208,7 @@ class ItemFactoryTest extends TestCase
->with($item, false)
->andReturn(1);
$result = $testee->fromWcOrder($order);
$result = $testee->from_wc_order($order);
$item = current($result);
/**
* @var Item $item
@ -260,7 +260,7 @@ class ItemFactoryTest extends TestCase
->with($item, false)
->andReturn(1);
$result = $testee->fromWcOrder($order);
$result = $testee->from_wc_order($order);
$item = current($result);
/**
* @var Item $item
@ -282,7 +282,7 @@ class ItemFactoryTest extends TestCase
'currency_code' => 'EUR',
],
];
$item = $testee->fromPayPalResponse($response);
$item = $testee->from_paypal_response($response);
$this->assertInstanceOf(Item::class, $item);
/**
* @var Item $item
@ -292,7 +292,7 @@ class ItemFactoryTest extends TestCase
$this->assertEquals('description', $item->description());
$this->assertEquals(1, $item->quantity());
$this->assertEquals(Item::PHYSICAL_GOODS, $item->category());
$this->assertEquals(1, $item->unitAmount()->value());
$this->assertEquals(1, $item->unit_amount()->value());
$this->assertNull($item->tax());
}
@ -310,7 +310,7 @@ class ItemFactoryTest extends TestCase
],
'category' => Item::DIGITAL_GOODS,
];
$item = $testee->fromPayPalResponse($response);
$item = $testee->from_paypal_response($response);
/**
* @var Item $item
*/
@ -334,7 +334,7 @@ class ItemFactoryTest extends TestCase
'currency_code' => 'EUR',
],
];
$item = $testee->fromPayPalResponse($response);
$item = $testee->from_paypal_response($response);
$this->assertEquals(100, $item->tax()->value());
}
@ -355,7 +355,7 @@ class ItemFactoryTest extends TestCase
],
];
$this->expectException(RuntimeException::class);
$testee->fromPayPalResponse($response);
$testee->from_paypal_response($response);
}
public function testFromPayPalResponseThrowsWithoutQuantity()
@ -375,7 +375,7 @@ class ItemFactoryTest extends TestCase
],
];
$this->expectException(RuntimeException::class);
$testee->fromPayPalResponse($response);
$testee->from_paypal_response($response);
}
public function testFromPayPalResponseThrowsWithStringInQuantity()
@ -396,7 +396,7 @@ class ItemFactoryTest extends TestCase
],
];
$this->expectException(RuntimeException::class);
$testee->fromPayPalResponse($response);
$testee->from_paypal_response($response);
}
public function testFromPayPalResponseThrowsWithWrongUnitAmount()
@ -415,6 +415,6 @@ class ItemFactoryTest extends TestCase
],
];
$this->expectException(RuntimeException::class);
$testee->fromPayPalResponse($response);
$testee->from_paypal_response($response);
}
}

View file

@ -27,14 +27,14 @@ class OrderFactoryTest extends TestCase
$order->expects('status')->andReturn($status);
$order->expects('payer')->andReturn($payer);
$order->expects('intent')->andReturn('intent');
$order->expects('createTime')->andReturn($createTime);
$order->expects('updateTime')->andReturn($updateTime);
$order->expects('applicationContext')->andReturnNull();
$order->expects('paymentSource')->andReturnNull();
$order->expects('create_time')->andReturn($createTime);
$order->expects('update_time')->andReturn($updateTime);
$order->expects('application_context')->andReturnNull();
$order->expects('payment_source')->andReturnNull();
$wcOrder = Mockery::mock(\WC_Order::class);
$purchaseUnitFactory = Mockery::mock(PurchaseUnitFactory::class);
$purchaseUnit = Mockery::mock(PurchaseUnit::class);
$purchaseUnitFactory->expects('fromWcOrder')->with($wcOrder)->andReturn($purchaseUnit);
$purchaseUnitFactory->expects('from_wc_order')->with($wcOrder)->andReturn($purchaseUnit);
$payerFactory = Mockery::mock(PayerFactory::class);
$applicationRepository = Mockery::mock(ApplicationContextRepository::class);
$applicationFactory = Mockery::mock(ApplicationContextFactory::class);
@ -48,8 +48,8 @@ class OrderFactoryTest extends TestCase
$applicationFactory,
$paymentSourceFactory
);
$result = $testee->fromWcOrder($wcOrder, $order);
$resultPurchaseUnit = current($result->purchaseUnits());
$result = $testee->from_wc_order($wcOrder, $order);
$resultPurchaseUnit = current($result->purchase_units());
$this->assertEquals($purchaseUnit, $resultPurchaseUnit);
}
@ -62,14 +62,14 @@ class OrderFactoryTest extends TestCase
$purchaseUnitFactory = Mockery::mock(PurchaseUnitFactory::class);
if (count($orderData->purchase_units)) {
$purchaseUnitFactory
->expects('fromPayPalResponse')
->expects('from_paypal_response')
->times(count($orderData->purchase_units))
->andReturn(Mockery::mock(PurchaseUnit::class));
}
$payerFactory = Mockery::mock(PayerFactory::class);
if (isset($orderData->payer)) {
$payerFactory
->expects('fromPayPalResponse')
->expects('from_paypal_response')
->andReturn(Mockery::mock(Payer::class));
}
$applicationRepository = Mockery::mock(ApplicationContextRepository::class);
@ -83,16 +83,16 @@ class OrderFactoryTest extends TestCase
$applicationFactory,
$paymentSourceFactory
);
$order = $testee->fromPayPalResponse($orderData);
$order = $testee->from_paypal_response($orderData);
$this->assertCount(count($orderData->purchase_units), $order->purchaseUnits());
$this->assertCount(count($orderData->purchase_units), $order->purchase_units());
$this->assertEquals($orderData->id, $order->id());
$this->assertEquals($orderData->status, $order->status()->name());
$this->assertEquals($orderData->intent, $order->intent());
if (! isset($orderData->create_time)) {
$this->assertNull($order->createTime());
$this->assertNull($order->create_time());
} else {
$this->assertEquals($orderData->create_time, $order->createTime()->format(\DateTime::ISO8601));
$this->assertEquals($orderData->create_time, $order->create_time()->format(\DateTime::ISO8601));
}
if (! isset($orderData->payer)) {
$this->assertNull($order->payer());
@ -100,9 +100,9 @@ class OrderFactoryTest extends TestCase
$this->assertInstanceOf(Payer::class, $order->payer());
}
if (! isset($orderData->update_time)) {
$this->assertNull($order->updateTime());
$this->assertNull($order->update_time());
} else {
$this->assertEquals($orderData->update_time, $order->updateTime()->format(\DateTime::ISO8601));
$this->assertEquals($orderData->update_time, $order->update_time()->format(\DateTime::ISO8601));
}
}
@ -174,7 +174,7 @@ class OrderFactoryTest extends TestCase
);
$this->expectException(RuntimeException::class);
$testee->fromPayPalResponse($orderData);
$testee->from_paypal_response($orderData);
}
public function dataForTestFromPayPalResponseExceptionsTest() : array

View file

@ -32,19 +32,19 @@ class PayerFactoryTest extends TestCase
->andReturn($expectedFirstName);
$addressFactory = Mockery::mock(AddressFactory::class);
$addressFactory
->expects('fromWcCustomer')
->expects('from_wc_customer')
->with($customer, 'billing')
->andReturn($address);
$testee = new PayerFactory($addressFactory);
$result = $testee->fromCustomer($customer);
$result = $testee->from_customer($customer);
$this->assertEquals($expectedEmail, $result->emailAddress());
$this->assertEquals($expectedEmail, $result->email_address());
$this->assertEquals($expectedLastName, $result->name()->surname());
$this->assertEquals($expectedFirstName, $result->name()->givenName());
$this->assertEquals($expectedFirstName, $result->name()->given_name());
$this->assertEquals($address, $result->address());
$this->assertEquals($expectedPhone, $result->phone()->phone()->nationalNumber());
$this->assertNull($result->birthDate());
$this->assertEmpty($result->payerId());
$this->assertEquals($expectedPhone, $result->phone()->phone()->national_number());
$this->assertNull($result->birthdate());
$this->assertEmpty($result->payer_id());
}
/**
@ -74,13 +74,13 @@ class PayerFactoryTest extends TestCase
->andReturn($expectedFirstName);
$addressFactory = Mockery::mock(AddressFactory::class);
$addressFactory
->expects('fromWcCustomer')
->expects('from_wc_customer')
->with($customer, 'billing')
->andReturn($address);
$testee = new PayerFactory($addressFactory);
$result = $testee->fromCustomer($customer);
$result = $testee->from_customer($customer);
$this->assertEquals($expectedPhone, $result->phone()->phone()->nationalNumber());
$this->assertEquals($expectedPhone, $result->phone()->phone()->national_number());
}
public function testFromWcCustomerNoNumber()
@ -104,11 +104,11 @@ class PayerFactoryTest extends TestCase
->andReturn($expectedFirstName);
$addressFactory = Mockery::mock(AddressFactory::class);
$addressFactory
->expects('fromWcCustomer')
->expects('from_wc_customer')
->with($customer, 'billing')
->andReturn($address);
$testee = new PayerFactory($addressFactory);
$result = $testee->fromCustomer($customer);
$result = $testee->from_customer($customer);
$this->assertNull($result->phone());
}
@ -139,13 +139,13 @@ class PayerFactoryTest extends TestCase
->andReturn($expectedFirstName);
$addressFactory = Mockery::mock(AddressFactory::class);
$addressFactory
->expects('fromWcCustomer')
->expects('from_wc_customer')
->with($customer, 'billing')
->andReturn($address);
$testee = new PayerFactory($addressFactory);
$result = $testee->fromCustomer($customer);
$result = $testee->from_customer($customer);
$this->assertEquals($expectedPhone, $result->phone()->phone()->nationalNumber());
$this->assertEquals($expectedPhone, $result->phone()->phone()->national_number());
}
/**
@ -155,32 +155,32 @@ class PayerFactoryTest extends TestCase
{
$addressFactory = Mockery::mock(AddressFactory::class);
$addressFactory
->expects('fromPayPalRequest')
->expects('from_paypal_response')
->with($data->address)
->andReturn(Mockery::mock(Address::class));
$testee = new PayerFactory($addressFactory);
$payer = $testee->fromPayPalResponse($data);
$this->assertEquals($data->email_address, $payer->emailAddress());
$this->assertEquals($data->payer_id, $payer->payerId());
$this->assertEquals($data->name->given_name, $payer->name()->givenName());
$payer = $testee->from_paypal_response($data);
$this->assertEquals($data->email_address, $payer->email_address());
$this->assertEquals($data->payer_id, $payer->payer_id());
$this->assertEquals($data->name->given_name, $payer->name()->given_name());
$this->assertEquals($data->name->surname, $payer->name()->surname());
if (isset($data->phone)) {
$this->assertEquals($data->phone->phone_type, $payer->phone()->type());
$this->assertEquals($data->phone->phone_number->national_number, $payer->phone()->phone()->nationalNumber());
$this->assertEquals($data->phone->phone_number->national_number, $payer->phone()->phone()->national_number());
} else {
$this->assertNull($payer->phone());
}
$this->assertInstanceOf(Address::class, $payer->address());
if (isset($data->tax_info)) {
$this->assertEquals($data->tax_info->tax_id, $payer->taxInfo()->taxId());
$this->assertEquals($data->tax_info->tax_id_type, $payer->taxInfo()->type());
$this->assertEquals($data->tax_info->tax_id, $payer->tax_info()->tax_id());
$this->assertEquals($data->tax_info->tax_id_type, $payer->tax_info()->type());
} else {
$this->assertNull($payer->taxInfo());
$this->assertNull($payer->tax_info());
}
if (isset($data->birth_date)) {
$this->assertEquals($data->birth_date, $payer->birthDate()->format('Y-m-d'));
$this->assertEquals($data->birth_date, $payer->birthdate()->format('Y-m-d'));
} else {
$this->assertNull($payer->birthDate());
$this->assertNull($payer->birthdate());
}
}

View file

@ -14,10 +14,10 @@ class PaymentsFactoryTest extends TestCase
public function testFromPayPalResponse()
{
$authorization = Mockery::mock(Authorization::class);
$authorization->shouldReceive('toArray')->andReturn(['id' => 'foo', 'status' => 'CREATED']);
$authorization->shouldReceive('to_array')->andReturn(['id' => 'foo', 'status' => 'CREATED']);
$authorizationsFactory = Mockery::mock(AuthorizationFactory::class);
$authorizationsFactory->shouldReceive('fromPayPalRequest')->andReturn($authorization);
$authorizationsFactory->shouldReceive('from_paypal_response')->andReturn($authorization);
$response = (object)[
'authorizations' => [
@ -26,7 +26,7 @@ class PaymentsFactoryTest extends TestCase
];
$testee = new PaymentsFactory($authorizationsFactory);
$result = $testee->fromPayPalResponse($response);
$result = $testee->from_paypal_response($response);
$this->assertInstanceOf(Payments::class, $result);
@ -35,6 +35,6 @@ class PaymentsFactoryTest extends TestCase
['id' => 'foo', 'status' => 'CREATED'],
],
];
$this->assertEquals($expectedToArray, $result->toArray());
$this->assertEquals($expectedToArray, $result->to_array());
}
}

View file

@ -28,7 +28,7 @@ class PurchaseUnitFactoryTest extends TestCase
$amount = Mockery::mock(Amount::class);
$amountFactory = Mockery::mock(AmountFactory::class);
$amountFactory
->shouldReceive('fromWcOrder')
->shouldReceive('from_wc_order')
->with($wcOrder)
->andReturn($amount);
$payeeFactory = Mockery::mock(PayeeFactory::class);
@ -38,17 +38,17 @@ class PurchaseUnitFactoryTest extends TestCase
->shouldReceive('payee')->andReturn($payee);
$itemFactory = Mockery::mock(ItemFactory::class);
$itemFactory
->shouldReceive('fromWcOrder')
->shouldReceive('from_wc_order')
->with($wcOrder)
->andReturn([]);
$address = Mockery::mock(Address::class);
$address
->shouldReceive('countryCode')
->shouldReceive('country_code')
->twice()
->andReturn('DE');
$address
->shouldReceive('postalCode')
->shouldReceive('postal_code')
->andReturn('12345');
$shipping = Mockery::mock(Shipping::class);
$shipping
@ -56,7 +56,7 @@ class PurchaseUnitFactoryTest extends TestCase
->andReturn($address);
$shippingFactory = Mockery::mock(ShippingFactory::class);
$shippingFactory
->shouldReceive('fromWcOrder')
->shouldReceive('from_wc_order')
->with($wcOrder)
->andReturn($shipping);
$paymentsFacory = Mockery::mock(PaymentsFactory::class);
@ -69,14 +69,14 @@ class PurchaseUnitFactoryTest extends TestCase
$paymentsFacory
);
$unit = $testee->fromWcOrder($wcOrder);
$unit = $testee->from_wc_order($wcOrder);
$this->assertTrue(is_a($unit, PurchaseUnit::class));
$this->assertEquals($payee, $unit->payee());
$this->assertEquals('', $unit->description());
$this->assertEquals('default', $unit->referenceId());
$this->assertEquals('WC-' . $wcOrderId, $unit->customId());
$this->assertEquals('', $unit->softDescriptor());
$this->assertEquals('WC-' . $wcOrderId, $unit->invoiceId());
$this->assertEquals('default', $unit->reference_id());
$this->assertEquals('WC-' . $wcOrderId, $unit->custom_id());
$this->assertEquals('', $unit->soft_descriptor());
$this->assertEquals('WC-' . $wcOrderId, $unit->invoice_id());
$this->assertEquals([], $unit->items());
$this->assertEquals($amount, $unit->amount());
$this->assertEquals($shipping, $unit->shipping());
@ -90,7 +90,7 @@ class PurchaseUnitFactoryTest extends TestCase
$amount = Mockery::mock(Amount::class);
$amountFactory = Mockery::mock(AmountFactory::class);
$amountFactory
->expects('fromWcOrder')
->expects('from_wc_order')
->with($wcOrder)
->andReturn($amount);
$payeeFactory = Mockery::mock(PayeeFactory::class);
@ -100,17 +100,17 @@ class PurchaseUnitFactoryTest extends TestCase
->expects('payee')->andReturn($payee);
$itemFactory = Mockery::mock(ItemFactory::class);
$itemFactory
->expects('fromWcOrder')
->expects('from_wc_order')
->with($wcOrder)
->andReturn([]);
$address = Mockery::mock(Address::class);
$address
->expects('countryCode')
->expects('country_code')
->twice()
->andReturn('DE');
$address
->expects('postalCode')
->expects('postal_code')
->andReturn('');
$shipping = Mockery::mock(Shipping::class);
$shipping
@ -119,7 +119,7 @@ class PurchaseUnitFactoryTest extends TestCase
->andReturn($address);
$shippingFactory = Mockery::mock(ShippingFactory::class);
$shippingFactory
->expects('fromWcOrder')
->expects('from_wc_order')
->with($wcOrder)
->andReturn($shipping);
$paymentsFacory = Mockery::mock(PaymentsFactory::class);
@ -132,7 +132,7 @@ class PurchaseUnitFactoryTest extends TestCase
$paymentsFacory
);
$unit = $testee->fromWcOrder($wcOrder);
$unit = $testee->from_wc_order($wcOrder);
$this->assertEquals(null, $unit->shipping());
}
@ -144,7 +144,7 @@ class PurchaseUnitFactoryTest extends TestCase
$amount = Mockery::mock(Amount::class);
$amountFactory = Mockery::mock(AmountFactory::class);
$amountFactory
->expects('fromWcOrder')
->expects('from_wc_order')
->with($wcOrder)
->andReturn($amount);
$payeeFactory = Mockery::mock(PayeeFactory::class);
@ -154,13 +154,13 @@ class PurchaseUnitFactoryTest extends TestCase
->expects('payee')->andReturn($payee);
$itemFactory = Mockery::mock(ItemFactory::class);
$itemFactory
->expects('fromWcOrder')
->expects('from_wc_order')
->with($wcOrder)
->andReturn([]);
$address = Mockery::mock(Address::class);
$address
->expects('countryCode')
->expects('country_code')
->andReturn('');
$shipping = Mockery::mock(Shipping::class);
$shipping
@ -168,7 +168,7 @@ class PurchaseUnitFactoryTest extends TestCase
->andReturn($address);
$shippingFactory = Mockery::mock(ShippingFactory::class);
$shippingFactory
->expects('fromWcOrder')
->expects('from_wc_order')
->with($wcOrder)
->andReturn($shipping);
$paymentsFacory = Mockery::mock(PaymentsFactory::class);
@ -181,7 +181,7 @@ class PurchaseUnitFactoryTest extends TestCase
$paymentsFacory
);
$unit = $testee->fromWcOrder($wcOrder);
$unit = $testee->from_wc_order($wcOrder);
$this->assertEquals(null, $unit->shipping());
}
@ -195,7 +195,7 @@ class PurchaseUnitFactoryTest extends TestCase
$amount = Mockery::mock(Amount::class);
$amountFactory = Mockery::mock(AmountFactory::class);
$amountFactory
->expects('fromWcCart')
->expects('from_wc_cart')
->with($wcCart)
->andReturn($amount);
$payeeFactory = Mockery::mock(PayeeFactory::class);
@ -205,16 +205,16 @@ class PurchaseUnitFactoryTest extends TestCase
->expects('payee')->andReturn($payee);
$itemFactory = Mockery::mock(ItemFactory::class);
$itemFactory
->expects('fromWcCart')
->expects('from_wc_cart')
->with($wcCart)
->andReturn([]);
$address = Mockery::mock(Address::class);
$address
->shouldReceive('countryCode')
->shouldReceive('country_code')
->andReturn('DE');
$address
->shouldReceive('postalCode')
->shouldReceive('postal_code')
->andReturn('12345');
$shipping = Mockery::mock(Shipping::class);
$shipping
@ -223,7 +223,7 @@ class PurchaseUnitFactoryTest extends TestCase
->andReturn($address);
$shippingFactory = Mockery::mock(ShippingFactory::class);
$shippingFactory
->expects('fromWcCustomer')
->expects('from_wc_customer')
->with($wcCustomer)
->andReturn($shipping);
$paymentsFacory = Mockery::mock(PaymentsFactory::class);
@ -236,14 +236,14 @@ class PurchaseUnitFactoryTest extends TestCase
$paymentsFacory
);
$unit = $testee->fromWcCart($wcCart);
$unit = $testee->from_wc_cart($wcCart);
$this->assertTrue(is_a($unit, PurchaseUnit::class));
$this->assertEquals($payee, $unit->payee());
$this->assertEquals('', $unit->description());
$this->assertEquals('default', $unit->referenceId());
$this->assertEquals('', $unit->customId());
$this->assertEquals('', $unit->softDescriptor());
$this->assertEquals('', $unit->invoiceId());
$this->assertEquals('default', $unit->reference_id());
$this->assertEquals('', $unit->custom_id());
$this->assertEquals('', $unit->soft_descriptor());
$this->assertEquals('', $unit->invoice_id());
$this->assertEquals([], $unit->items());
$this->assertEquals($amount, $unit->amount());
$this->assertEquals($shipping, $unit->shipping());
@ -258,7 +258,7 @@ class PurchaseUnitFactoryTest extends TestCase
$amount = Mockery::mock(Amount::class);
$amountFactory = Mockery::mock(AmountFactory::class);
$amountFactory
->expects('fromWcCart')
->expects('from_wc_cart')
->with($wcCart)
->andReturn($amount);
$payeeFactory = Mockery::mock(PayeeFactory::class);
@ -268,7 +268,7 @@ class PurchaseUnitFactoryTest extends TestCase
->expects('payee')->andReturn($payee);
$itemFactory = Mockery::mock(ItemFactory::class);
$itemFactory
->expects('fromWcCart')
->expects('from_wc_cart')
->with($wcCart)
->andReturn([]);
$shippingFactory = Mockery::mock(ShippingFactory::class);
@ -282,7 +282,7 @@ class PurchaseUnitFactoryTest extends TestCase
$paymentsFacory
);
$unit = $testee->fromWcCart($wcCart);
$unit = $testee->from_wc_cart($wcCart);
$this->assertNull($unit->shipping());
}
@ -295,7 +295,7 @@ class PurchaseUnitFactoryTest extends TestCase
$amount = Mockery::mock(Amount::class);
$amountFactory = Mockery::mock(AmountFactory::class);
$amountFactory
->expects('fromWcCart')
->expects('from_wc_cart')
->with($wcCart)
->andReturn($amount);
$payeeFactory = Mockery::mock(PayeeFactory::class);
@ -305,16 +305,16 @@ class PurchaseUnitFactoryTest extends TestCase
->expects('payee')->andReturn($payee);
$itemFactory = Mockery::mock(ItemFactory::class);
$itemFactory
->expects('fromWcCart')
->expects('from_wc_cart')
->with($wcCart)
->andReturn([]);
$address = Mockery::mock(Address::class);
$address
->shouldReceive('countryCode')
->shouldReceive('country_code')
->andReturn('DE');
$address
->shouldReceive('postalCode')
->shouldReceive('postal_code')
->andReturn('');
$shipping = Mockery::mock(Shipping::class);
$shipping
@ -322,7 +322,7 @@ class PurchaseUnitFactoryTest extends TestCase
->andReturn($address);
$shippingFactory = Mockery::mock(ShippingFactory::class);
$shippingFactory
->expects('fromWcCustomer')
->expects('from_wc_customer')
->andReturn($shipping);
$paymentsFacory = Mockery::mock(PaymentsFactory::class);
$testee = new PurchaseUnitFactory(
@ -334,7 +334,7 @@ class PurchaseUnitFactoryTest extends TestCase
$paymentsFacory
);
$unit = $testee->fromWcCart($wcCart);
$unit = $testee->from_wc_cart($wcCart);
$this->assertNull($unit->shipping());
}
@ -347,7 +347,7 @@ class PurchaseUnitFactoryTest extends TestCase
$amount = Mockery::mock(Amount::class);
$amountFactory = Mockery::mock(AmountFactory::class);
$amountFactory
->expects('fromWcCart')
->expects('from_wc_cart')
->with($wcCart)
->andReturn($amount);
$payeeFactory = Mockery::mock(PayeeFactory::class);
@ -357,13 +357,13 @@ class PurchaseUnitFactoryTest extends TestCase
->expects('payee')->andReturn($payee);
$itemFactory = Mockery::mock(ItemFactory::class);
$itemFactory
->expects('fromWcCart')
->expects('from_wc_cart')
->with($wcCart)
->andReturn([]);
$address = Mockery::mock(Address::class);
$address
->shouldReceive('countryCode')
->shouldReceive('country_code')
->andReturn('');
$shipping = Mockery::mock(Shipping::class);
$shipping
@ -371,7 +371,7 @@ class PurchaseUnitFactoryTest extends TestCase
->andReturn($address);
$shippingFactory = Mockery::mock(ShippingFactory::class);
$shippingFactory
->expects('fromWcCustomer')
->expects('from_wc_customer')
->andReturn($shipping);
$paymentsFacory = Mockery::mock(PaymentsFactory::class);
$testee = new PurchaseUnitFactory(
@ -383,7 +383,7 @@ class PurchaseUnitFactoryTest extends TestCase
$paymentsFacory
);
$unit = $testee->fromWcCart($wcCart);
$unit = $testee->from_wc_cart($wcCart);
$this->assertNull($unit->shipping());
}
@ -395,17 +395,17 @@ class PurchaseUnitFactoryTest extends TestCase
$rawShipping = (object) ['shipping' => 1];
$amountFactory = Mockery::mock(AmountFactory::class);
$amount = Mockery::mock(Amount::class);
$amountFactory->expects('fromPayPalResponse')->with($rawAmount)->andReturn($amount);
$amountFactory->expects('from_paypal_response')->with($rawAmount)->andReturn($amount);
$payeeFactory = Mockery::mock(PayeeFactory::class);
$payee = Mockery::mock(Payee::class);
$payeeFactory->expects('fromPayPalResponse')->with($rawPayee)->andReturn($payee);
$payeeFactory->expects('from_paypal_response')->with($rawPayee)->andReturn($payee);
$payeeRepository = Mockery::mock(PayeeRepository::class);
$itemFactory = Mockery::mock(ItemFactory::class);
$item = Mockery::mock(Item::class, ['category' => Item::PHYSICAL_GOODS]);
$itemFactory->expects('fromPayPalResponse')->with($rawItem)->andReturn($item);
$itemFactory->expects('from_paypal_response')->with($rawItem)->andReturn($item);
$shippingFactory = Mockery::mock(ShippingFactory::class);
$shipping = Mockery::mock(Shipping::class);
$shippingFactory->expects('fromPayPalResponse')->with($rawShipping)->andReturn($shipping);
$shippingFactory->expects('from_paypal_response')->with($rawShipping)->andReturn($shipping);
$paymentsFacory = Mockery::mock(PaymentsFactory::class);
$testee = new PurchaseUnitFactory(
$amountFactory,
@ -428,14 +428,14 @@ class PurchaseUnitFactoryTest extends TestCase
'shipping' => $rawShipping,
];
$unit = $testee->fromPayPalResponse($response);
$unit = $testee->from_paypal_response($response);
$this->assertTrue(is_a($unit, PurchaseUnit::class));
$this->assertEquals($payee, $unit->payee());
$this->assertEquals('description', $unit->description());
$this->assertEquals('default', $unit->referenceId());
$this->assertEquals('customId', $unit->customId());
$this->assertEquals('softDescriptor', $unit->softDescriptor());
$this->assertEquals('invoiceId', $unit->invoiceId());
$this->assertEquals('default', $unit->reference_id());
$this->assertEquals('customId', $unit->custom_id());
$this->assertEquals('softDescriptor', $unit->soft_descriptor());
$this->assertEquals('invoiceId', $unit->invoice_id());
$this->assertEquals([$item], $unit->items());
$this->assertEquals($amount, $unit->amount());
$this->assertEquals($shipping, $unit->shipping());
@ -449,15 +449,15 @@ class PurchaseUnitFactoryTest extends TestCase
$rawShipping = (object) ['shipping' => 1];
$amountFactory = Mockery::mock(AmountFactory::class);
$amount = Mockery::mock(Amount::class);
$amountFactory->expects('fromPayPalResponse')->with($rawAmount)->andReturn($amount);
$amountFactory->expects('from_paypal_response')->with($rawAmount)->andReturn($amount);
$payeeFactory = Mockery::mock(PayeeFactory::class);
$payeeRepository = Mockery::mock(PayeeRepository::class);
$itemFactory = Mockery::mock(ItemFactory::class);
$item = Mockery::mock(Item::class, ['category' => Item::PHYSICAL_GOODS]);
$itemFactory->expects('fromPayPalResponse')->with($rawItem)->andReturn($item);
$itemFactory->expects('from_paypal_response')->with($rawItem)->andReturn($item);
$shippingFactory = Mockery::mock(ShippingFactory::class);
$shipping = Mockery::mock(Shipping::class);
$shippingFactory->expects('fromPayPalResponse')->with($rawShipping)->andReturn($shipping);
$shippingFactory->expects('from_paypal_response')->with($rawShipping)->andReturn($shipping);
$paymentsFacory = Mockery::mock(PaymentsFactory::class);
$testee = new PurchaseUnitFactory(
$amountFactory,
@ -479,7 +479,7 @@ class PurchaseUnitFactoryTest extends TestCase
'shipping' => $rawShipping,
];
$unit = $testee->fromPayPalResponse($response);
$unit = $testee->from_paypal_response($response);
$this->assertNull($unit->payee());
}
@ -490,14 +490,14 @@ class PurchaseUnitFactoryTest extends TestCase
$rawPayee = (object) ['payee' => 1];
$amountFactory = Mockery::mock(AmountFactory::class);
$amount = Mockery::mock(Amount::class);
$amountFactory->expects('fromPayPalResponse')->with($rawAmount)->andReturn($amount);
$amountFactory->expects('from_paypal_response')->with($rawAmount)->andReturn($amount);
$payeeFactory = Mockery::mock(PayeeFactory::class);
$payee = Mockery::mock(Payee::class);
$payeeFactory->expects('fromPayPalResponse')->with($rawPayee)->andReturn($payee);
$payeeFactory->expects('from_paypal_response')->with($rawPayee)->andReturn($payee);
$payeeRepository = Mockery::mock(PayeeRepository::class);
$itemFactory = Mockery::mock(ItemFactory::class);
$item = Mockery::mock(Item::class, ['category' => Item::PHYSICAL_GOODS]);
$itemFactory->expects('fromPayPalResponse')->with($rawItem)->andReturn($item);
$itemFactory->expects('from_paypal_response')->with($rawItem)->andReturn($item);
$shippingFactory = Mockery::mock(ShippingFactory::class);
$paymentsFacory = Mockery::mock(PaymentsFactory::class);
$testee = new PurchaseUnitFactory(
@ -520,7 +520,7 @@ class PurchaseUnitFactoryTest extends TestCase
'payee' => $rawPayee,
];
$unit = $testee->fromPayPalResponse($response);
$unit = $testee->from_paypal_response($response);
$this->assertNull($unit->shipping());
}
@ -553,7 +553,7 @@ class PurchaseUnitFactoryTest extends TestCase
];
$this->expectException(\Inpsyde\PayPalCommerce\ApiClient\Exception\RuntimeException::class);
$testee->fromPayPalResponse($response);
$testee->from_paypal_response($response);
}
public function testFromPayPalResponsePaymentsGetAppended()
@ -566,21 +566,21 @@ class PurchaseUnitFactoryTest extends TestCase
$amountFactory = Mockery::mock(AmountFactory::class);
$amount = Mockery::mock(Amount::class);
$amountFactory->expects('fromPayPalResponse')->with($rawAmount)->andReturn($amount);
$amountFactory->expects('from_paypal_response')->with($rawAmount)->andReturn($amount);
$payeeFactory = Mockery::mock(PayeeFactory::class);
$payee = Mockery::mock(Payee::class);
$payeeFactory->expects('fromPayPalResponse')->with($rawPayee)->andReturn($payee);
$payeeFactory->expects('from_paypal_response')->with($rawPayee)->andReturn($payee);
$payeeRepository = Mockery::mock(PayeeRepository::class);
$itemFactory = Mockery::mock(ItemFactory::class);
$item = Mockery::mock(Item::class, ['category' => Item::PHYSICAL_GOODS]);
$itemFactory->expects('fromPayPalResponse')->with($rawItem)->andReturn($item);
$itemFactory->expects('from_paypal_response')->with($rawItem)->andReturn($item);
$shippingFactory = Mockery::mock(ShippingFactory::class);
$shipping = Mockery::mock(Shipping::class);
$shippingFactory->expects('fromPayPalResponse')->with($rawShipping)->andReturn($shipping);
$shippingFactory->expects('from_paypal_response')->with($rawShipping)->andReturn($shipping);
$paymentsFactory = Mockery::mock(PaymentsFactory::class);
$payments = Mockery::mock(Payments::class);
$paymentsFactory->expects('fromPayPalResponse')->with($rawPayments)->andReturn($payments);
$paymentsFactory->expects('from_paypal_response')->with($rawPayments)->andReturn($payments);
$testee = new PurchaseUnitFactory(
$amountFactory,
@ -604,7 +604,7 @@ class PurchaseUnitFactoryTest extends TestCase
'payments' => $rawPayments,
];
$unit = $testee->fromPayPalResponse($response);
$unit = $testee->from_paypal_response($response);
$this->assertEquals($payments, $unit->payments());
}
@ -618,17 +618,17 @@ class PurchaseUnitFactoryTest extends TestCase
$amountFactory = Mockery::mock(AmountFactory::class);
$amount = Mockery::mock(Amount::class);
$amountFactory->expects('fromPayPalResponse')->with($rawAmount)->andReturn($amount);
$amountFactory->expects('from_paypal_response')->with($rawAmount)->andReturn($amount);
$payeeFactory = Mockery::mock(PayeeFactory::class);
$payee = Mockery::mock(Payee::class);
$payeeFactory->expects('fromPayPalResponse')->with($rawPayee)->andReturn($payee);
$payeeFactory->expects('from_paypal_response')->with($rawPayee)->andReturn($payee);
$payeeRepository = Mockery::mock(PayeeRepository::class);
$itemFactory = Mockery::mock(ItemFactory::class);
$item = Mockery::mock(Item::class, ['category' => Item::PHYSICAL_GOODS]);
$itemFactory->expects('fromPayPalResponse')->with($rawItem)->andReturn($item);
$itemFactory->expects('from_paypal_response')->with($rawItem)->andReturn($item);
$shippingFactory = Mockery::mock(ShippingFactory::class);
$shipping = Mockery::mock(Shipping::class);
$shippingFactory->expects('fromPayPalResponse')->with($rawShipping)->andReturn($shipping);
$shippingFactory->expects('from_paypal_response')->with($rawShipping)->andReturn($shipping);
$paymentsFactory = Mockery::mock(PaymentsFactory::class);
@ -653,7 +653,7 @@ class PurchaseUnitFactoryTest extends TestCase
'shipping' => $rawShipping,
];
$unit = $testee->fromPayPalResponse($response);
$unit = $testee->from_paypal_response($response);
$this->assertNull($unit->payments());
}
}

View file

@ -16,7 +16,7 @@ class PayeeRepositoryTest extends TestCase
$merchantId = 'merchant_id';
$testee = new PayeeRepository($merchantEmail, $merchantId);
$payee = $testee->payee();
$this->assertEquals($merchantId, $payee->merchantId());
$this->assertEquals($merchantId, $payee->merchant_id());
$this->assertEquals($merchantEmail, $payee->email());
}
}

View file

@ -97,11 +97,11 @@ class ChangeCartEndpointTest extends TestCase
$defaultLineItem = Mockery::mock(PurchaseUnit::class);
$defaultLineItem
->shouldReceive('toArray')
->shouldReceive('to_array')
->andReturn([1]);
$variationLineItem = Mockery::mock(PurchaseUnit::class);
$variationLineItem
->shouldReceive('toArray')
->shouldReceive('to_array')
->andReturn([2]);
$testData = [

View file

@ -22,15 +22,15 @@ class ThreeDSecureTest extends TestCase
public function testDefault(int $expected, string $liabilityShift, string $authenticationResult, string $enrollment)
{
$result = \Mockery::mock(CardAuthenticationResult::class);
$result->shouldReceive('liabilityShift')->andReturn($liabilityShift);
$result->shouldReceive('authenticationResult')->andReturn($authenticationResult);
$result->shouldReceive('enrollmentStatus')->andReturn($enrollment);
$result->shouldReceive('liability_shift')->andReturn($liabilityShift);
$result->shouldReceive('authentication_result')->andReturn($authenticationResult);
$result->shouldReceive('enrollment_status')->andReturn($enrollment);
$card = \Mockery::mock(PaymentSourceCard::class);
$card->shouldReceive('authenticationResult')->andReturn($result);
$card->shouldReceive('authentication_result')->andReturn($result);
$source = \Mockery::mock(PaymentSource::class);
$source->shouldReceive('card')->andReturn($card);
$order = \Mockery::mock(Order::class);
$order->shouldReceive('paymentSource')->andReturn($source);
$order->shouldReceive('payment_source')->andReturn($source);
$testee = new ThreeDSecure();
$result = $testee->proceed_with_order($order);
$this->assertEquals($expected, $result);

View file

@ -53,7 +53,7 @@ class CheckoutPayPalAddressPresetTest extends TestCase
Order::class,
[
'id' => 'abc123def',
'purchaseUnits' => [
'purchase_units' => [
\Mockery::mock(
PurchaseUnit::class,
[
@ -63,12 +63,12 @@ class CheckoutPayPalAddressPresetTest extends TestCase
'address' => \Mockery::mock(
Address::class,
[
'addressLine1' => 'Unter den Linden 1',
'addressLine2' => '2. Stock Hinterhaus',
'postalCode' => '10117',
'countryCode' => 'DE',
'adminArea1' => 'BE',
'adminArea2' => 'Berlin',
'address_line_1' => 'Unter den Linden 1',
'address_line_2' => '2. Stock Hinterhaus',
'postal_code' => '10117',
'country_code' => 'DE',
'admin_area_1' => 'BE',
'admin_area_2' => 'Berlin',
]
),
]
@ -82,18 +82,18 @@ class CheckoutPayPalAddressPresetTest extends TestCase
'name' => \Mockery::mock(
PayerName::class,
[
'givenName' => 'John',
'given_name' => 'John',
'surname' => 'Doe',
]
),
'emailAddress' => 'mail@domain.tld',
'email_address' => 'mail@domain.tld',
'phone' => \Mockery::mock(
PhoneWithType::class,
[
'phone' => \Mockery::mock(
Phone::class,
[
'nationalNumber' => '+4912345678',
'national_number' => '+4912345678',
]
),
]
@ -173,7 +173,7 @@ class CheckoutPayPalAddressPresetTest extends TestCase
'id' => 'whatever',
]
);
$order->shouldReceive('purchaseUnits')
$order->shouldReceive('purchase_units')
->once()
->andReturn(
[

View file

@ -43,7 +43,7 @@ class AuthorizedPaymentsProcessorTest extends TestCase
->andReturn($payments);
$order = Mockery::mock(Order::class);
$order
->expects('purchaseUnits')
->expects('purchase_units')
->andReturn([$purchaseUnit]);
$orderEndpoint = Mockery::mock(OrderEndpoint::class);
$orderEndpoint
@ -129,7 +129,7 @@ class AuthorizedPaymentsProcessorTest extends TestCase
->andReturn($payments);
$order = Mockery::mock(Order::class);
$order
->expects('purchaseUnits')
->expects('purchase_units')
->andReturn([$purchaseUnit]);
$orderEndpoint = Mockery::mock(OrderEndpoint::class);
$orderEndpoint
@ -181,7 +181,7 @@ class AuthorizedPaymentsProcessorTest extends TestCase
->andReturn($payments);
$order = Mockery::mock(Order::class);
$order
->expects('purchaseUnits')
->expects('purchase_units')
->andReturn([$purchaseUnit]);
$orderEndpoint = Mockery::mock(OrderEndpoint::class);
$orderEndpoint

View file

@ -53,7 +53,7 @@ class OrderProcessorTest extends TestCase
$cartRepository = Mockery::mock(CartRepository::class);
$orderEndpoint = Mockery::mock(OrderEndpoint::class);
$orderEndpoint
->expects('patchOrderWith')
->expects('patch_order_with')
->with($currentOrder, $currentOrder)
->andReturn($currentOrder);
$orderEndpoint
@ -63,7 +63,7 @@ class OrderProcessorTest extends TestCase
$paymentsEndpoint = Mockery::mock(PaymentsEndpoint::class);
$orderFactory = Mockery::mock(OrderFactory::class);
$orderFactory
->expects('fromWcOrder')
->expects('from_wc_order')
->with($wcOrder, $currentOrder)
->andReturn($currentOrder);
$threeDSecure = Mockery::mock(ThreeDSecure::class);
@ -146,7 +146,7 @@ class OrderProcessorTest extends TestCase
$cartRepository = Mockery::mock(CartRepository::class);
$orderEndpoint = Mockery::mock(OrderEndpoint::class);
$orderEndpoint
->expects('patchOrderWith')
->expects('patch_order_with')
->with($currentOrder, $currentOrder)
->andReturn($currentOrder);
$orderEndpoint
@ -156,7 +156,7 @@ class OrderProcessorTest extends TestCase
$paymentsEndpoint = Mockery::mock(PaymentsEndpoint::class);
$orderFactory = Mockery::mock(OrderFactory::class);
$orderFactory
->expects('fromWcOrder')
->expects('from_wc_order')
->with($wcOrder, $currentOrder)
->andReturn($currentOrder);
$threeDSecure = Mockery::mock(ThreeDSecure::class);
@ -224,7 +224,7 @@ class OrderProcessorTest extends TestCase
->shouldReceive('status')
->andReturn($orderStatus);
$currentOrder
->shouldReceive('paymentSource')
->shouldReceive('payment_source')
->andReturnNull();
$sessionHandler = Mockery::mock(SessionHandler::class);
$sessionHandler

View file

@ -48,7 +48,7 @@ class ApplicationContextRepositoryTest extends TestCase
/* @var ApplicationContextRepository $testee */
$testee = $this->buildTestee()[1];
$context = $testee->currentContext($shippingPreference);
$context = $testee->current_context($shippingPreference);
self::assertInstanceOf(
ApplicationContext::class,
@ -79,9 +79,9 @@ class ApplicationContextRepositoryTest extends TestCase
'shippingPreference' => ApplicationContext::SHIPPING_PREFERENCE_NO_SHIPPING,
'expected' => [
'locale' => 'de-DE',
'brandName' => 'Acme corp.',
'landingPage' => ApplicationContext::LANDING_PAGE_BILLING,
'shippingPreference' => ApplicationContext::SHIPPING_PREFERENCE_NO_SHIPPING,
'brand_name' => 'Acme corp.',
'landing_page' => ApplicationContext::LANDING_PAGE_BILLING,
'shipping_preference' => ApplicationContext::SHIPPING_PREFERENCE_NO_SHIPPING,
],
],
];