Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mmaymo committed Dec 27, 2024
1 parent 6b40d38 commit 078b27c
Show file tree
Hide file tree
Showing 12 changed files with 249 additions and 250 deletions.
2 changes: 1 addition & 1 deletion src/Gateway/inc/services.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
use Mollie\WooCommerce\Gateway\Surcharge;
use Mollie\WooCommerce\Notice\AdminNotice;
use Mollie\WooCommerce\Payment\MollieOrderService;
use Mollie\WooCommerce\Payment\OrderInstructionsManager;
use Mollie\WooCommerce\PaymentMethods\InstructionStrategies\OrderInstructionsManager;
use Mollie\WooCommerce\Payment\PaymentCheckoutRedirectService;
use Mollie\WooCommerce\Payment\PaymentFactory;
use Mollie\WooCommerce\PaymentMethods\PaymentFieldsStrategies\PaymentFieldsManager;
Expand Down
13 changes: 4 additions & 9 deletions src/Payment/PaymentProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public function processPayment($order, $paymentGateway): array
$molliePaymentType = $this->paymentTypeBasedOnGateway($paymentMethod);
$molliePaymentType = $this->paymentTypeBasedOnProducts($order, $molliePaymentType);
try {
$paymentObject = $this->paymentFactory->getPaymentObject($molliePaymentType, $paymentMethod);
$paymentObject = $this->paymentFactory->getPaymentObject($molliePaymentType);
} catch (ApiException $exception) {
return $this->paymentObjectFailure($exception);
}
Expand All @@ -126,7 +126,6 @@ public function processPayment($order, $paymentGateway): array
$customerId,
$apiKey
);

