-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fixed Japanese translation issue in secure form. * Used locale instead of hardcoded en * Fix installment payment when admin manually pay for order (#388) * [MIT-1562]: Total amount for payment is pulled from order instead of cart when the payment page is triggered from admin. * Fixed the issue with Japanese language Support in the secure form. * Added unit test for installment * Added unit test for installment * Updated test * Fix indentation * Fix the tests after code chagne. * Fix the spelling mistake. * Reverted secure form changes. --------- Co-authored-by: Aashish <[email protected]> * Updated metadata for v5.2.1 --------- Co-authored-by: (AJ) Zin Kyaw Kyaw <[email protected]> Co-authored-by: Aashish <[email protected]>
- Loading branch information
1 parent
8b92392
commit e44d980
Showing
6 changed files
with
120 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
85 changes: 85 additions & 0 deletions
85
tests/unit/includes/gateway/class-omise-payment-installment-test.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
<?php | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use Mockery; | ||
|
||
class Omise_Payment_Installment_Test extends TestCase | ||
{ | ||
public function setUp(): void | ||
{ | ||
// Mocking the parent class | ||
$offsite = Mockery::mock('overload:Omise_Payment_Offsite'); | ||
$offsite->shouldReceive('init_settings'); | ||
$offsite->shouldReceive('get_option'); | ||
|
||
// mocking WP built-in functions | ||
if (!function_exists('wp_kses')) { | ||
function wp_kses() {} | ||
} | ||
|
||
if (!function_exists('add_action')) { | ||
function add_action() {} | ||
} | ||
|
||
require_once __DIR__ . '/../../../../includes/gateway/class-omise-payment-installment.php'; | ||
} | ||
|
||
/** | ||
* close mockery after tests are done | ||
*/ | ||
public function teardown(): void | ||
{ | ||
Mockery::close(); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function getTotalAmountFromAdminOrderpage() | ||
{ | ||
// mocking built-in WooCommerce function | ||
if (!function_exists('wc_get_order')) { | ||
function wc_get_order() { | ||
$class = new class { | ||
public $property; | ||
|
||
public function get_total() { | ||
return 999999; | ||
} | ||
}; | ||
return $class; | ||
} | ||
} | ||
|
||
// mocking the WP global variable $wp | ||
$wp = new stdClass(); | ||
$wp->query_vars = ['order-pay' => 123]; | ||
$GLOBALS['wp'] = $wp; | ||
|
||
$installment = new Omise_Payment_Installment(); | ||
$total = $installment->getTotalAmount(); | ||
|
||
$this->assertEquals($total, 999999); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function getTotalAmountFromCart() | ||
{ | ||
// mocking WC() method | ||
if (!function_exists('WC')) { | ||
function WC() { | ||
$class = new stdClass(); | ||
$class->cart = new stdClass(); | ||
$class->cart->total = 999999; | ||
return $class; | ||
} | ||
} | ||
|
||
$installment = new Omise_Payment_Installment(); | ||
$total = $installment->getTotalAmount(); | ||
|
||
$this->assertEquals($total, 999999); | ||
} | ||
} |