Skip to content

Commit

Permalink
Updated tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Aashish committed Oct 12, 2023
1 parent 145fb58 commit b833c0a
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 63 deletions.
21 changes: 9 additions & 12 deletions includes/admin/views/omise-page-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,18 +137,15 @@
<code><?php echo get_rest_url( null, 'omise/webhooks' ); ?></code>
<p class="description">
<?php
echo sprintf(
wp_kses(
__( 'To enable <a href="%s">WebHooks</a> feature, you must setup an endpoint at <a href="%s"><strong>Opn Payments dashboard</strong></a> by using the above url <em>(HTTPS only)</em>.', '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 <a href="%s">Opn Payments dashboard</a> (HTTPS only).', 'omise' ),
[
'a' => ['href' => []],
],
),
esc_url( 'https://dashboard.omise.co/v2/settings/webhooks' )
);
?>
</fieldset>
</td>
Expand Down
4 changes: 1 addition & 3 deletions includes/gateway/abstract-omise-payment-offline.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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('<pre>' . print_r($result, true) . '<pre>');

// $result = $prepareChargeData->invoke($mock, $order_id, $orderMock, $omise_customer_id, $card_id, $token);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}

0 comments on commit b833c0a

Please sign in to comment.