Skip to content

Commit

Permalink
v1.6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
luiztucillo committed Jan 3, 2024
1 parent 757b60c commit eab865c
Show file tree
Hide file tree
Showing 60 changed files with 2,535 additions and 786 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ESLint.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Run ESLint
name: ESLint
on: [pull_request]

jobs:
Expand All @@ -11,4 +11,4 @@ jobs:
with:
node-version: 16
- run: npm install -g eslint
- run: eslint
- run: eslint
2 changes: 1 addition & 1 deletion .github/workflows/phpcs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ jobs:

- name: Detect Coding Standard Violations
id: phpcs
run: magento2/vendor/bin/phpcs -qn --standard=Magento2 magento2/app/code/MercadoPago/
run: magento2/vendor/bin/phpcs -qn --standard=Magento2 --ignore=magento2/app/code/MercadoPago/AdbPayment/Tests magento2/app/code/MercadoPago/

- name: Detect PHP Compatibility
id: phpcs_compatibility
Expand Down
50 changes: 45 additions & 5 deletions .github/workflows/phpunit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on: [pull_request]

jobs:
validate-tests:
name: Run Tests
runs-on: ubuntu-22.04

services:
Expand Down Expand Up @@ -59,14 +60,53 @@ jobs:

- name: Run Unit Test
id: unit-test
run: magento2/vendor/phpunit/phpunit/phpunit --configuration magento2/app/code/MercadoPago/AdbPayment/phpunit.xml --coverage-clover clover.xml --coverage-text magento2/app/code/MercadoPago/AdbPayment/Tests
run:
XDEBUG_MODE=coverage magento2/vendor/phpunit/phpunit/phpunit \
--configuration magento2/app/code/MercadoPago/AdbPayment/phpunit.xml \
--coverage-html coverage/ \
--coverage-clover coverage/clover.xml \
--coverage-filter magento2/app/code/MercadoPago/AdbPayment

- name: Repository Minimum Test Coverage
id: repository-coverage
run: php magento2/app/code/MercadoPago/AdbPayment/Tests/coverage-checker.php clover.xml 80
run: php magento2/app/code/MercadoPago/AdbPayment/Tests/coverage-checker.php coverage/clover.xml 25

- id: pr-files-list
name: Get Pull Request Files
uses: ruslandulina/[email protected]

- id: save-modified-pr-files-list
name: Save modified PR Files List to a file
run: echo "${{join(steps.pr-files-list.outputs.modified, ' ')}}" > modified-files-list.txt

- id: save-added-pr-files-list
name: Save added PR Files List to a file
run: echo "${{join(steps.pr-added-list.outputs.added, ' ')}}" > added-files-list.txt

- name: PR Modified Files
run: cat modified-files-list.txt

- name: PR Added Files
run: cat added-files-list.txt

- name: Pull Request Coverage
id: pull-request-coverage
run: bash bin/pull-request-coverage.sh
env:
PR_NUMBER: ${{ github.event.number }}
run: php magento2/app/code/MercadoPago/AdbPayment/Tests/pr-coverage.php coverage/clover.xml modified-files-list.txt added-files-list.txt 25

- name: List
run: ls && ls coverage

- name: ZIP coverage results
run: zip coverage.zip coverage

- name: Archive code coverage results
uses: actions/upload-artifact@v3
with:
name: code-coverage-report
path: coverage.zip

- name: Archive code coverage folder
uses: actions/upload-artifact@v3
with:
name: code-coverage-report
path: coverage/
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ vendor
.phpunit.result.cache
testdoc.txt
.idea
coverage/
35 changes: 4 additions & 31 deletions Block/Sales/Info/Card.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Copyright © MercadoPago. All rights reserved.
*
Expand All @@ -8,48 +9,20 @@

namespace MercadoPago\AdbPayment\Block\Sales\Info;

use Magento\Payment\Block\ConfigurableInfo;
use Magento\Framework\Pricing\PriceCurrencyInterface;
use Magento\Framework\View\Element\Template\Context;
use Magento\Payment\Gateway\ConfigInterface;
use MercadoPago\AdbPayment\Block\Sales\Info\Info;


/**
* Payment details form block by card.
*
* @SuppressWarnings(PHPMD.CamelCaseMethodName)
*/
class Card extends ConfigurableInfo
class Card extends Info
{
/**
* Checkout Pro Info template.
*
* @var string
*/
protected $_template = 'MercadoPago_AdbPayment::info/cc/instructions.phtml';

/** @var PriceCurrencyInterface $priceCurrency */
protected $priceCurrency;

public function __construct(
Context $context,
ConfigInterface $config,
PriceCurrencyInterface $priceCurrency,
array $data = []
) {
parent::__construct($context, $config, $data);

$this->priceCurrency = $priceCurrency;
}

/**
* Function getFormatedPrice
*
* @param float $price
*
* @return string
*/
public function getFormatedPrice($amount)
{
return $this->priceCurrency->convertAndFormat($amount);
}
}
4 changes: 2 additions & 2 deletions Block/Sales/Info/CheckoutCredits.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@

namespace MercadoPago\AdbPayment\Block\Sales\Info;

use Magento\Payment\Block\ConfigurableInfo;
use MercadoPago\AdbPayment\Block\Sales\Info\Info;

