Skip to content

Commit 460b32f

Browse files
committed
Merge branch '2.4-develop' of https://github.com/magento-commerce/magento2ce into PR-2021-20-08
2 parents 66ed0d2 + 86dc050 commit 460b32f

File tree

13 files changed

+710
-271
lines changed

13 files changed

+710
-271
lines changed

app/code/Magento/MediaGalleryUi/view/adminhtml/web/template/image/image-details.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ <h3 translate="'Details'"></h3>
3333
<each args="{ data: value, as: 'item'}">
3434
<div class="value">
3535
<a attr="href: $parents[1].getFilterUrl(item.link)"
36-
text="$parents[1].getUsedInText(item)"></a></br>
36+
text="$parents[1].getUsedInText(item)"></a><br/>
3737
</div>
3838
</each>
3939
</if>
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Quote\Model\Quote;
9+
10+
use Magento\Quote\Model\Quote;
11+
12+
class QuantityCollector
13+
{
14+
/**
15+
* Collect items qty
16+
*
17+
* @param Quote $quote
18+
* @return Quote
19+
*/
20+
public function collectItemsQtys(Quote $quote)
21+
{
22+
$quoteItems = $quote->getAllVisibleItems();
23+
$quote->setItemsCount(0);
24+
$quote->setItemsQty(0);
25+
$quote->setVirtualItemsQty(0);
26+
27+
foreach ($quoteItems as $item) {
28+
if ($item->getParentItem()) {
29+
continue;
30+
}
31+
32+
$children = $item->getChildren();
33+
if ($children && $item->isShipSeparately()) {
34+
foreach ($children as $child) {
35+
if ($child->getProduct()->getIsVirtual()) {
36+
$quote->setVirtualItemsQty($quote->getVirtualItemsQty() + $child->getQty() * $item->getQty());
37+
}
38+
}
39+
}
40+
41+
if ($item->getProduct()->getIsVirtual()) {
42+
$quote->setVirtualItemsQty($quote->getVirtualItemsQty() + $item->getQty());
43+
}
44+
$quote->setItemsCount($quote->getItemsCount() + 1);
45+
$quote->setItemsQty((float)$quote->getItemsQty() + $item->getQty());
46+
}
47+
48+
return $quote;
49+
}
50+
}

app/code/Magento/Quote/Model/Quote/TotalsCollector.php

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@
77

88
namespace Magento\Quote\Model\Quote;
99

10+
use Magento\Framework\App\ObjectManager;
1011
use Magento\Quote\Model\Quote\Address\Total\Collector;
1112
use Magento\Quote\Model\Quote\Address\Total\CollectorFactory;
1213
use Magento\Quote\Model\Quote\Address\Total\CollectorInterface;
1314

1415
/**
15-
* Class TotalsCollector
16+
* Composite object for collecting total.
1617
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
1718
*/
1819
class TotalsCollector
@@ -68,6 +69,11 @@ class TotalsCollector
6869
*/
6970
protected $shippingAssignmentFactory;
7071

