From f7737ea5fe0ea95ce229b77dab58eb0b46ae86b0 Mon Sep 17 00:00:00 2001 From: Aashish Gurung <101558497+aashishgurung@users.noreply.github.com> Date: Thu, 16 Nov 2023 15:34:27 +0700 Subject: [PATCH 1/2] Fixed a bug for previous merchants without custom name field in the secure form settings. (#419) Co-authored-by: Aashish --- ...ass-omise-page-card-form-customization.php | 8 +++ ...mise-page-card-form-customization-test.php | 49 +++++++++++++++++-- 2 files changed, 52 insertions(+), 5 deletions(-) diff --git a/includes/admin/class-omise-page-card-form-customization.php b/includes/admin/class-omise-page-card-form-customization.php index 8a446482..5f869169 100644 --- a/includes/admin/class-omise-page-card-form-customization.php +++ b/includes/admin/class-omise-page-card-form-customization.php @@ -88,6 +88,14 @@ public function get_design_setting() if (empty($formDesign)) { $formDesign = $this->get_default_design_setting(); } + + // Old saved settings might not have the newer fields. Make sure + // we add the missing field + // TODO: Find a better way to handle this + if (!in_array('custom_name', $formDesign['font'])) { + $formDesign['font']['custom_name'] = ''; + } + return $formDesign; } diff --git a/tests/unit/includes/admin/class-omise-page-card-form-customization-test.php b/tests/unit/includes/admin/class-omise-page-card-form-customization-test.php index 898b22db..43a1dc41 100644 --- a/tests/unit/includes/admin/class-omise-page-card-form-customization-test.php +++ b/tests/unit/includes/admin/class-omise-page-card-form-customization-test.php @@ -9,17 +9,14 @@ class Omise_Page_Card_From_Customization_Test extends TestCase { public function setUp(): void { - // mocking WP built-in functions - if (!function_exists('get_option')) { - function get_option() {} - } - + Brain\Monkey\setUp(); Mockery::mock('alias:Omise_Admin_Page'); require_once __DIR__ . '/../../../../includes/admin/class-omise-page-card-form-customization.php'; } public function tearDown(): void { + Brain\Monkey\tearDown(); Mockery::close(); } @@ -93,6 +90,48 @@ public function testGetDarkTheme() $this->assertEqualsCanonicalizing($expected, $themeValues); } + /** + * Test for merchants using secure form prior to v5.6.0 + * Make sure it includes custom_name + * @test + */ + public function testGetDesignSettingIncludesCustomName() + { + // settings of merchant's secure form prior to v5.6.0 + $savedSettings = [ + 'font' => [ + 'name' => 'Poppins', + 'size' => 16, + ], + 'input' => [ + 'height' => '44px', + 'border_radius' => '4px', + 'border_color' => '#475266', + 'active_border_color' => '#475266', + 'background_color' => '#131926', + 'label_color' => '#E6EAF2', + 'text_color' => '#ffffff', + 'placeholder_color' => '#DBDBDB', + ], + 'checkbox' => [ + 'text_color' => '#E6EAF2', + 'theme_color' => '#1451CC', + ] + ]; + + Brain\Monkey\Functions\stubs( [ + 'get_option' => $savedSettings, + ] ); + + $obj = Omise_Page_Card_From_Customization::get_instance(); + $designValues = $obj->get_design_setting(); + + $expected = $savedSettings; + $expected['font']['custom_name'] = ''; + $this->assertEqualsCanonicalizing($expected, $designValues); + $this->assertArrayHasKey('custom_name', $designValues['font']); + } + /** * Call protected/private method of a class. * From 099794d15c401394b5648f2835611ec88bdd6abc Mon Sep 17 00:00:00 2001 From: Aashish Date: Thu, 16 Nov 2023 15:42:23 +0700 Subject: [PATCH 2/2] Bump to v5.6.1 --- CHANGELOG.md | 3 +++ omise-woocommerce.php | 4 ++-- readme.txt | 6 +++++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b1ea1ab4..9aa204b7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # CHANGELOG +### [v5.6.1 _(Nov 16, 2023)_](https://github.com/omise/omise-woocommerce/releases/tag/v5.6.1) +- Fixed a custom font name bug. (PR [#419](https://github.com/omise/omise-woocommerce/pull/419)) + ### [v5.6.0 _(Nov 15, 2023)_](https://github.com/omise/omise-woocommerce/releases/tag/v5.6.0) - Support Google fonts other than Poppins. (PR [#416](https://github.com/omise/omise-woocommerce/pull/416)) diff --git a/omise-woocommerce.php b/omise-woocommerce.php index 2fd51ffc..67d41fbd 100644 --- a/omise-woocommerce.php +++ b/omise-woocommerce.php @@ -4,7 +4,7 @@ * Plugin Name: Opn Payments * Plugin URI: https://www.omise.co/woocommerce * Description: Opn Payments is a WordPress plugin designed specifically for WooCommerce. The plugin adds support for Opn Payments Payment Gateway's payment methods to WooCommerce. - * Version: 5.6.0 + * Version: 5.6.1 * Author: Opn Payments and contributors * Author URI: https://github.com/omise/omise-woocommerce/graphs/contributors * Text Domain: omise @@ -22,7 +22,7 @@ class Omise * * @var string */ - public $version = '5.6.0'; + public $version = '5.6.1'; /** * The Omise Instance. diff --git a/readme.txt b/readme.txt index a27f1caa..de955022 100644 --- a/readme.txt +++ b/readme.txt @@ -3,7 +3,7 @@ Contributors: Opn Payments Tags: opn payments, payment, payment gateway, woocommerce plugin, omise, opn, installment, internet banking, alipay, paynow, truemoney wallet, woocommerce payment Requires at least: 4.3.1 Tested up to: 6.4.0 -Stable tag: 5.6.0 +Stable tag: 5.6.1 License: MIT License URI: https://opensource.org/licenses/MIT @@ -34,6 +34,10 @@ From there: == Changelog == += 5.6.1 = + +- Fixed a custom font name bug. (PR [#419](https://github.com/omise/omise-woocommerce/pull/419)) + = 5.6.0 = - Support Google fonts other than Poppins. (PR [#416](https://github.com/omise/omise-woocommerce/pull/416))