Skip to content

Commit

Permalink
Merge branch '2.2-develop' into jignesh-baldha-patch1
Browse files Browse the repository at this point in the history
  • Loading branch information
jignesh-baldha authored May 19, 2018
2 parents 6fcfb88 + 9644572 commit bfb39b5
Show file tree
Hide file tree
Showing 322 changed files with 6,168 additions and 2,632 deletions.
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@ language: php
php:
- 7.0
- 7.1
git:
depth: 5
env:
global:
- COMPOSER_BIN_DIR=~/bin
- INTEGRATION_SETS=3
- NODE_JS_VERSION=6
- NODE_JS_VERSION=8
- MAGENTO_HOST_NAME="magento2.travis"
matrix:
- TEST_SUITE=unit
Expand Down
456 changes: 456 additions & 0 deletions CHANGELOG.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion app/code/Magento/AdminNotification/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"lib-libxml": "*"
},
"type": "magento2-module",
"version": "100.2.1",
"version": "100.2.2",
"license": [
"OSL-3.0",
"AFL-3.0"
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/AdvancedPricingImportExport/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"magento/framework": "101.0.*"
},
"type": "magento2-module",
"version": "100.2.1",
"version": "100.2.2",
"license": [
"OSL-3.0",
"AFL-3.0"
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/Analytics/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"magento/framework": "101.0.*"
},
"type": "magento2-module",
"version": "100.2.0",
"version": "100.2.1",
"license": [
"OSL-3.0",
"AFL-3.0"
Expand Down
69 changes: 54 additions & 15 deletions app/code/Magento/Authorizenet/Model/Directpost.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@
*/
namespace Magento\Authorizenet\Model;

use Magento\Framework\HTTP\ZendClientFactory;
use Magento\Framework\App\ObjectManager;
use Magento\Payment\Model\Method\ConfigInterface;
use Magento\Payment\Model\Method\TransparentInterface;
use Magento\Sales\Model\Order\Email\Sender\OrderSender;

/**
* Authorize.net DirectPost payment method model.
Expand Down Expand Up @@ -102,7 +101,7 @@ class Directpost extends \Magento\Authorizenet\Model\Authorizenet implements Tra
protected $response;

/**
* @var OrderSender
* @var \Magento\Sales\Model\Order\Email\Sender\OrderSender
*/
protected $orderSender;

Expand All @@ -123,6 +122,16 @@ class Directpost extends \Magento\Authorizenet\Model\Authorizenet implements Tra
*/
private $psrLogger;

/**
* @var \Magento\Sales\Api\PaymentFailuresInterface
*/
private $paymentFailures;

/**
* @var \Magento\Sales\Model\Order
*/
private $order;

/**
* @param \Magento\Framework\Model\Context $context
* @param \Magento\Framework\Registry $registry
Expand All @@ -141,11 +150,12 @@ class Directpost extends \Magento\Authorizenet\Model\Authorizenet implements Tra
* @param \Magento\Sales\Model\OrderFactory $orderFactory
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
* @param \Magento\Quote\Api\CartRepositoryInterface $quoteRepository
* @param OrderSender $orderSender
* @param \Magento\Sales\Model\Order\Email\Sender\OrderSender $orderSender
* @param \Magento\Sales\Api\TransactionRepositoryInterface $transactionRepository
* @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource
* @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection
* @param array $data
* @param \Magento\Sales\Api\PaymentFailuresInterface|null $paymentFailures
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/
public function __construct(
Expand All @@ -162,15 +172,16 @@ public function __construct(
\Magento\Authorizenet\Model\Directpost\Request\Factory $requestFactory,
\Magento\Authorizenet\Model\Directpost\Response\Factory $responseFactory,
TransactionService $transactionService,
ZendClientFactory $httpClientFactory,
\Magento\Framework\HTTP\ZendClientFactory $httpClientFactory,
\Magento\Sales\Model\OrderFactory $orderFactory,
\Magento\Store\Model\StoreManagerInterface $storeManager,
\Magento\Quote\Api\CartRepositoryInterface $quoteRepository,
\Magento\Sales\Model\Order\Email\Sender\OrderSender $orderSender,
\Magento\Sales\Api\TransactionRepositoryInterface $transactionRepository,
\Magento\Framework\Model\ResourceModel\AbstractResource $resource = null,
\Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null,
array $data = []
array $data = [],
\Magento\Sales\Api\PaymentFailuresInterface $paymentFailures = null
) {
$this->orderFactory = $orderFactory;
$this->storeManager = $storeManager;
Expand All @@ -179,6 +190,8 @@ public function __construct(
$this->orderSender = $orderSender;
$this->transactionRepository = $transactionRepository;
$this->_code = static::METHOD_CODE;
$this->paymentFailures = $paymentFailures ? : ObjectManager::getInstance()
->get(\Magento\Sales\Api\PaymentFailuresInterface::class);

parent::__construct(
$context,
Expand Down Expand Up @@ -561,13 +574,10 @@ public function process(array $responseData)
$this->validateResponse();

$response = $this->getResponse();
//operate with order
$orderIncrementId = $response->getXInvoiceNum();
$responseText = $this->dataHelper->wrapGatewayError($response->getXResponseReasonText());
$isError = false;
if ($orderIncrementId) {
/* @var $order \Magento\Sales\Model\Order */
$order = $this->orderFactory->create()->loadByIncrementId($orderIncrementId);
if ($this->getOrderIncrementId()) {
$order = $this->getOrderFromResponse();
//check payment method
$payment = $order->getPayment();
if (!$payment || $payment->getMethod() != $this->getCode()) {
Expand Down Expand Up @@ -632,9 +642,10 @@ public function checkResponseCode()
return true;
case self::RESPONSE_CODE_DECLINED:
case self::RESPONSE_CODE_ERROR:
throw new \Magento\Framework\Exception\LocalizedException(
$this->dataHelper->wrapGatewayError($this->getResponse()->getXResponseReasonText())
);
$errorMessage = $this->dataHelper->wrapGatewayError($this->getResponse()->getXResponseReasonText());
$order = $this->getOrderFromResponse();
$this->paymentFailures->handle((int)$order->getQuoteId(), $errorMessage);
throw new \Magento\Framework\Exception\LocalizedException($errorMessage);
default:
throw new \Magento\Framework\Exception\LocalizedException(
__('There was a payment authorization error.')
Expand Down Expand Up @@ -988,12 +999,40 @@ protected function getTransactionResponse($transactionId)
private function getPsrLogger()
{
if (null === $this->psrLogger) {
$this->psrLogger = \Magento\Framework\App\ObjectManager::getInstance()
$this->psrLogger = ObjectManager::getInstance()
->get(\Psr\Log\LoggerInterface::class);
}
return $this->psrLogger;
}

/**
* Fetch order by increment id from response.
*
* @return \Magento\Sales\Model\Order
*/
private function getOrderFromResponse(): \Magento\Sales\Model\Order
{
if (!$this->order) {
$this->order = $this->orderFactory->create();

if ($incrementId = $this->getOrderIncrementId()) {
$this->order = $this->order->loadByIncrementId($incrementId);
}
}

return $this->order;
}

/**
* Fetch order increment id from response.
*
* @return string
*/
private function getOrderIncrementId(): string
{
return $this->getResponse()->getXInvoiceNum();
}

/**
* Checks if filter action is Report Only. Transactions that trigger this filter are processed as normal,
* but are also reported in the Merchant Interface as triggering this filter.
Expand Down
51 changes: 44 additions & 7 deletions app/code/Magento/Authorizenet/Test/Unit/Model/DirectpostTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*/
namespace Magento\Authorizenet\Test\Unit\Model;

use Magento\Sales\Api\PaymentFailuresInterface;
use Magento\Framework\Simplexml\Element;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
use Magento\Authorizenet\Model\Directpost;
Expand Down Expand Up @@ -74,6 +75,14 @@ class DirectpostTest extends \PHPUnit\Framework\TestCase
*/
protected $requestFactory;

/**
* @var PaymentFailuresInterface|\PHPUnit_Framework_MockObject_MockObject
*/
private $paymentFailures;

/**
* @inheritdoc
*/
protected function setUp()
{
$this->scopeConfigMock = $this->getMockBuilder(\Magento\Framework\App\Config\ScopeConfigInterface::class)
Expand Down Expand Up @@ -104,6 +113,12 @@ protected function setUp()
->setMethods(['getTransactionDetails'])
->getMock();

$this->paymentFailures = $this->getMockBuilder(
PaymentFailuresInterface::class
)
->disableOriginalConstructor()
->getMock();

$this->requestFactory = $this->getRequestFactoryMock();
$httpClientFactoryMock = $this->getHttpClientFactoryMock();

Expand All @@ -117,7 +132,8 @@ protected function setUp()
'responseFactory' => $this->responseFactoryMock,
'transactionRepository' => $this->transactionRepositoryMock,
'transactionService' => $this->transactionServiceMock,
'httpClientFactory' => $httpClientFactoryMock
'httpClientFactory' => $httpClientFactoryMock,
'paymentFailures' => $this->paymentFailures,
]
);
}
Expand Down Expand Up @@ -313,12 +329,16 @@ public function checkResponseCodeSuccessDataProvider()
}

/**
* @param bool $responseCode
* Checks response failures behaviour.
*
* @param int $responseCode
* @param int $failuresHandlerCalls
* @return void
*
* @expectedException \Magento\Framework\Exception\LocalizedException
* @dataProvider checkResponseCodeFailureDataProvider
*/
public function testCheckResponseCodeFailure($responseCode)
public function testCheckResponseCodeFailure(int $responseCode, int $failuresHandlerCalls)
{
$reasonText = 'reason text';

Expand All @@ -333,18 +353,35 @@ public function testCheckResponseCodeFailure($responseCode)
->with($reasonText)
->willReturn(__('Gateway error: %1', $reasonText));

$orderMock = $this->getMockBuilder(Order::class)
->disableOriginalConstructor()
->getMock();

$orderMock->expects($this->exactly($failuresHandlerCalls))
->method('getQuoteId')
->willReturn(1);

$this->paymentFailures->expects($this->exactly($failuresHandlerCalls))
->method('handle')
->with(1);

$reflection = new \ReflectionClass($this->directpost);
$order = $reflection->getProperty('order');
$order->setAccessible(true);
$order->setValue($this->directpost, $orderMock);

$this->directpost->checkResponseCode();
}

/**
* @return array
*/
public function checkResponseCodeFailureDataProvider()
public function checkResponseCodeFailureDataProvider(): array
{
return [
['responseCode' => Directpost::RESPONSE_CODE_DECLINED],
['responseCode' => Directpost::RESPONSE_CODE_ERROR],
['responseCode' => 999999]
['responseCode' => Directpost::RESPONSE_CODE_DECLINED, 1],
['responseCode' => Directpost::RESPONSE_CODE_ERROR, 1],
['responseCode' => 999999, 0],
];
}

Expand Down
4 changes: 3 additions & 1 deletion app/code/Magento/Backend/Block/Template.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@
* Example:
* <block name="my.block" class="Magento\Backend\Block\Template" template="My_Module::template.phtml" >
* <arguments>
* <argument name="viewModel" xsi:type="object">My\Module\ViewModel\Custom</argument>
* <argument name="view_model" xsi:type="object">My\Module\ViewModel\Custom</argument>
* </arguments>
* </block>
*
* Your class object can then be accessed by doing $block->getViewModel()
*
* @api
* @SuppressWarnings(PHPMD.NumberOfChildren)
* @since 100.0.2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public function render(\Magento\Framework\DataObject $row)
*/
protected function _getCheckboxHtml($value, $checked)
{
$id = 'id_' . rand(0, 999);
$id = 'id_' . random_int(0, 999);
$html = '<label class="data-grid-checkbox-cell-inner" for="'. $id .'">';
$html .= '<input type="checkbox" name="' . $this->getColumn()->getName() . '" ';
$html .= 'id="' . $id . '" data-role="select-row"';
Expand Down
6 changes: 6 additions & 0 deletions app/code/Magento/Backend/Model/Url.php
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,9 @@ public function getUrl($routePath = null, $routeParams = null)
return $result;
}

$this->getRouteParamsResolver()->unsetData('route_params');
$this->_setRoutePath($routePath);
$extraParams = $this->getRouteParamsResolver()->getRouteParams();
$routeName = $this->_getRouteName('*');
$controllerName = $this->_getControllerName(self::DEFAULT_CONTROLLER_NAME);
$actionName = $this->_getActionName(self::DEFAULT_ACTION_NAME);
Expand All @@ -226,6 +228,10 @@ public function getUrl($routePath = null, $routeParams = null)
$routeParams[self::SECRET_KEY_PARAM_NAME] = $secretKey;
}