72+
/**
73+
* @var QuantityCollector
74+
*/
75+
private $quantityCollector;
76+
7177
/**
7278
* @param Collector $totalCollector
7379
* @param CollectorFactory $totalCollectorFactory
@@ -78,6 +84,7 @@ class TotalsCollector
7884
* @param \Magento\Quote\Model\ShippingFactory $shippingFactory
7985
* @param \Magento\Quote\Model\ShippingAssignmentFactory $shippingAssignmentFactory
8086
* @param \Magento\Quote\Model\QuoteValidator $quoteValidator
87+
* @param QuantityCollector $quantityCollector
8188
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
8289
*/
8390
public function __construct(
@@ -89,7 +96,8 @@ public function __construct(
8996
\Magento\Quote\Model\Quote\TotalsCollectorList $collectorList,
9097
\Magento\Quote\Model\ShippingFactory $shippingFactory,
9198
\Magento\Quote\Model\ShippingAssignmentFactory $shippingAssignmentFactory,
92-
\Magento\Quote\Model\QuoteValidator $quoteValidator
99+
\Magento\Quote\Model\QuoteValidator $quoteValidator,
100+
QuantityCollector $quantityCollector = null
93101
) {
94102
$this->totalCollector = $totalCollector;
95103
$this->totalCollectorFactory = $totalCollectorFactory;
@@ -100,6 +108,8 @@ public function __construct(
100108
$this->shippingFactory = $shippingFactory;
101109
$this->shippingAssignmentFactory = $shippingAssignmentFactory;
102110
$this->quoteValidator = $quoteValidator;
111+
$this->quantityCollector = $quantityCollector
112+
?: ObjectManager::getInstance()->get(QuantityCollector::class);
103113
}
104114

105115
/**
@@ -132,7 +142,7 @@ public function collect(\Magento\Quote\Model\Quote $quote)
132142
['quote' => $quote]
133143
);
134144

135-
$this->_collectItemsQtys($quote);
145+
$this->quantityCollector->collectItemsQtys($quote);
136146

137147
$total->setSubtotal(0);
138148
$total->setBaseSubtotal(0);
@@ -206,6 +216,8 @@ protected function _validateCouponCode(\Magento\Quote\Model\Quote $quote)
206216
*
207217
* @param \Magento\Quote\Model\Quote $quote
208218
* @return $this
219+
* @deprecated
220+
* @see \Magento\Quote\Model\Quote\QuantityCollector
209221
*/
210222
protected function _collectItemsQtys(\Magento\Quote\Model\Quote $quote)
211223
{
@@ -273,7 +285,7 @@ public function collectAddressTotals(
273285
/** @var CollectorInterface $collector */
274286
$collector->collect($quote, $shippingAssignment, $total);
275287
}
276-
288+
277289
$this->eventManager->dispatch(
278290
'sales_quote_address_collect_totals_after',
279291
[

app/code/Magento/Security/Model/AdminSessionsManager.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
namespace Magento\Security\Model;
99

1010
use Magento\Framework\HTTP\PhpEnvironment\RemoteAddress;
11-
use \Magento\Security\Model\ResourceModel\AdminSessionInfo\CollectionFactory;
11+
use Magento\Security\Model\ResourceModel\AdminSessionInfo\CollectionFactory;
1212

1313
/**
1414
* Admin Sessions Manager Model
@@ -174,8 +174,15 @@ public function processLogout()
174174
public function getCurrentSession()
175175
{
176176
if (!$this->currentSession) {
177+
$adminSessionInfoId = $this->authSession->getAdminSessionInfoId();
178+
if (!$adminSessionInfoId) {
179+
$this->createNewSession();
180+
$adminSessionInfoId = $this->authSession->getAdminSessionInfoId();
181+
$this->logoutOtherUserSessions();
182+
}
183+
177184
$this->currentSession = $this->adminSessionInfoFactory->create();
178-
$this->currentSession->load($this->authSession->getAdminSessionInfoId(), 'id');
185+
$this->currentSession->load($adminSessionInfoId, 'id');
179186
}
180187

181188
return $this->currentSession;

app/code/Magento/Security/Test/Unit/Model/AdminSessionsManagerTest.php

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,9 +335,32 @@ public function testCleanExpiredSessions()
335335
*/
336336
public function testGetLogoutReasonMessage($expectedResult, $sessionStatus)
337337
{
338-
$this->adminSessionInfoFactoryMock->expects($this->once())
338+
$this->adminSessionInfoFactoryMock->expects($this->exactly(2))
339339
->method('create')
340340
->willReturn($this->currentSessionMock);
341+
$this->authSessionMock->expects($this->any())
342+
->method('getUser')
343+
->willReturn($this->userMock);
344+
$this->currentSessionMock->expects($this->once())
345+
->method('setData')
346+
->willReturn($this->currentSessionMock);
347+
$this->currentSessionMock->expects($this->once())
348+
->method('save')
349+
->willReturn($this->currentSessionMock);
350+
$this->adminSessionInfoCollectionFactoryMock->expects($this->once())
351+
->method('create')
352+
->willReturn($this->adminSessionInfoCollectionMock);
353+
$this->adminSessionInfoCollectionMock->expects($this->once())->method('filterByUser')
354+
->willReturnSelf();
355+
$this->adminSessionInfoCollectionMock->expects($this->once())
356+
->method('filterExpiredSessions')
357+
->willReturnSelf();
358+
$this->adminSessionInfoCollectionMock->expects($this->once())
359+
->method('loadData')
360+
->willReturnSelf();
361+
$this->adminSessionInfoCollectionMock->expects($this->once())
362+
->method('setDataToAll')
363+
->willReturnSelf();
341364
$this->currentSessionMock->expects($this->once())
342365
->method('getStatus')
343366
->willReturn($sessionStatus);

app/code/Magento/Ui/view/base/web/js/modal/modal.js

Lines changed: 39 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ define([
2424
* Detect browser transition end event.
2525
* @return {String|undefined} - transition event.
2626
*/
27-
var transitionEvent = (function () {
27+
var transitionEvent = (function () {
2828
var transition,
2929
elementStyle = document.createElement('div').style,
3030
transitions = {
@@ -39,7 +39,39 @@ define([
3939
return transitions[transition];
4040
}
4141
}
42-
})();
42+
})(),
43+
44+
/**
45+
* Implementation of zIndex used from jQuery UI
46+
* @param {Element} elem
47+
* @private
48+
*/
49+
getZIndex = function (elem) {
50+
var position, zIndex;
51+
52+
/* eslint-disable max-depth */
53+
while (elem.length && elem[ 0 ] !== document) {
54+
// Ignore z-index if position is set to a value where z-index is ignored by the browser
55+
// This makes behavior of this function consistent across browsers
56+
// WebKit always returns auto if the element is positioned
57+
position = elem.css('position');
58+
59+
if (position === 'absolute' || position === 'relative' || position === 'fixed') {
60+
// IE returns 0 when zIndex is not specified
61+
// other browsers return a string
62+
// we ignore the case of nested elements with an explicit value of 0
63+
zIndex = parseInt(elem.css('zIndex'), 10);
64+
65+
if (!isNaN(zIndex) && zIndex !== 0) {
66+
return zIndex;
67+
}
68+
}
69+
elem = elem.parent();
70+
}
71+
72+
return 0;
73+
/* eslint-enable max-depth */
74+
};
4375

4476
/**
4577
* Modal Window Widget
@@ -341,18 +373,17 @@ define([
341373
* Set z-index and margin for modal and overlay.
342374
*/
343375
_setActive: function () {
344-
var zIndex = this.modal.zIndex(),
376+
var zIndex = getZIndex(this.modal),
345377
baseIndex = zIndex + this._getVisibleCount();
346378

347379
if (this.modal.data('active')) {
348380
return;
349381
}
350-
351382
this.modal.data('active', true);
352383

353-
this.overlay.zIndex(++baseIndex);
354-
this.prevOverlayIndex = this.overlay.zIndex();
355-
this.modal.zIndex(this.overlay.zIndex() + 1);
384+
this.overlay.css('z-index', ++baseIndex);
385+
this.prevOverlayIndex = baseIndex;
386+
this.modal.css('z-index', baseIndex + 1);
356387

357388
if (this._getVisibleSlideCount()) {
358389
this.modal.css('marginLeft', this.options.modalLeftMargin * this._getVisibleSlideCount());
@@ -367,7 +398,7 @@ define([
367398
this.modal.data('active', false);
368399

369400
if (this.overlay) {
370-
this.overlay.zIndex(this.prevOverlayIndex - 1);
401+
this.overlay.css('z-index', this.prevOverlayIndex - 1);
371402
}
372403
},
373404

dev/tests/integration/testsuite/Magento/Backend/Model/Auth/SessionTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ protected function setUp(): void
3939
->setCurrentScope(\Magento\Backend\App\Area\FrontNameResolver::AREA_CODE);
4040
$this->auth = $this->objectManager->create(\Magento\Backend\Model\Auth::class);
4141
$this->authSession = $this->objectManager->create(\Magento\Backend\Model\Auth\Session::class);
42+
$this->authSession->setUser($this->objectManager->create(\Magento\User\Model\User::class));
4243
$this->auth->setAuthStorage($this->authSession);
4344
$this->auth->logout();
4445
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ public function run(array $whiteList)
9999
$settings['standards'] = [$this->rulesetDir];
100100
$settings['extensions'] = $this->extensions;
101101
$settings['reports']['full'] = $this->reportFile;
102+
$settings['reportWidth'] = 120;
102103
$this->wrapper->setSettings($settings);
103104

104105
// phpcs:ignore Magento2.Functions.DiscouragedFunction

dev/tests/static/framework/tests/unit/testsuite/Magento/TestFramework/CodingStandard/Tool/CodeSnifferTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class CodeSnifferTest extends \PHPUnit\Framework\TestCase
2828
const RULE_SET = 'some/ruleset/directory';
2929

3030
/**
31-
* Report file
31+
* Report file path
3232
*/
3333
const REPORT_FILE = 'some/report/file.xml';
3434

@@ -52,6 +52,7 @@ public function testRun()
5252
'standards' => [self::RULE_SET],
5353
'extensions' => $extensions,
5454
'reports' => ['full' => self::REPORT_FILE],
55+
'reportWidth' => 120
5556
];
5657

5758
$this->_tool->setExtensions($extensions);

dev/tests/static/testsuite/Magento/Test/Html/LiveCodeTest.php

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
namespace Magento\Test\Html;
88

9+
use Magento\Framework\App\Utility\Files;
910
use Magento\TestFramework\CodingStandard\Tool\CodeSniffer;
1011
use Magento\Test\Php\LiveCodeTest as PHPCodeTest;
1112
use Magento\TestFramework\CodingStandard\Tool\CodeSniffer\Wrapper;
@@ -46,12 +47,33 @@ public function testCodeStyle(): void
4647
$reportFile = self::$reportDir . '/html_report.txt';
4748
$codeSniffer = new CodeSniffer('Magento', $reportFile, new Wrapper());
4849
$codeSniffer->setExtensions([self::FILE_EXTENSION]);
49-
$result = $codeSniffer->run(PHPCodeTest::getWhitelist([self::FILE_EXTENSION], __DIR__, __DIR__));
50+
$fileList = $this->isFullScan() ? array_column(Files::init()->getStaticHtmlFiles(), '0')
51+
: PHPCodeTest::getWhitelist([self::FILE_EXTENSION], __DIR__, __DIR__);
52+
$result = $codeSniffer->run($fileList);
5053
$report = file_exists($reportFile) ? file_get_contents($reportFile) : '';
5154
$this->assertEquals(
5255
0,
5356
$result,
5457
"PHP Code Sniffer detected {$result} violation(s): " . PHP_EOL . $report
5558
);
5659
}
60+
61+
/**
62+
* Returns whether a full scan was requested.
63+
*
64+
* This can be set in the `phpunit.xml` used to run these test cases, by setting the constant
65+
* `TESTCODESTYLE_IS_FULL_SCAN` to `1`, e.g.:
66+
* ```xml
67+
* <php>
68+
* <!-- TESTCODESTYLE_IS_FULL_SCAN - specify if full scan should be performed for test code style test -->
69+
* <const name="TESTCODESTYLE_IS_FULL_SCAN" value="0"/>
70+
* </php>
71+
* ```
72+
*
73+
* @return bool
74+
*/
75+
private function isFullScan(): bool
76+
{
77+
return defined('TESTCODESTYLE_IS_FULL_SCAN') && TESTCODESTYLE_IS_FULL_SCAN === '1';
78+
}
5779
}

0 commit comments

Comments
 (0)