Skip to content
This repository has been archived by the owner on Aug 28, 2023. It is now read-only.

Commit

Permalink
v3.12.3 🚀 (#181)
Browse files Browse the repository at this point in the history
* 🐛 Fix the PR cover checker when there is no test (#189)

This fixes an issue that is workflow failure when the pull request does not contain tests and Added hotfix branch filter to check tests

* fix(helper): 🐛 fixed float to int convertion

* feat(bin): ✨ new command sync with container

* build: 📦 new patch version of mercardo pago for magento 2 v3.12.3

Co-authored-by: Gustavo Brito <[email protected]>
Co-authored-by: Douglas <[email protected]>
  • Loading branch information
3 people authored Nov 16, 2021
1 parent ee07903 commit b34ce87
Show file tree
Hide file tree
Showing 13 changed files with 228 additions and 53 deletions.
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,6 @@ indent_size = 2

[{composer, auth}.json]
indent_size = 4

[{Makefile,**.mk}]
indent_style = tab
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [3.12.3] - 2021-11-16

### Fixed

- Fixed round method for integer currencies

## [3.12.2] - 2021-11-05

### Fixed
Expand Down
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: help bash build linter phpcs phpmd phpstan test
.PHONY: help bash build linter phpcs phpmd phpstan test sync-files
help:
@grep -E '^[a-zA-Z-]+:.*?## .*$$' Makefile | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "%-15s %s\n", $$1, $$2}'

Expand All @@ -22,3 +22,6 @@ phpstan: ## Run and validate code standards with stan

test: ## Run and validate tests with phpunit
@sh bin/run-test.sh

sync-files: ## Sync your local files to Magento 2 Container
@sh bin/run-sync-files.sh
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
</a>
</p>

# Magento 2 - Mercado Pago Module (v3.12.2)
# Magento 2 - Mercado Pago Module (v3.12.3)

The Mercado Pago plugin for Magento 2 allows you to expand the functionalities of your online store and offer a unique payment experience for your customers.

Expand Down
7 changes: 6 additions & 1 deletion bin/pull-request-coverage.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
#!/bin/bash

echo "Getting pull request head branch..."
export PHPUNIT_HEAD_BRANCH=$(curl -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/PluginAndPartners/cart-magento2/pulls/${PR_NUMBER} \
| jq ".head.ref" \
| xargs)

echo "Getting pull request files..."
export PHPUNIT_FILES=$(curl -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/PluginAndPartners/cart-magento2/pulls/${PR_NUMBER}/files \
| jq ".[].filename" \
| grep -E 'php"$' \
| xargs)

php magento2/app/code/MercadoPago/Test/pull-request-coverage-checker.php clover.xml 40 $PHPUNIT_FILES
php magento2/app/code/MercadoPago/Test/pull-request-coverage-checker.php clover.xml 40 $PHPUNIT_HEAD_BRANCH $PHPUNIT_FILES
1 change: 1 addition & 0 deletions bin/run-linters.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/bin/bash

sh bin/run-sync-files.sh
sh bin/run-phpcs.sh
sh bin/run-phpstan.sh
sh bin/run-phpmd.sh
12 changes: 12 additions & 0 deletions bin/run-sync-files.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!bin/bash
echo "\n"
echo 🐘🔍 '\033[01;33m RUNNING SYNC FILES TO MAGENTO 2 CONTAINER \033[0m'
echo "\n"

docker cp src/. magento-php:/var/www/html/magento2/app/code

if [ $? -eq 0 ]; then
echo"\033[01;32m SYNC EXECUTED SUCCESSFULLY \n \033[0m"
else
echo 🚫 "\033[01;31m SYNC FAILED \n \033[0m"
fi
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
}
],
"type": "magento2-module",
"version": "3.12.2",
"version": "3.12.3",
"license": [
"OSL-3.0",
"AFL-3.0"
Expand Down
30 changes: 18 additions & 12 deletions src/MercadoPago/Core/Helper/Round.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,46 +11,52 @@ class Round
*/
const COUNTRIES_WITH_INTEGER_PRICE = [
'MLC',
'MLO',
'MCO',
];


/**
* Get rounded value with site id
*
* @param float $value
* @param float $value
* @param string $siteId
* @return float|integer
*/
public static function roundWithSiteId($value, $siteId)
{
$round = (float) number_format($value, 2, '.', '');

if (in_array($siteId, self::COUNTRIES_WITH_INTEGER_PRICE, true)) {
return (int) $round;
return (int) number_format($value, 0, '.', '');
}

return $round;
}
return (float) number_format($value, 2, '.', '');

}//end roundWithSiteId()


