From b833c0afd7475684d383ca1457f766a966524b6a Mon Sep 17 00:00:00 2001 From: Aashish Date: Thu, 12 Oct 2023 11:42:20 +0700 Subject: [PATCH] Updated tests --- includes/admin/views/omise-page-settings.php | 21 +++++----- .../abstract-omise-payment-offline.php | 4 +- .../abstract-omise-payment-base-card-test.php | 39 +------------------ .../abstract-omise-payment-offline-test.php | 11 +----- 4 files changed, 12 insertions(+), 63 deletions(-) diff --git a/includes/admin/views/omise-page-settings.php b/includes/admin/views/omise-page-settings.php index f2f4012d..b0975c60 100644 --- a/includes/admin/views/omise-page-settings.php +++ b/includes/admin/views/omise-page-settings.php @@ -137,18 +137,15 @@

WebHooks feature, you must setup an endpoint at Opn Payments dashboard by using the above url (HTTPS only).', 'omise' ), - array( - 'a' => array( 'href' => array() ), - 'em' => array(), - 'strong' => array() - ) - ), - esc_url( 'https://www.omise.co/api-webhooks' ), - esc_url( 'https://dashboard.omise.co/v2/settings/webhooks' ) - ); + echo sprintf( + wp_kses( + __( 'Unless dynamic webhooks are enabled, you must add the URL below as a new endpoint on your Opn Payments dashboard (HTTPS only).', 'omise' ), + [ + 'a' => ['href' => []], + ], + ), + esc_url( 'https://dashboard.omise.co/v2/settings/webhooks' ) + ); ?> diff --git a/includes/gateway/abstract-omise-payment-offline.php b/includes/gateway/abstract-omise-payment-offline.php index 5668b170..dac3c8e9 100644 --- a/includes/gateway/abstract-omise-payment-offline.php +++ b/includes/gateway/abstract-omise-payment-offline.php @@ -19,9 +19,7 @@ abstract class Omise_Payment_Offline extends Omise_Payment public function charge( $order_id, $order ) { $requestData = $this->build_charge_request( - $order_id, - $order, - $this->source_type + $order_id, $order, $this->source_type ); return OmiseCharge::create($requestData); diff --git a/tests/unit/includes/gateway/abstract-omise-payment-base-card-test.php b/tests/unit/includes/gateway/abstract-omise-payment-base-card-test.php index 588a89f2..c3ad1125 100644 --- a/tests/unit/includes/gateway/abstract-omise-payment-base-card-test.php +++ b/tests/unit/includes/gateway/abstract-omise-payment-base-card-test.php @@ -11,41 +11,4 @@ public function setUp(): void // $omisePayment = Mockery::mock('overload:Omise_Payment'); // $omisePayment->shouldReceive('') } - - public function prepareChargeData() - { - $mock = Mockery::mock('Omise_Payment_Base_Card')->makePartial(); - - // $mock = $this->getMockBuilder('Omise_Payment_Base_Card') - // ->onlyMethods(['prepareChargeData']) - // ->getMock(); - - // $reflectionClass = new \ReflectionClass($mock); - - // $prepareChargeData = $reflectionClass->getMethod('prepareChargeData'); - // $prepareChargeData->setAccessible(true); - - $expectedAmount = 999999; - $expectedCurrency = 'thb'; - $order_id = 'order_123'; - $omise_customer_id = 'cust_123'; - $card_id = 'card_123'; - $token = 'token_123'; - - // Create a mock of the $order object - $orderMock = Mockery::mock('WC_Order'); - - // Define expectations for the mock - $orderMock->shouldReceive('get_currency') - ->andReturn($expectedCurrency); - $orderMock->shouldReceive('get_total') - ->andReturn($expectedAmount/100); // in units - $orderMock->shouldReceive('add_meta_data'); - - $result = $mock->prepareChargeData($order_id, $orderMock, $omise_customer_id, $card_id, $token); - - echo var_dump('

' . print_r($result, true) . '
');
-
-        // $result = $prepareChargeData->invoke($mock, $order_id, $orderMock, $omise_customer_id, $card_id, $token);
-    }
-}
\ No newline at end of file
+}
diff --git a/tests/unit/includes/gateway/abstract-omise-payment-offline-test.php b/tests/unit/includes/gateway/abstract-omise-payment-offline-test.php
index 0be53dc6..f3bc40db 100644
--- a/tests/unit/includes/gateway/abstract-omise-payment-offline-test.php
+++ b/tests/unit/includes/gateway/abstract-omise-payment-offline-test.php
@@ -7,16 +7,7 @@ class Omise_Payment_Offline_Test extends Bootstrap_Test_Setup
     public function setUp(): void
     {
         parent::setUp();
+        Mockery::mock('alias:Omise_Payment')->makePartial();
         require_once __DIR__ . '/../../../../includes/gateway/abstract-omise-payment-offline.php';
     }
-
-    public function charge()
-    {
-        $orderMock = $this->getOrderMock(99999, 'THB');
-        $mock = Mockery::mock('Omise_Payment_Offline')->makePartial();
-
-        $result = $mock->charge('order_123', $orderMock);
-
-        var_dump(print_r($result, true));
-    }
 }