if (!empty($extraParams)) {
$routeParams = array_merge($extraParams, $routeParams);
}

return parent::getUrl("{$routeName}/{$controllerName}/{$actionName}", $routeParams);
}

Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/Backend/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"magento/module-theme": "100.2.*"
},
"type": "magento2-module",
"version": "100.2.3",
"version": "100.2.4",
"license": [
"OSL-3.0",
"AFL-3.0"
Expand Down
3 changes: 0 additions & 3 deletions app/code/Magento/Backend/etc/adminhtml/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,6 @@
<item name="dev" xsi:type="const">Magento\Config\Model\Config\Structure\ElementVisibilityInterface::HIDDEN</item>
<item name="general/locale/code" xsi:type="const">Magento\Config\Model\Config\Structure\ElementVisibilityInterface::DISABLED</item>
</argument>
<argument name="exemptions" xsi:type="array">
<item name="dev/debug/debug_logging" xsi:type="string"/>
</argument>
</arguments>
</type>
<type name="Magento\Framework\View\Layout\Generator\Block">
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/Backup/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"magento/framework": "101.0.*"
},
"type": "magento2-module",
"version": "100.2.2",
"version": "100.2.3",
"license": [
"OSL-3.0",
"AFL-3.0"
Expand Down
Loading

0 comments on commit bfb39b5

Please sign in to comment.