Skip to content

Commit 49bc267

Browse files
[EngCom] Public Pull Requests - 2.3-develop
- merged latest code from mainline branch
2 parents a91194f + c0a2062 commit 49bc267

File tree

31 files changed

+380
-548
lines changed

31 files changed

+380
-548
lines changed

app/code/Magento/AuthorizenetAcceptjs/Gateway/Validator/TransactionResponseValidator.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,15 @@ public function validate(array $validationSubject): ResultInterface
5454
if (isset($transactionResponse['messages']['message']['code'])) {
5555
$errorCodes[] = $transactionResponse['messages']['message']['code'];
5656
$errorMessages[] = $transactionResponse['messages']['message']['text'];
57-
} elseif ($transactionResponse['messages']['message']) {
57+
} elseif (isset($transactionResponse['messages']['message'])) {
5858
foreach ($transactionResponse['messages']['message'] as $message) {
5959
$errorCodes[] = $message['code'];
6060
$errorMessages[] = $message['description'];
6161
}
6262
} elseif (isset($transactionResponse['errors'])) {
6363
foreach ($transactionResponse['errors'] as $message) {
6464
$errorCodes[] = $message['errorCode'];
65-
$errorMessages[] = $message['errorCode'];
65+
$errorMessages[] = $message['errorText'];
6666
}
6767
}
6868

@@ -85,8 +85,10 @@ private function isResponseCodeAnError(array $transactionResponse): bool
8585
?? $transactionResponse['errors'][0]['errorCode']
8686
?? null;
8787