/**
* Payment details form block by Checkout Credits.
*
* @SuppressWarnings(PHPMD.CamelCasePropertyName)
*/
class CheckoutCredits extends ConfigurableInfo
class CheckoutCredits extends Info
{
/**
* Checkout Pro Info template.
Expand Down
5 changes: 3 additions & 2 deletions Block/Sales/Info/CheckoutPro.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Copyright © MercadoPago. All rights reserved.
*
Expand All @@ -8,14 +9,14 @@

namespace MercadoPago\AdbPayment\Block\Sales\Info;

use Magento\Payment\Block\ConfigurableInfo;
use MercadoPago\AdbPayment\Block\Sales\Info\Info;

/**
* Payment details form block by Checkout Pro.
*
* @SuppressWarnings(PHPMD.CamelCasePropertyName)
*/
class CheckoutPro extends ConfigurableInfo
class CheckoutPro extends Info
{
/**
* Checkout Pro Info template.
Expand Down
81 changes: 81 additions & 0 deletions Block/Sales/Info/Info.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<?php

/**
* Copyright © MercadoPago. All rights reserved.
*
* @author Mercado Pago
* @license See LICENSE for license details.
*/

namespace MercadoPago\AdbPayment\Block\Sales\Info;

use Magento\Payment\Block\ConfigurableInfo;
use Magento\Framework\Stdlib\DateTime\TimezoneInterface;
use Magento\Framework\Pricing\PriceCurrencyInterface;
use Magento\Framework\View\Element\Template\Context;
use Magento\Payment\Gateway\ConfigInterface;

/**
* Payment details form block.
*
* @SuppressWarnings(PHPMD.CamelCasePropertyName)
*/
class Info extends ConfigurableInfo
{
private TimezoneInterface $timezone;

/** @var PriceCurrencyInterface $priceCurrency */
protected $priceCurrency;

/**
* @param Context $context
* @param ConfigInterface $config
* @param TimezoneInterface $timezone
* @param PriceCurrencyInterface $priceCurrency
* @param array $data
*/
public function __construct(
Context $context,
ConfigInterface $config,
TimezoneInterface $timezone,
PriceCurrencyInterface $priceCurrency,
array $data = []
) {
parent::__construct($context, $config, $data);
$this->timezone = $timezone;
$this->priceCurrency = $priceCurrency;
}

/**
* Function FormatedDate
*
* @param string $date
*
* @return string
*/
public function date($date)
{
$localeDate = $this->timezone->date($date);

$format = $localeDate->format('Y-m-d\TH:i:s.000O');


return $this->formatDate(
$format,
\IntlDateFormatter::MEDIUM,
true,
);
}

/**
* Function getFormatedPrice
*
* @param float $price
*
* @return string
*/
public function getFormatedPrice($amount)
{
return $this->priceCurrency->convertAndFormat($amount);
}
}
4 changes: 2 additions & 2 deletions Block/Sales/Info/PaymentMethodsOff.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

namespace MercadoPago\AdbPayment\Block\Sales\Info;

use Magento\Payment\Block\ConfigurableInfo;
use MercadoPago\AdbPayment\Block\Sales\Info\Info;

/**
* Payment details form block by PaymentMethodsOff.
*
* @SuppressWarnings(PHPMD.CamelCasePropertyName)
*/
class PaymentMethodsOff extends ConfigurableInfo
class PaymentMethodsOff extends Info
{
/**
* PaymentMethodsOff Info template.
Expand Down
5 changes: 3 additions & 2 deletions Block/Sales/Info/Pix.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Copyright © MercadoPago. All rights reserved.
*
Expand All @@ -8,14 +9,14 @@

namespace MercadoPago\AdbPayment\Block\Sales\Info;

use Magento\Payment\Block\ConfigurableInfo;
use MercadoPago\AdbPayment\Block\Sales\Info\Info;

/**
* Payment details form block by Pix.
*
* @SuppressWarnings(PHPMD.CamelCasePropertyName)
*/
class Pix extends ConfigurableInfo
class Pix extends Info
{
/**
* Pix Info template.
Expand Down
5 changes: 3 additions & 2 deletions Block/Sales/Info/Pse.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Copyright © MercadoPago. All rights reserved.
*
Expand All @@ -8,14 +9,14 @@

namespace MercadoPago\AdbPayment\Block\Sales\Info;

use Magento\Payment\Block\ConfigurableInfo;
use MercadoPago\AdbPayment\Block\Sales\Info\Info;

/**
* Payment details form block by Pse.
*
* @SuppressWarnings(PHPMD.CamelCasePropertyName)
*/
class Pse extends ConfigurableInfo
class Pse extends Info
{
/**
* Pse Info template.
Expand Down
34 changes: 3 additions & 31 deletions Block/Sales/Info/TwoCc.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Copyright © MercadoPago. All rights reserved.
*
Expand All @@ -7,48 +8,19 @@

namespace MercadoPago\AdbPayment\Block\Sales\Info;

use Magento\Payment\Block\ConfigurableInfo;
use Magento\Framework\Pricing\PriceCurrencyInterface;
use Magento\Framework\View\Element\Template\Context;
use Magento\Payment\Gateway\ConfigInterface;
use MercadoPago\AdbPayment\Block\Sales\Info\Info;

/**
* Payment details form block by Webpay.
*
* @SuppressWarnings(PHPMD.CamelCasePropertyName)
*/
class TwoCc extends ConfigurableInfo
class TwoCc extends Info
{
/**
* TwoCc Info template.
*
* @var string
*/
protected $_template = 'MercadoPago_AdbPayment::info/twocc/instructions.phtml';

/** @var PriceCurrencyInterface $priceCurrency */
protected $priceCurrency;

public function __construct(
Context $context,
ConfigInterface $config,
PriceCurrencyInterface $priceCurrency,
array $data = []
) {
parent::__construct($context, $config, $data);

$this->priceCurrency = $priceCurrency;
}

/**
* Function getFormatedPrice
*
* @param float $price
*
* @return string
*/
public function getFormatedPrice($amount)
{
return $this->priceCurrency->convertAndFormat($amount);
}
}
Loading

0 comments on commit eab865c

Please sign in to comment.