Skip to content

Commit 34f5b2a

Browse files
authored
Merge branch '2.4-develop' into B2B-2053
2 parents 5a3c55e + 8ad8b26 commit 34f5b2a

File tree

27 files changed

+383
-444
lines changed

27 files changed

+383
-444
lines changed

app/code/Magento/Backend/App/DefaultPath.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<?php
22
/**
3-
* Default application path for backend area
4-
*
53
* Copyright © Magento, Inc. All rights reserved.
64
* See COPYING.txt for license details.
75
*/
86
namespace Magento\Backend\App;
97

108
/**
9+
* Default application path for backend area
10+
*
1111
* @api
1212
* @since 100.0.2
1313
*/
@@ -24,7 +24,11 @@ class DefaultPath implements \Magento\Framework\App\DefaultPathInterface
2424
*/
2525
public function __construct(\Magento\Backend\App\ConfigInterface $config)
2626
{
27-
$pathParts = explode('/', $config->getValue('web/default/admin'));
27+
$pathConfigValue = $config->getValue('web/default/admin') ?? '';
28+
$pathParts = [];
29+
if ($pathConfigValue) {
30+
$pathParts = explode('/', $pathConfigValue);
31+
}
2832

2933
$this->_parts = [
3034
'area' => isset($pathParts[0]) ? $pathParts[0] : '',

app/code/Magento/Backend/view/adminhtml/templates/widget/tabshoriz.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use Magento\Framework\View\Helper\SecureHtmlRenderer;
1919
<?php foreach ($tabs as $_tab): ?>
2020
<?php $tabId = $block->getTabId($_tab) ?>
2121
<?php $_tabClass = 'tab-item-link ' . $block->getTabClass($_tab) . ' ' .
22-
(preg_match('/\s?ajax\s?/', $_tab->getClass()) ? 'notloaded' : '') ?>
22+
($_tab->getClass() !== null ? (preg_match('/\s?ajax\s?/', $_tab->getClass()) ? 'notloaded' : '') : '') ?>
2323
<?php $_tabType = (!preg_match('/\s?ajax\s?/', $_tabClass) && $block->getTabUrl($_tab) != '#') ? 'link' : '' ?>
2424
<?php $_tabHref = $block->getTabUrl($_tab) == '#' ?
2525
'#' . $tabId . '_content' :

app/code/Magento/Checkout/Model/GuestPaymentInformationManagement.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,10 @@ public function savePaymentInformation(
176176
}
177177
$this->limitShippingCarrier($quote);
178178

179+
if (!(int)$quote->getItemsQty()) {
180+
throw new CouldNotSaveException(__('Some of the products are disabled.'));
181+
}
182+
179183
$this->paymentMethodManagement->set($cartId, $paymentMethod);
180184
return true;
181185
}

app/code/Magento/Checkout/Test/Unit/Model/GuestPaymentInformationManagementTest.php

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ public function testSavePaymentInformationWithoutBillingAddress()
180180
$paymentMock = $this->getMockForAbstractClass(PaymentInterface::class);
181181
$billingAddressMock = $this->getMockForAbstractClass(AddressInterface::class);
182182
$quoteMock = $this->createMock(Quote::class);
183+
$quoteMock->expects($this->any())->method('getItemsQty')->willReturn(1);
183184

184185
$billingAddressMock->expects($this->once())->method('setEmail')->with($email)->willReturnSelf();
185186

@@ -210,6 +211,7 @@ public function testSavePaymentInformationAndPlaceOrderWithLocalizedException()
210211

211212
$quoteMock = $this->createMock(Quote::class);
212213
$quoteMock->method('getBillingAddress')->willReturn($billingAddressMock);
214+
$quoteMock->expects($this->any())->method('getItemsQty')->willReturn(1);
213215
$this->cartRepositoryMock->method('getActive')->with($cartId)->willReturn($quoteMock);
214216

215217
$quoteIdMask = $this->getMockBuilder(QuoteIdMask::class)
@@ -231,6 +233,35 @@ public function testSavePaymentInformationAndPlaceOrderWithLocalizedException()
231233
$this->model->savePaymentInformationAndPlaceOrder($cartId, $email, $paymentMock, $billingAddressMock);
232234
}
233235

