Skip to content

Commit

Permalink
Merge pull request #386 from omise/release-v5.2.0
Browse files Browse the repository at this point in the history
Release v5.2.0
  • Loading branch information
ajzkk authored Aug 3, 2023
2 parents fce44ef + 0af35b6 commit 8b92392
Show file tree
Hide file tree
Showing 6 changed files with 93 additions and 5 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# CHANGELOG

### [v5.2.0 _(Aug 3, 2023)_](https://github.com/omise/omise-woocommerce/releases/tag/v5.2.0)
- Declare High-Performance Order Storage (HPOS) as compatible. (PR [#385](https://github.com/omise/omise-woocommerce/pull/385))
- Added a script to run test `composer test`. (PR [#385](https://github.com/omise/omise-woocommerce/pull/385))
- Update sonar properties to exclude javascript files. (PR [#385](https://github.com/omise/omise-woocommerce/pull/384))

### [v5.1.1 _(Jun 13, 2023)_](https://github.com/omise/omise-woocommerce/releases/tag/v5.1.1)
- Remove free products from the Atome bill. (PR [#378](https://github.com/omise/omise-woocommerce/pull/378))
- Fix incompatible issue with country based payments plugin. (PR [#379](https://github.com/omise/omise-woocommerce/pull/379))
Expand Down
6 changes: 5 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
"homepage": "https://www.omise.co/",
"license": "MIT",
"require-dev": {
"phpunit/phpunit": "^5.7 || ^9.5"
"phpunit/phpunit": "^5.7 || ^9.5",
"mockery/mockery": "^1.6"
},
"scripts": {
"test": "vendor/bin/phpunit --testdox --colors"
}
}
18 changes: 16 additions & 2 deletions omise-woocommerce.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.1.1
* Version: 5.2.0
* Author: Opn Payments and contributors
* Author URI: https://github.com/omise/omise-woocommerce/graphs/contributors
* Text Domain: omise
Expand All @@ -22,7 +22,7 @@ class Omise
*
* @var string
*/
public $version = '5.1.1';
public $version = '5.2.0';

/**
* The Omise Instance.
Expand All @@ -47,12 +47,26 @@ class Omise
*/
public function __construct()
{
add_action('before_woocommerce_init', [$this, 'enable_hpos']);
add_action('plugins_loaded', array($this, 'check_dependencies'));
add_action('woocommerce_init', array($this, 'init'));
do_action('omise_initiated');
add_action('admin_notices', [$this, 'embedded_form_notice']);
}

/**
* enable high performance order storage(HPOS) feature
*/
public function enable_hpos() {
if (class_exists(\Automattic\WooCommerce\Utilities\FeaturesUtil::class)) {
\Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility(
'custom_order_tables',
__FILE__,
true
);
}
}

/**
* Notice for users informing about embedded form
*/
Expand Down
8 changes: 7 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.0.2
Stable tag: 5.1.1
Stable tag: 5.2.0
License: MIT
License URI: https://opensource.org/licenses/MIT

Expand Down Expand Up @@ -34,6 +34,12 @@ From there:

== Changelog ==

= 5.2.0 =

- Declare High-Performance Order Storage (HPOS) as compatible. (PR [#385](https://github.com/omise/omise-woocommerce/pull/385))
- Added a script to run test `composer test`. (PR [#385](https://github.com/omise/omise-woocommerce/pull/385))
- Update sonar properties to exclude javascript files. (PR [#385](https://github.com/omise/omise-woocommerce/pull/384))

= 5.1.1 =

- Remove free products from the Atome bill. (PR [#378](https://github.com/omise/omise-woocommerce/pull/378))
Expand Down
2 changes: 1 addition & 1 deletion sonar-project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ sonar.organization=omise
sonar.php.coverage.reportPaths=coverage.xml

sonar.exclusions=**/tests/**, **/assets/**
sonar.coverage.exclusions=**/tests/**, composer.json, Gruntfile.js, **/*.xml, omise-woocommerce.php
sonar.coverage.exclusions=**/tests/**, composer.json, **/*.xml, omise-woocommerce.php, **/*.js
59 changes: 59 additions & 0 deletions tests/unit/omise-woocommerce-test.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?php

use Omise;
use Mockery;
use PHPUnit\Framework\TestCase;

class Omise_Test extends TestCase
{
private Omise $model;

/**
* setup add_action and do_action before the test run
*/
public function setUp(): void
{
if (!function_exists('add_action')) {
function add_action()
{
}
}
if (!function_exists('do_action')) {
function do_action()
{
}
}
require_once __DIR__ . '/../../omise-woocommerce.php';
$this->model = Omise::instance();
}

/**
* close mockery after test cases are done
*/
public function tearDown(): void
{
Mockery::close();
}

/**
* Making sure that when FeaturesUtil class do not exist,
* it doesn't throw any error
*/
public function test_when_features_util_class_do_not_exist()
{
$this->model->enable_hpos();
$this->assertFalse(class_exists(\Automattic\WooCommerce\Utilities\FeaturesUtil::class));
}

/**
* Making sure that when FeaturesUti class exist,
* it doesn't throw any error and the 'declare_compatibility' method should be called once
*/
public function test_when_features_util_class_exist()
{
$featuresUtilMock = Mockery::mock('alias:\Automattic\WooCommerce\Utilities\FeaturesUtil');
$featuresUtilMock->shouldReceive('declare_compatibility')->once();
$this->model->enable_hpos();
$this->assertTrue(class_exists(\Automattic\WooCommerce\Utilities\FeaturesUtil::class));
}
}

0 comments on commit 8b92392

Please sign in to comment.