diff --git a/includes/gateway/traits/charge-request-builder.php b/includes/gateway/traits/charge-request-builder.php index 1d5fe43b..3cdf0c3e 100644 --- a/includes/gateway/traits/charge-request-builder.php +++ b/includes/gateway/traits/charge-request-builder.php @@ -11,11 +11,7 @@ public function build_charge_request( { $currency = $order->get_currency(); $return_uri = $this->getRedirectUrl($callback_endpoint, $order_id, $order); - $description = apply_filters( - 'omise_charge_params_description', - 'WooCommerce Order id ' . $order_id, - $order - ); + $description = 'WooCommerce Order id ' . $order_id; return [ 'amount' => Omise_Money::to_subunit($order->get_total(), $currency), @@ -38,12 +34,7 @@ public function getMetadata($order_id, $order, $additionalData = []) // override order_id as a reference for webhook handlers. $orderId = [ 'order_id' => $order_id ]; - echo var_dump(apply_filters('omise_charge_params_metadata', [], $order)); - - return array_merge( - apply_filters('omise_charge_params_metadata', [], $order), - array_merge($orderId, $additionalData) - ); + return array_merge($orderId, $additionalData); } /** diff --git a/tests/unit/includes/gateway/class-omise-payment-ocbc-digital-test.php b/tests/unit/includes/gateway/class-omise-payment-ocbc-digital-test.php index 54fd8e75..2370cfa3 100644 --- a/tests/unit/includes/gateway/class-omise-payment-ocbc-digital-test.php +++ b/tests/unit/includes/gateway/class-omise-payment-ocbc-digital-test.php @@ -12,6 +12,25 @@ public function setUp(): void require_once __DIR__ . '/../../../../includes/gateway/class-omise-payment-ocbc-digital.php'; require_once __DIR__ . '/../../../../includes/classes/class-omise-image.php'; $this->obj = new Omise_Payment_OCBC_Digital(); + + // mocking WP built-in functions + if (!function_exists('plugins_url')) { + function plugins_url() { + return "http://localhost"; + } + } + + if (!function_exists('apply_filters')) { + function apply_filters() { + return "http://localhost/image.png"; + } + } + + if (!function_exists('wc_get_user_agent')) { + function wc_get_user_agent() { + return "Chrome Web"; + } + } } public function tearDown(): void @@ -59,21 +78,7 @@ public function supportsIsCorrect() */ public function getIconReturnsCorrectImageLink() { - // mocking WP built-in functions - if (!function_exists('plugins_url')) { - function plugins_url() { - return "http://localhost"; - } - } - - if (!function_exists('apply_filters')) { - function apply_filters() { - return "http://localhost/image.png"; - } - } - $result = $this->obj->get_icon(); - $this->assertEquals("http://localhost/image.png", $result); } @@ -106,13 +111,6 @@ public function testCharge() $orderMock->shouldReceive('get_total') ->andReturn($expectedAmount/100); // in units - if (!function_exists('wc_get_user_agent')) { - function wc_get_user_agent() { - return "Chrome Web"; - } - } - - $expectedSourceType = 'mobile_banking_ocbc'; $order_id = "123"; $result = $this->obj->charge($order_id, $orderMock); $this->assertEquals($expectedAmount, $result['amount']); diff --git a/tests/unit/includes/gateway/traits/charge-request-builder-test.php b/tests/unit/includes/gateway/traits/charge-request-builder-test.php index 2390ac7c..5935ca47 100644 --- a/tests/unit/includes/gateway/traits/charge-request-builder-test.php +++ b/tests/unit/includes/gateway/traits/charge-request-builder-test.php @@ -14,6 +14,12 @@ public static function setUpBeforeClass(): void */ public function buildChargeRequestReturnsValidResponse() { + if (!function_exists('get_rest_url')) { + function get_rest_url() { + return "http://localhost/"; + } + } + $mock = $this->getMockForTrait('Charge_Request_Builder'); $redirectUrlMock = Mockery::mock('alias:RedirectUrl'); $redirectUrlMock->shouldReceive('create') @@ -38,14 +44,6 @@ public function add_meta_data() {} $source_type = 'alipay'; $callback_url = 'omise_alipay_callback'; - // removed function_exists('apply_filters') check because "apply_filters" - // returns different data type such as string or array depending how it's - // implemented. So, even if "apply_filters" is already declared somewhere, - // it might not return the desired result. So, we are overriding it. - function apply_filters() { - return []; - } - $result = $mock->build_charge_request( $order_id, $order,