236+
public function testSavePaymentInformationAndPlaceOrderWithDisabledProduct()
237+
{
238+
$this->expectException('Magento\Framework\Exception\CouldNotSaveException');
239+
$this->expectExceptionMessage('Some of the products are disabled.');
240+
$cartId = 100;
241+
$email = 'email@magento.com';
242+
$paymentMock = $this->getMockForAbstractClass(PaymentInterface::class);
243+
$billingAddressMock = $this->getMockForAbstractClass(AddressInterface::class);
244+
245+
$quoteMock = $this->createMock(Quote::class);
246+
$quoteMock->method('getBillingAddress')->willReturn($billingAddressMock);
247+
$quoteMock->expects($this->any())->method('getItemsQty')->willReturn(0);
248+
$this->cartRepositoryMock->method('getActive')->with($cartId)->willReturn($quoteMock);
249+
250+
$quoteIdMask = $this->getMockBuilder(QuoteIdMask::class)
251+
->addMethods(['getQuoteId'])
252+
->onlyMethods(['load'])
253+
->disableOriginalConstructor()
254+
->getMock();
255+
$this->quoteIdMaskFactoryMock->method('create')->willReturn($quoteIdMask);
256+
$quoteIdMask->method('load')->with($cartId, 'masked_id')->willReturnSelf();
257+
$quoteIdMask->method('getQuoteId')->willReturn($cartId);
258+
259+
$billingAddressMock->expects($this->once())->method('setEmail')->with($email)->willReturnSelf();
260+
261+
$this->paymentMethodManagementMock->expects($this->never())->method('set')->with($cartId, $paymentMock);
262+
$this->model->savePaymentInformationAndPlaceOrder($cartId, $email, $paymentMock, $billingAddressMock);
263+
}
264+
234265
/**
235266
* @param int $cartId
236267
* @param MockObject $billingAddressMock
@@ -266,6 +297,9 @@ private function getMockForAssignBillingAddress(
266297
$this->cartRepositoryMock->method('getActive')
267298
->with($cartId)
268299
->willReturn($quote);
300+
$quote->expects($this->any())
301+
->method('getItemsQty')
302+
->willReturn(1);
269303
$quote->expects($this->any())
270304
->method('getBillingAddress')
271305
->willReturn($quoteBillingAddress);

app/code/Magento/Deploy/Model/Plugin/ConfigChangeDetector.php

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
namespace Magento\Deploy\Model\Plugin;
88

99
use Magento\Deploy\Model\DeploymentConfig\ChangeDetector;
10+
use Magento\Framework\App\DeploymentConfig;
1011
use Magento\Framework\App\FrontControllerInterface;
1112
use Magento\Framework\App\RequestInterface;
1213
use Magento\Framework\Exception\LocalizedException;
@@ -20,19 +21,26 @@
2021
*/
2122
class ConfigChangeDetector
2223
{
24+
private const DEPLOYMENT_BLUE_GREEN_ENABLED = 'deployment/blue_green/enabled';
25+
2326
/**
2427
* Configuration data changes detector.
2528
*
2629
* @var ChangeDetector
2730
*/
2831
private $changeDetector;
2932

33+
/** @var DeploymentConfig */
34+
private $deploymentConfig;
35+
3036
/**
31-
* @param ChangeDetector $changeDetector configuration data changes detector
37+
* @param ChangeDetector $changeDetector
38+
* @param DeploymentConfig $deploymentConfig
3239
*/
33-
public function __construct(ChangeDetector $changeDetector)
40+
public function __construct(ChangeDetector $changeDetector, DeploymentConfig $deploymentConfig)
3441
{
3542
$this->changeDetector = $changeDetector;
43+
$this->deploymentConfig = $deploymentConfig;
3644
}
3745

3846
/**
@@ -46,7 +54,9 @@ public function __construct(ChangeDetector $changeDetector)
4654
*/
4755
public function beforeDispatch(FrontControllerInterface $subject, RequestInterface $request)
4856
{
49-
if ($this->changeDetector->hasChanges()) {
57+
if (!$this->deploymentConfig->get(self::DEPLOYMENT_BLUE_GREEN_ENABLED)
58+
&& $this->changeDetector->hasChanges()
59+
) {
5060
throw new LocalizedException(
5161
__(
5262
'The configuration file has changed.'

app/code/Magento/Deploy/Test/Unit/Model/Plugin/ConfigChangeDetectorTest.php

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
use Magento\Deploy\Model\DeploymentConfig\ChangeDetector;
1111
use Magento\Deploy\Model\Plugin\ConfigChangeDetector;
12+
use Magento\Framework\App\DeploymentConfig;
1213
use Magento\Framework\App\FrontControllerInterface;
1314
use Magento\Framework\App\RequestInterface;
1415
use PHPUnit\Framework\MockObject\MockObject;
@@ -36,6 +37,11 @@ class ConfigChangeDetectorTest extends TestCase
3637
*/
3738
private $requestMock;
3839

40+
/**
41+
* @var DeploymentConfig|mixed|MockObject
42+
*/
43+
private $deploymentConfig;
44+
3945
/**
4046
* @return void
4147
*/
@@ -48,8 +54,14 @@ protected function setUp(): void
4854
->getMockForAbstractClass();
4955
$this->requestMock = $this->getMockBuilder(RequestInterface::class)
5056
->getMockForAbstractClass();
57+
$this->deploymentConfig =$this->getMockBuilder(DeploymentConfig::class)
58+
->disableOriginalConstructor()
59+
->getMock();
5160

52-
$this->configChangeDetectorPlugin = new ConfigChangeDetector($this->changeDetectorMock);
61+
$this->configChangeDetectorPlugin = new ConfigChangeDetector(
62+
$this->changeDetectorMock,
63+
$this->deploymentConfig
64+
);
5365
}
5466

5567
/**
@@ -65,8 +77,6 @@ public function testBeforeDispatchWithoutException()
6577

6678
/**
6779
* @return void
68-
* @codingStandardsIgnoreStart
69-
* @codingStandardsIgnoreEnd
7080
*/
7181
public function testBeforeDispatchWithException()
7282
{
@@ -80,4 +90,13 @@ public function testBeforeDispatchWithException()
8090
->willReturn(true);
8191
$this->configChangeDetectorPlugin->beforeDispatch($this->frontControllerMock, $this->requestMock);
8292
}
93+
94+
public function testBeforeDispatchWithBlueGreen()
95+
{
96+
$this->deploymentConfig->expects($this->atLeastOnce())
97+
->method('get')
98+
->with('deployment/blue_green/enabled')
99+
->willReturn(1);
100+
$this->configChangeDetectorPlugin->beforeDispatch($this->frontControllerMock, $this->requestMock);
101+
}
83102
}

app/code/Magento/Eav/Model/Entity/Type.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ public function getValueTablePrefix()
303303
*/
304304
public function getEntityTablePrefix()
305305
{
306-
$tablePrefix = trim($this->_data['value_table_prefix']);
306+
$tablePrefix = isset($this->_data['value_table_prefix']) ? trim($this->_data['value_table_prefix']) : '';
307307

308308
if (empty($tablePrefix)) {
309309
$tablePrefix = $this->getEntityTable();

composer.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@
8888
"magento/magento-coding-standard": "*",
8989
"magento/magento2-functional-testing-framework": "^3.7",
9090
"pdepend/pdepend": "~2.10.0",
91-
"phpcompatibility/php-compatibility": "^9.3",
9291
"phpmd/phpmd": "^2.9.1",
9392
"phpstan/phpstan": "~1.1.0",
9493
"phpunit/phpunit": "~9.5.0",

composer.lock

Lines changed: 69 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dev/tests/static/framework/Magento/TestFramework/CodingStandard/Tool/PhpCompatibility.php

Lines changed: 0 additions & 25 deletions
This file was deleted.

0 commit comments

Comments
 (0)