88-
return in_array($transactionResponse['responseCode'], [self::RESPONSE_CODE_APPROVED, self::RESPONSE_CODE_HELD])
89-
&& $code
88+
return !in_array($transactionResponse['responseCode'], [
89+
self::RESPONSE_CODE_APPROVED, self::RESPONSE_CODE_HELD
90+
])
91+
|| $code
9092
&& !in_array(
9193
$code,
9294
[

app/code/Magento/AuthorizenetAcceptjs/Test/Unit/Gateway/Validator/TransactionResponseValidatorTest.php

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,18 @@
1515
use PHPUnit\Framework\MockObject\MockObject;
1616
use PHPUnit\Framework\TestCase;
1717

18+
/**
19+
* Tests for the transaction response validator
20+
*/
1821
class TransactionResponseValidatorTest extends TestCase
1922
{
2023
private const RESPONSE_CODE_APPROVED = 1;
2124
private const RESPONSE_CODE_HELD = 4;
25+
private const RESPONSE_CODE_DENIED = 2;
2226
private const RESPONSE_REASON_CODE_APPROVED = 1;
2327
private const RESPONSE_REASON_CODE_PENDING_REVIEW_AUTHORIZED = 252;
2428
private const RESPONSE_REASON_CODE_PENDING_REVIEW = 253;
29+
private const ERROR_CODE_AVS_MISMATCH = 27;
2530

2631
/**
2732
* @var ResultInterfaceFactory|MockObject
@@ -86,16 +91,6 @@ public function testValidateScenarios($transactionResponse, $isValid, $errorCode
8691
public function scenarioProvider()
8792
{
8893
return [
89-
// This validator only cares about successful edge cases so test for default behavior
90-
[
91-
[
92-
'responseCode' => 'foo',
93-
],
94-
true,
95-
[],
96-
[]
97-
],
98-
9994
// Test for acceptable reason codes
10095
[
10196
[
@@ -208,6 +203,29 @@ public function scenarioProvider()
208203
['foo'],
209204
['bar']
210205
],
206+
[
207+
[
208+
'responseCode' => self::RESPONSE_CODE_DENIED,
209+
'errors' => [
210+
[
211+
'errorCode' => self::ERROR_CODE_AVS_MISMATCH,
212+
'errorText' => 'bar'
213+
]
214+
]
215+
],
216+
false,
217+
[self::ERROR_CODE_AVS_MISMATCH],
218+
['bar']
219+
],
220+
// This validator only cares about successful edge cases so test for default behavior
221+
[
222+
[
223+
'responseCode' => 'foo',
224+
],
225+
false,
226+
[],
227+
[]
228+
],
211229
];
212230
}
213231
}

app/code/Magento/Catalog/Model/ResourceModel/Category/Collection.php

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
use Magento\CatalogUrlRewrite\Model\CategoryUrlRewriteGenerator;
99
use Magento\Framework\App\Config\ScopeConfigInterface;
10-
use Magento\Framework\Model\ResourceModel\ResourceModelPoolInterface;
1110
use Magento\Store\Model\ScopeInterface;
1211

1312
/**
@@ -83,8 +82,6 @@ class Collection extends \Magento\Catalog\Model\ResourceModel\Collection\Abstrac
8382
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
8483
* @param \Magento\Framework\DB\Adapter\AdapterInterface $connection
8584
* @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
86-
*
87-
* @param ResourceModelPoolInterface|null $resourceModelPool
8885
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
8986
*/
9087
public function __construct(
@@ -99,8 +96,7 @@ public function __construct(
9996
\Magento\Framework\Validator\UniversalFactory $universalFactory,
10097
\Magento\Store\Model\StoreManagerInterface $storeManager,
10198
\Magento\Framework\DB\Adapter\AdapterInterface $connection = null,
102-
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig = null,
103-
ResourceModelPoolInterface $resourceModelPool = null
99+
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig = null
104100
) {
105101
parent::__construct(
106102
$entityFactory,
@@ -113,8 +109,7 @@ public function __construct(
113109
$resourceHelper,
114110
$universalFactory,
115111
$storeManager,
116-
$connection,
117-
$resourceModelPool
112+
$connection
118113
);
119114
$this->scopeConfig = $scopeConfig ?:
120115
\Magento\Framework\App\ObjectManager::getInstance()->get(ScopeConfigInterface::class);

app/code/Magento/Catalog/Model/ResourceModel/Collection/AbstractCollection.php

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
*/
66
namespace Magento\Catalog\Model\ResourceModel\Collection;
77

8-
use Magento\Framework\Model\ResourceModel\ResourceModelPoolInterface;
9-
108
/**
119
* Catalog EAV collection resource abstract model
1210
*
@@ -45,8 +43,6 @@ class AbstractCollection extends \Magento\Eav\Model\Entity\Collection\AbstractCo
4543
* @param \Magento\Framework\Validator\UniversalFactory $universalFactory
4644
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
4745
* @param \Magento\Framework\DB\Adapter\AdapterInterface $connection
48-
*
49-
* @param ResourceModelPoolInterface|null $resourceModelPool
5046
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
5147
*/
5248
public function __construct(
@@ -60,8 +56,7 @@ public function __construct(
6056
\Magento\Eav\Model\ResourceModel\Helper $resourceHelper,
6157
\Magento\Framework\Validator\UniversalFactory $universalFactory,
6258
\Magento\Store\Model\StoreManagerInterface $storeManager,
63-
\Magento\Framework\DB\Adapter\AdapterInterface $connection = null,
64-
ResourceModelPoolInterface $resourceModelPool = null
59+
\Magento\Framework\DB\Adapter\AdapterInterface $connection = null
6560
) {
6661
$this->_storeManager = $storeManager;
6762
parent::__construct(
@@ -74,8 +69,7 @@ public function __construct(
7469
$eavEntityFactory,
7570
$resourceHelper,
7671
$universalFactory,
77-
$connection,
78-
$resourceModelPool
72+
$connection
7973
);
8074
}
8175

app/code/Magento/Catalog/Model/ResourceModel/Product/Collection.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
use Magento\Store\Model\Store;
2222
use Magento\Catalog\Model\Indexer\Category\Product\TableMaintainer;
2323
use Magento\Framework\Indexer\DimensionFactory;
24-
use Magento\Framework\Model\ResourceModel\ResourceModelPoolInterface;
2524

2625
/**
2726
* Product collection
@@ -32,6 +31,7 @@
3231
* @SuppressWarnings(PHPMD.ExcessiveClassComplexity)
3332
* @SuppressWarnings(PHPMD.NumberOfChildren)
3433
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
34+
* @SuppressWarnings(PHPMD.CookieAndSessionMisuse)
3535
* @since 100.0.2
3636
*/
3737
class Collection extends \Magento\Catalog\Model\ResourceModel\Collection\AbstractCollection
@@ -324,7 +324,6 @@ class Collection extends \Magento\Catalog\Model\ResourceModel\Collection\Abstrac
324324
* @param TableMaintainer|null $tableMaintainer
325325
* @param PriceTableResolver|null $priceTableResolver
326326
* @param DimensionFactory|null $dimensionFactory
327-
* @param ResourceModelPoolInterface|null $resourceModelPool
328327
*
329328
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
330329
*/
@@ -353,8 +352,7 @@ public function __construct(
353352
MetadataPool $metadataPool = null,
354353
TableMaintainer $tableMaintainer = null,
355354
PriceTableResolver $priceTableResolver = null,
356-
DimensionFactory $dimensionFactory = null,
357-
ResourceModelPoolInterface $resourceModelPool = null
355+
DimensionFactory $dimensionFactory = null
358356
) {
359357
$this->moduleManager = $moduleManager;
360358
$this->_catalogProductFlatState = $catalogProductFlatState;
@@ -382,8 +380,7 @@ public function __construct(
382380
$resourceHelper,
383381
$universalFactory,
384382
$storeManager,
385-
$connection,
386-
$resourceModelPool
383+
$connection
387384
);
388385
$this->tableMaintainer = $tableMaintainer ?: ObjectManager::getInstance()->get(TableMaintainer::class);
389386
$this->priceTableResolver = $priceTableResolver ?: ObjectManager::getInstance()->get(PriceTableResolver::class);
@@ -1979,6 +1976,7 @@ protected function _productLimitationPrice($joinLeft = false)
19791976
}
19801977
// Set additional field filters
19811978
foreach ($this->_priceDataFieldFilters as $filterData) {
1979+
// phpcs:ignore Magento2.Functions.DiscouragedFunction
19821980
$select->where(call_user_func_array('sprintf', $filterData));
19831981
}
19841982
} else {
@@ -2284,6 +2282,7 @@ private function getBackend()
22842282
public function addPriceDataFieldFilter($comparisonFormat, $fields)
22852283
{
22862284
if (!preg_match('/^%s( (<|>|=|<=|>=|<>) %s)*$/', $comparisonFormat)) {
2285+
// phpcs:ignore Magento2.Exceptions.DirectThrow
22872286
throw new \Exception('Invalid comparison format.');
22882287
}
22892288

app/code/Magento/Catalog/Model/ResourceModel/Product/Compare/Item/Collection.php

Lines changed: 3 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,14 @@
55
*/
66
namespace Magento\Catalog\Model\ResourceModel\Product\Compare\Item;
77

8-
use Magento\Catalog\Model\Indexer\Category\Product\TableMaintainer;
9-
use Magento\Catalog\Model\Indexer\Product\Price\PriceTableResolver;
10-
use Magento\Catalog\Model\ResourceModel\Product\Collection\ProductLimitationFactory;
11-
use Magento\Framework\EntityManager\MetadataPool;
12-
use Magento\Framework\Indexer\DimensionFactory;
13-
use Magento\Framework\Model\ResourceModel\ResourceModelPoolInterface;
14-
158
/**
169
* Catalog Product Compare Items Resource Collection
1710
*
1811
* @api
1912
* @author Magento Core Team <core@magentocommerce.com>
2013
* @SuppressWarnings(PHPMD.LongVariable)
2114
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
15+
* @SuppressWarnings(PHPMD.CookieAndSessionMisuse)
2216
* @since 100.0.2
2317
*/
2418
class Collection extends \Magento\Catalog\Model\ResourceModel\Product\Collection
@@ -82,12 +76,6 @@ class Collection extends \Magento\Catalog\Model\ResourceModel\Product\Collection
8276
* @param \Magento\Catalog\Model\ResourceModel\Product\Compare\Item $catalogProductCompareItem
8377
* @param \Magento\Catalog\Helper\Product\Compare $catalogProductCompare
8478
* @param \Magento\Framework\DB\Adapter\AdapterInterface $connection
85-
* @param ProductLimitationFactory|null $productLimitationFactory
86-
* @param MetadataPool|null $metadataPool
87-
* @param TableMaintainer|null $tableMaintainer
88-
* @param PriceTableResolver|null $priceTableResolver
89-
* @param DimensionFactory|null $dimensionFactory
90-
* @param ResourceModelPoolInterface|null $resourceModelPool
9179
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
9280
*/
9381
public function __construct(
@@ -112,13 +100,7 @@ public function __construct(
112100
\Magento\Customer\Api\GroupManagementInterface $groupManagement,
113101
\Magento\Catalog\Model\ResourceModel\Product\Compare\Item $catalogProductCompareItem,
114102
\Magento\Catalog\Helper\Product\Compare $catalogProductCompare,
115-
\Magento\Framework\DB\Adapter\AdapterInterface $connection = null,
116-
ProductLimitationFactory $productLimitationFactory = null,
117-
MetadataPool $metadataPool = null,
118-
TableMaintainer $tableMaintainer = null,
119-
PriceTableResolver $priceTableResolver = null,
120-
DimensionFactory $dimensionFactory = null,
121-
ResourceModelPoolInterface $resourceModelPool = null
103+
\Magento\Framework\DB\Adapter\AdapterInterface $connection = null
122104
) {
123105
$this->_catalogProductCompareItem = $catalogProductCompareItem;
124106
$this->_catalogProductCompare = $catalogProductCompare;
@@ -142,13 +124,7 @@ public function __construct(
142124
$customerSession,
143125
$dateTime,
144126
$groupManagement,
145-
$connection,
146-
$productLimitationFactory,
147-
$metadataPool,
148-
$tableMaintainer,
149-
$priceTableResolver,
150-
$dimensionFactory,
151-
$resourceModelPool
127+
$connection
152128
);
153129
}
154130

0 commit comments

Comments
 (0)