Skip to content

Commit

Permalink
Merge pull request #80 from pagantis/bugfix-version
Browse files Browse the repository at this point in the history
Resolved module version bug
  • Loading branch information
tmeliotpg authored Sep 21, 2020
2 parents a1c8c51 + 14e2773 commit c0a6c13
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 18 deletions.
1 change: 1 addition & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ jobs:
command: |
export DOCKERHOST=$(ifconfig | grep -E "([0-9]{1,3}\.){3}[0-9]{1,3}" | grep -v 127.0.0.1 | awk '{ print $2 }' | cut -f2 -d: | head -n1)
vendor/bin/phpunit --group woocommerce3-buy
pushRelease:
docker:
- image: circleci/php:7.1-node-browsers
Expand Down
5 changes: 2 additions & 3 deletions WC_Pagantis.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Plugin Name: Pagantis
* Plugin URI: http://www.pagantis.com/
* Description: Financiar con Pagantis
* Version: 8.6.10
* Version: 8.6.11
* Author: Pagantis
*
* Text Domain: pagantis
Expand All @@ -26,7 +26,7 @@
*/
define('PG_WC_MAIN_FILE', __FILE__);
define('PG_ABSPATH', trailingslashit(dirname(PG_WC_MAIN_FILE)));
define('PG_VERSION', getModuleComposerVersion(PG_ABSPATH));
define('PG_VERSION', getModuleVersion());
define('PG_ROOT', dirname(__DIR__));
define('PG_CONFIG_TABLE_NAME', 'pagantis_config');
define('PG_LOGS_TABLE_NAME', 'pagantis_logs');
Expand Down Expand Up @@ -82,7 +82,6 @@ public function __construct()
{
require_once(plugin_dir_path(__FILE__).'/vendor/autoload.php');
require_once(PG_ABSPATH . '/includes/pg-functions.php');

$this->template_path = plugin_dir_path(__FILE__).'/templates/';

$this->pagantisActivation();
Expand Down
1 change: 0 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"name": "pagantis/woocommerce",
"description": "Woocommerce module to add Pagantis",
"version": "8.6.10",
"license": "proprietary",
"type": "wordpress-plugin",
"keywords": [
Expand Down
6 changes: 5 additions & 1 deletion controllers/paymentController.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class WcPagantisGateway extends WC_Payment_Gateway
*/
public function __construct()
{
require_once(plugin_dir_path(__FILE__).'../includes/pg-functions.php');
//Mandatory vars for plugin
$this->id = WcPagantisGateway::METHOD_ID;
$this->has_fields = true;
Expand All @@ -58,6 +59,8 @@ public function __construct()
//Useful vars
$this->template_path = plugin_dir_path(__FILE__) . '../templates/';
$this->allowed_currencies = getAllowedCurrencies();
$this->mainFileLocation = dirname(plugin_dir_path(__FILE__)) . '/WC_Pagantis.php';
$this->plugin_info = get_file_data($this->mainFileLocation, array('Version' => 'Version'), false);
$this->language = strstr(get_locale(), '_', true);
if ($this->language=='') {
$this->language = 'ES';
Expand Down Expand Up @@ -247,7 +250,7 @@ public function pagantisReceiptPage($order_id)
$metadataOrder = new Metadata();
$metadata = array(
'pg_module' => 'woocommerce',
'pg_version' => PG_VERSION,
'pg_version' => getModuleVersion(),
'ec_module' => 'woocommerce',
'ec_version' => WC()->version
);
Expand Down Expand Up @@ -689,4 +692,5 @@ private function unparseUrl($parsed_url)
$path = $parsed_url['path'];
return $scheme . $host . $port . $path . $query . $fragment;
}

}
2 changes: 1 addition & 1 deletion controllers/paymentController4x.php
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ public function pagantisReceiptPage($order_id)
$metadataOrder = new Metadata();
$metadata = array(
'pg_module' => 'woocommerce',
'pg_version' => PG_VERSION,
'pg_version' => getModuleVersion(),
'ec_module' => 'woocommerce',
'ec_version' => WC()->version
);
Expand Down
15 changes: 4 additions & 11 deletions includes/pg-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -334,21 +334,14 @@ function getExtraConfig()
return $response;
}

function getModuleComposerVersion($moduleAbsolutePath)
function getModuleVersion()
{
$maybe_composer_json = $moduleAbsolutePath . 'composer.json';
if (! file_exists($maybe_composer_json) && ! is_readable($maybe_composer_json)) {
return null;
}
$composer = json_decode(file_get_contents($maybe_composer_json));
if (empty($composer->version)) {
return null;
}

return $composer->version;
$mainFile = plugin_dir_path(PG_WC_MAIN_FILE). '/WC_Pagantis.php';
$version = get_file_data($mainFile, array('Version' => 'Version'), false);
return $version['Version'];
}


/**
* @param $order
*
Expand Down
4 changes: 3 additions & 1 deletion test/selenium/buy/AbstractBuy.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,8 @@ public function prepareProductAndCheckout()

/**
* STEP2: Prepare checkout and check pagantis form
*
* @throws \Exception
*/
public function makeCheckoutAndPagantis()
{
Expand Down Expand Up @@ -317,7 +319,7 @@ public function verifyOrderInformation()
{
$messageElementSearch = WebDriverBy::className('entry-title');
$condition = WebDriverExpectedCondition::visibilityOfElementLocated($messageElementSearch);
$this->waitUntil($condition);
$this->waitUntil($condition);
$actualString = $this->webDriver->findElement($messageElementSearch)->getText();
$this->assertNotEmpty($actualString, "PR45");
$confString = ($this->woocommerceLanguage == 'EN') ? "Order received" : "Pedido recibido";
Expand Down

0 comments on commit c0a6c13

Please sign in to comment.