$this->saveMollieInfo($order, $paymentObject);
$this->saveSubscriptionMandateData($orderId, $apiKey, $customerId, $paymentObject, $order);
do_action($this->pluginId . '_payment_created', $paymentObject, $order);
Expand Down Expand Up @@ -328,8 +327,7 @@ protected function processAsMollieOrder(
MollieOrder $paymentObject,
$order,
$customer_id,
$apiKey,
$paymentMethod
$apiKey
) {

$molliePaymentType = self::PAYMENT_METHOD_TYPE_ORDER;
Expand Down Expand Up @@ -455,8 +453,7 @@ protected function processAsMollieOrder(
protected function processAsMolliePayment(
\WC_Order $order,
$customer_id,
$apiKey,
$paymentMethod
$apiKey
) {

$paymentObject = $this->paymentFactory->getPaymentObject(
Expand Down Expand Up @@ -563,8 +560,7 @@ protected function processPaymentForMollie(
$paymentObject,
$order,
$customer_id,
$apiKey,
$paymentMethod
$apiKey
);
}

Expand Down Expand Up @@ -599,7 +595,6 @@ protected function saveMollieInfo($order, $payment)

// Set active Mollie payment
$payment_object->setActiveMolliePayment($order->get_id());

// Get Mollie Customer ID
$mollie_customer_id = $payment_object->getMollieCustomerIdFromPaymentObject($payment_object->data()->id);

Expand Down
1 change: 0 additions & 1 deletion src/Payment/Request/Strategies/OrderRequestStrategy.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ public function createRequest(WC_Order $order, string $customerId): array
'orderNumber' => $order->get_order_number(),
];


$context = 'order';
foreach ($this->decorators as $decorator) {
$requestData = $decorator->decorate($requestData, $order, $context);
Expand Down
4 changes: 1 addition & 3 deletions tests/php/Functional/ApplePayButton/AjaxRequestsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@
use Mollie\WooCommerce\Buttons\ApplePayButton\AppleAjaxRequests;
use Mollie\WooCommerce\Buttons\ApplePayButton\ApplePayDataObjectHttp;
use Mollie\WooCommerce\Buttons\ApplePayButton\ResponsesToApple;
use Mollie\WooCommerce\Gateway\Surcharge;
use Mollie\WooCommerce\Payment\RefundLineItemsBuilder;
use Mollie\WooCommerce\Gateway\Refund\RefundLineItemsBuilder;
use Mollie\WooCommerce\Shared\Data;
use Mollie\WooCommerce\Subscription\MollieSubscriptionGatewayHandler;
use Mollie\WooCommerceTests\Functional\HelperMocks;
use Mollie\WooCommerceTests\Stubs\postDTOTestsStubs;
use Mollie\WooCommerceTests\Stubs\WooCommerceMocks;
Expand Down
161 changes: 0 additions & 161 deletions tests/php/Functional/Gateway/MollieGatewayTest.php

This file was deleted.

47 changes: 36 additions & 11 deletions tests/php/Functional/HelperMocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@
namespace Mollie\WooCommerceTests\Functional;


use Inpsyde\PaymentGateway\PaymentGateway;
use Mollie\Api\MollieApiClient;
use Mollie\WooCommerce\Gateway\MolliePaymentGatewayHandler;
use Mollie\WooCommerce\Notice\AdminNotice;
use Mollie\WooCommerce\Payment\MollieOrder;
use Mollie\WooCommerce\Payment\MollieOrderService;
use Mollie\WooCommerce\Payment\OrderInstructionsManager;
use Mollie\WooCommerce\Payment\OrderItemsRefunder;
use Mollie\WooCommerce\Payment\MolliePayment;
use Mollie\WooCommerce\Payment\Request\RequestFactory;
use Mollie\WooCommerce\PaymentMethods\InstructionStrategies\OrderInstructionsManager;
use Mollie\WooCommerce\Gateway\Refund\OrderItemsRefunder;
use Mollie\WooCommerce\Payment\OrderLines;
use Mollie\WooCommerce\Payment\MollieObject;
use Mollie\WooCommerce\Payment\PaymentFactory;
Expand Down Expand Up @@ -50,14 +53,24 @@ public function statusHelper()
return new Status();
}

public function paymentFactory($apiClientMock){
public function genericPaymentGatewayMock()
{
$mock = $this->getMockBuilder(PaymentGateway::class)
->addMethods(['supports'])
->onlyMethods(['get_return_url'])
->disableOriginalConstructor()
->getMock();
return $mock;
}

public function paymentFactory(){
return new PaymentFactory(
$this->dataHelper($apiClientMock),
$this->apiHelper($apiClientMock),
$this->settingsHelper(),
$this->pluginId(),
$this->loggerMock(),
$this->orderLines($apiClientMock)
function(){
return $this->mollieOrderMock();
},
function(){
return $this->molliePaymentMock();
}
);
}

Expand All @@ -67,6 +80,12 @@ public function mollieOrderMock()
->disableOriginalConstructor()
->getMock();
}
public function molliePaymentMock()
{
return $this->getMockBuilder(MolliePayment::class)
->disableOriginalConstructor()
->getMock();
}
public function noticeMock()
{
return $this->getMockBuilder(AdminNotice::class)
Expand Down Expand Up @@ -251,9 +270,8 @@ public function mollieGatewayBuilder($paymentMethodName, $isSepa, $isSubscriptio
$mollieObject = $this->getMockBuilder(MollieObject::class)
->disableOriginalConstructor()
->getMock();
$apiClientMock = $this->apiClient();

$paymentFactory = $this->paymentFactory($apiClientMock);
$paymentFactory = $this->paymentFactory();
$pluginId = $this->pluginId();

return $this->buildTesteeMock(
Expand Down Expand Up @@ -281,6 +299,13 @@ public function mollieGatewayBuilder($paymentMethodName, $isSepa, $isSubscriptio
]
)->getMock();
}

public function requestFactory()
{
return $this->getMockBuilder(RequestFactory::class)
->disableOriginalConstructor()
->getMock();
}
}

class emptyLogger implements LoggerInterface{
Expand Down
4 changes: 2 additions & 2 deletions tests/php/Functional/Payment/OrderItemsRefunderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
use Mollie\Api\Exceptions\ApiException;
use Mollie\Api\Resources\Order;
use Mollie\Api\Resources\Refund;
use Mollie\WooCommerce\Payment\OrderItemsRefunder;
use Mollie\WooCommerce\Payment\RefundLineItemsBuilder;
use Mollie\WooCommerce\Gateway\Refund\OrderItemsRefunder;
use Mollie\WooCommerce\Gateway\Refund\RefundLineItemsBuilder;
use Mollie\WooCommerce\Shared\Data;


Expand Down
Loading

0 comments on commit 078b27c

Please sign in to comment.