/**
* Get rounded value with site id
*
* @param float $value
* @param float $value
* @return float
*/
public static function roundWithoutSiteId($value)
{
return (float) number_format($value, 2, '.', '');
}

}//end roundWithoutSiteId()


/**
* Get rounded value with site id
*
* @param float $value
* @param float $value
* @return integer
*/
public static function roundInteger($value)
{
return (int) number_format($value, 0, '.', '');
}
}

}//end roundInteger()


}//end class
2 changes: 1 addition & 1 deletion src/MercadoPago/Core/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "mercadopago/core",
"description": "Mercado Pago Magento 2 Plugin",
"type": "magento2-module",
"version": "3.12.2",
"version": "3.12.3",
"license": [
"OSL-3.0",
"AFL-3.0"
Expand Down
2 changes: 1 addition & 1 deletion src/MercadoPago/Core/etc/module.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="MercadoPago_Core" setup_version="3.12.2">
<module name="MercadoPago_Core" setup_version="3.12.3">
<sequence>
<module name="Magento_Sales"/>
<module name="Magento_Payment"/>
Expand Down
86 changes: 86 additions & 0 deletions src/MercadoPago/Test/Unit/Helper/RoundTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
<?php

namespace MercadoPago\Test\Unit\Helper;

use Magento\Framework\View\Element\Template\Context;
use Magento\Sales\Model\OrderFactory;
use \MercadoPago\Core\Block\Info;
use MercadoPago\Core\Helper\Round;
use \PHPUnit\Framework\TestCase;

class HelperTest extends TestCase
{

public function testRoundIntToUp()
{
$result = Round::roundInteger(1.9);
$this->assertEquals(2, $result);

$result = Round::roundInteger(1.5);
$this->assertEquals(2, $result);
}

public function testRoundIntToDown()
{
$result = Round::roundInteger(1.4);
$this->assertEquals(1, $result);

$result = Round::roundInteger(1.1);
$this->assertEquals(1, $result);
}

public function testRoundFloatToUp()
{
$result = Round::roundWithoutSiteId(99.4999);
$this->assertEquals(99.5, $result);

$result = Round::roundWithoutSiteId(55.999);
$this->assertEquals(56, $result);
}

public function testRoundFloatToDown()
{
$result = Round::roundWithoutSiteId(66.404444);
$this->assertEquals(66.40, $result);

$result = Round::roundWithoutSiteId(75.890000);
$this->assertEquals(75.89, $result);
}

public function testRoundWithSiteFloatToUp()
{
$result = Round::roundWithSiteId(142.87777, 'MLB');
$this->assertEquals(142.88, $result);

$result = Round::roundWithSiteId(545.999, 'MLA');
$this->assertEquals(546, $result);
}

public function testRoundWithSiteFloatToDown()
{
$result = Round::roundWithSiteId(66.672333, 'MLM');
$this->assertEquals(66.67, $result);

$result = Round::roundWithSiteId(755.890000, 'MLU');
$this->assertEquals(755.89, $result);
}

public function testRoundWithSiteIntToUp()
{
$result = Round::roundWithSiteId(142.87777, 'MLC');
$this->assertEquals(143, $result);

$result = Round::roundWithSiteId(545.999, 'MCO');
$this->assertEquals(546, $result);
}

public function testRoundWithSiteIntToDown()
{
$result = Round::roundWithSiteId(66.472333, 'MCO');
$this->assertEquals(66, $result);

$result = Round::roundWithSiteId(755.190000, 'MLC');
$this->assertEquals(755, $result);
}

}//end class
Loading

0 comments on commit b34ce87

Please sign in to comment.