Skip to content

Commit 70115d6

Browse files
Merge branch '2.4.8-beta1-develop' into ACP2E-3188
2 parents 6920108 + 2bffa45 commit 70115d6

File tree

3,130 files changed

+39577
-16220
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

3,130 files changed

+39577
-16220
lines changed

.editorconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ trim_trailing_whitespace = false
1414
[*.{yml,yaml,json}]
1515
indent_size = 2
1616

17-
[{composer, auth}.json]
17+
[{composer,auth}.json]
1818
indent_size = 4
1919

2020
[db_schema_whitelist.json]
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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\AdminNotification\Block\Grid\MassAction;
9+
10+
use Magento\AdminNotification\Controller\Adminhtml\Notification\MarkAsRead;
11+
use Magento\Backend\Block\Widget\Grid\Massaction\VisibilityCheckerInterface;
12+
use Magento\Framework\AuthorizationInterface;
13+
14+
/**
15+
* Class checks if mark as read action can be displayed on massaction list
16+
*/
17+
class MarkAsReadVisibility implements VisibilityCheckerInterface
18+
{
19+
/**
20+
* @var AuthorizationInterface
21+
*/
22+
private $authorization;
23+
24+
/**
25+
* @param AuthorizationInterface $authorizationInterface
26+
*/
27+
public function __construct(AuthorizationInterface $authorizationInterface)
28+
{
29+
$this->authorization = $authorizationInterface;
30+
}
31+
32+
/**
33+
* @inheritdoc
34+
*/
35+
public function isVisible()
36+
{
37+
return $this->authorization->isAllowed(MarkAsRead::ADMIN_RESOURCE);
38+
}
39+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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\AdminNotification\Block\Grid\MassAction;
9+
10+
use Magento\AdminNotification\Controller\Adminhtml\Notification\Remove;
11+
use Magento\Backend\Block\Widget\Grid\Massaction\VisibilityCheckerInterface;
12+
use Magento\Framework\AuthorizationInterface;
13+
14+
/**
15+
* Class checks if remove action can be displayed on massaction list
16+
*/
17+
class RemoveVisibility implements VisibilityCheckerInterface
18+
{
19+
/**
20+
* @var AuthorizationInterface
21+
*/
22+
private $authorization;
23+
24+
/**
25+
* @param AuthorizationInterface $authorizationInterface
26+
*/
27+
public function __construct(AuthorizationInterface $authorizationInterface)
28+
{
29+
$this->authorization = $authorizationInterface;
30+
}
31+
32+
/**
33+
* @inheritdoc
34+
*/
35+
public function isVisible()
36+
{
37+
return $this->authorization->isAllowed(Remove::ADMIN_RESOURCE);
38+
}
39+
}

app/code/Magento/AdminNotification/Block/Grid/Renderer/Actions.php

Lines changed: 30 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
<?php
2-
declare(strict_types=1);
3-
42
/**
5-
* Adminhtml AdminNotification Severity Renderer
6-
*
73
* Copyright © Magento, Inc. All rights reserved.
84
* See COPYING.txt for license details.
95
*/
6+
declare(strict_types=1);
107

118
namespace Magento\AdminNotification\Block\Grid\Renderer;
129

10+
use Magento\AdminNotification\Controller\Adminhtml\Notification\MarkAsRead;
11+
use Magento\AdminNotification\Controller\Adminhtml\Notification\Remove;
1312
use Magento\Backend\Block\Context;
1413
use Magento\Backend\Block\Widget\Grid\Column\Renderer\AbstractRenderer;
1514
use Magento\Framework\App\ActionInterface;
@@ -45,33 +44,41 @@ public function __construct(Context $context, Data $urlHelper, array $data = [])
4544
*/
4645
public function render(DataObject $row)
4746
{
48-
$readDetailsHtml = $row->getUrl() ? '<a class="action-details" target="_blank" href="' .
47+
$readDetailsHtml = $row->getUrl() ?
48+
'<a class="action-details" target="_blank" href="' .
4949
$this->escapeUrl($row->getUrl())
5050
. '">' .
5151
__('Read Details') . '</a>' : '';
5252

53-
$markAsReadHtml = !$row->getIsRead() ? '<a class="action-mark" href="' . $this->getUrl(
54-
'*/*/markAsRead/',
55-
['_current' => true, 'id' => $row->getNotificationId()]
56-
) . '">' . __(
57-
'Mark as Read'
58-
) . '</a>' : '';
53+
$markAsReadHtml = !$row->getIsRead()
54+
&& $this->_authorization->isAllowed(MarkAsRead::ADMIN_RESOURCE) ?
55+
'<a class="action-mark" href="' . $this->escapeUrl($this->getUrl(
56+
'*/*/markAsRead/',
57+
['_current' => true, 'id' => $row->getNotificationId()]
58+
)) . '">' . __(
59+
'Mark as Read'
60+
) . '</a>' : '';
61+
62+
$removeUrl = $this->getUrl(
63+
'*/*/remove/',
64+
[
65+
'_current' => true,
66+
'id' => $row->getNotificationId(),
67+
ActionInterface::PARAM_NAME_URL_ENCODED => $this->_urlHelper->getEncodedUrl()
68+
]
69+
);
70+
71+
$removeHtml = $this->_authorization->isAllowed(Remove::ADMIN_RESOURCE) ?
72+
'<a class="action-delete" href="'
73+
. $this->escapeUrl($removeUrl)
74+
.'" onClick="deleteConfirm('. __('\'Are you sure?\'') .', this.href); return false;">'
75+
. __('Remove') . '</a>' : '';
5976

60-
$encodedUrl = $this->_urlHelper->getEncodedUrl();
6177
return sprintf(
62-
'%s%s<a class="action-delete" href="%s" onClick="deleteConfirm(\'%s\', this.href); return false;">%s</a>',
78+
'%s%s%s',
6379
$readDetailsHtml,
6480
$markAsReadHtml,
65-
$this->getUrl(
66-
'*/*/remove/',
67-
[
68-
'_current' => true,
69-
'id' => $row->getNotificationId(),
70-
ActionInterface::PARAM_NAME_URL_ENCODED => $encodedUrl
71-
]
72-
),
73-
__('Are you sure?'),
74-
__('Remove')
81+
$removeHtml,
7582
);
7683
}
7784
}

app/code/Magento/AdminNotification/Controller/Adminhtml/Notification/AjaxMarkAsRead.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
declare(strict_types=1);
7+
68
namespace Magento\AdminNotification\Controller\Adminhtml\Notification;
79

810
use Magento\AdminNotification\Controller\Adminhtml\Notification;
@@ -16,6 +18,13 @@
1618
*/
1719
class AjaxMarkAsRead extends Notification implements HttpPostActionInterface
1820
{
21+
/**
22+
* Authorization level of a basic admin session
23+
*
24+
* @see _isAllowed()
25+
*/
26+
public const ADMIN_RESOURCE = 'Magento_AdminNotification::mark_as_read';
27+
1928
/**
2029
* @var NotificationService
2130
*/

app/code/Magento/AdminNotification/Test/Unit/Block/Grid/Renderer/ActionsTest.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Magento\AdminNotification\Block\Grid\Renderer\Actions;
1616
use Magento\Backend\Block\Context;
1717
use Magento\Framework\DataObject;
18+
use Magento\Framework\AuthorizationInterface;
1819
use Magento\Framework\Escaper;
1920
use Magento\Framework\Url\Helper\Data;
2021
use Magento\Framework\UrlInterface;
@@ -35,16 +36,23 @@ protected function setUp(): void
3536

3637
/** @var Escaper|MockObject $escaperMock */
3738
$escaperMock = $this->createMock(Escaper::class);
38-
$escaperMock->expects($this->once())->method('escapeUrl')->willReturn('https://magento.com');
39+
$escaperMock->expects($this->atLeastOnce())->method('escapeUrl')->willReturn('https://magento.com');
40+
41+
/** @var AuthorizationInterface|MockObject $authorizationMock */
42+
$authorizationMock = $this->getMockForAbstractClass(AuthorizationInterface::class);
43+
$authorizationMock->expects($this->atLeastOnce())
44+
->method('isAllowed')
45+
->willReturn(true);
3946

4047
/** @var UrlInterface|MockObject $urlBuilder */
4148
$urlBuilder = $this->getMockForAbstractClass(UrlInterface::class);
4249
$urlBuilder->expects($this->once())->method('getUrl')->willReturn('http://magento.com');
4350

4451
/** @var Context|MockObject $contextMock */
4552
$contextMock = $this->createMock(Context::class);
46-
$contextMock->expects($this->once())->method('getEscaper')->willReturn($escaperMock);
53+
$contextMock->expects($this->atLeastOnce())->method('getEscaper')->willReturn($escaperMock);
4754
$contextMock->expects($this->once())->method('getUrlBuilder')->willReturn($urlBuilder);
55+
$contextMock->expects($this->once())->method('getAuthorization')->willReturn($authorizationMock);
4856

4957
/** @var Data|MockObject $urlHelperMock */
5058
$urlHelperMock = $this->createMock(Data::class);
@@ -65,7 +73,7 @@ public function testShouldRenderMessageWhenUrlIsGiven() : void
6573
// Ignoring Code Style at this point due to the long HEREDOC
6674
// phpcs:disable
6775
$expected = <<<HTML
68-
<a class="action-details" target="_blank" href="https://magento.com">Read Details</a><a class="action-delete" href="http://magento.com" onClick="deleteConfirm('Are you sure?', this.href); return false;">Remove</a>
76+
<a class="action-details" target="_blank" href="https://magento.com">Read Details</a><a class="action-delete" href="https://magento.com" onClick="deleteConfirm('Are you sure?', this.href); return false;">Remove</a>
6977
HTML;
7078
// phpcs:enable
7179

app/code/Magento/AdminNotification/Test/Unit/Observer/PredispatchAdminActionControllerObserverTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,17 +68,17 @@ protected function setUp(): void
6868

6969
$this->backendAuthSessionMock = $this->getMockBuilder(Session::class)
7070
->disableOriginalConstructor()
71-
->setMethods(['isLoggedIn'])
71+
->onlyMethods(['isLoggedIn'])
7272
->getMock();
7373

7474
$this->feedMock = $this->getMockBuilder(Feed::class)
7575
->disableOriginalConstructor()
76-
->setMethods(['checkUpdate'])
76+
->onlyMethods(['checkUpdate'])
7777
->getMock();
7878

7979
$this->feedFactoryMock = $this->getMockBuilder(FeedFactory::class)
8080
->disableOriginalConstructor()
81-
->setMethods(['create'])
81+
->onlyMethods(['create'])
8282
->getMock();
8383

8484
$this->observer = $this->objectManager->getObject(

app/code/Magento/AdminNotification/view/adminhtml/layout/adminhtml_notification_block.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,13 @@
6161
<item name="mark_as_read" xsi:type="array">
6262
<item name="label" xsi:type="string" translate="true">Mark as Read</item>
6363
<item name="url" xsi:type="string">*/*/massMarkAsRead</item>
64+
<item name="visible" xsi:type="object">Magento\AdminNotification\Block\Grid\MassAction\MarkAsReadVisibility</item>
6465
</item>
6566
<item name="remove" xsi:type="array">
6667
<item name="label" xsi:type="string" translate="true">Remove</item>
6768
<item name="url" xsi:type="string">*/*/massRemove</item>
6869
<item name="confirm" xsi:type="string" translate="true">Are you sure?</item>
70+
<item name="visible" xsi:type="object">Magento\AdminNotification\Block\Grid\MassAction\RemoveVisibility</item>
6971
</item>
7072
</argument>
7173
</arguments>

app/code/Magento/AdvancedPricingImportExport/Test/Unit/Model/Import/AdvancedPricing/Validator/TierPriceTest.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ protected function setUp(): void
5454
{
5555
$this->groupRepository = $this->getMockBuilder(GroupRepositoryInterface::class)
5656
->disableOriginalConstructor()
57-
->setMethods(['getList'])
57+
->onlyMethods(['getList'])
5858
->getMockForAbstractClass();
5959

6060
$this->searchCriteriaBuilder = $this->createMock(SearchCriteriaBuilder::class);
@@ -65,7 +65,7 @@ protected function setUp(): void
6565
$this->tierPrice = $this->getMockBuilder(
6666
TierPrice::class
6767
)
68-
->setMethods(['isValidValueAndLength', 'hasEmptyColumns', '_addMessages'])
68+
->onlyMethods(['isValidValueAndLength', 'hasEmptyColumns', '_addMessages'])
6969
->setConstructorArgs([$this->groupRepository, $this->searchCriteriaBuilder, $this->storeResolver])
7070
->getMock();
7171
}
@@ -87,7 +87,7 @@ public function testInitInternalCalls()
8787

8888
$groupTest = $this->getMockBuilder(GroupInterface::class)
8989
->disableOriginalConstructor()
90-
->setMethods(['getCode', 'getId'])
90+
->onlyMethods(['getCode', 'getId'])
9191
->getMockForAbstractClass();
9292
$groupTest->expects($this->once())->method('getCode');
9393
$groupTest->method('getId');
@@ -114,7 +114,7 @@ public function testInitAddToCustomerGroups()
114114

115115
$groupTest = $this->getMockBuilder(GroupInterface::class)
116116
->disableOriginalConstructor()
117-
->setMethods(['getCode', 'getId'])
117+
->onlyMethods(['getCode', 'getId'])
118118
->getMockForAbstractClass();
119119

120120
$expectedCode = 'code';
@@ -184,7 +184,7 @@ public function testIsValidAddMessagesCall($value, $hasEmptyColumns, $customerGr
184184

185185
$groupTest = $this->getMockBuilder(GroupInterface::class)
186186
->disableOriginalConstructor()
187-
->setMethods(['getCode', 'getId'])
187+
->onlyMethods(['getCode', 'getId'])
188188
->getMockForAbstractClass();
189189
$groupTest->expects($this->once())->method('getCode');
190190
$groupTest->method('getId');
@@ -198,7 +198,7 @@ public function testIsValidAddMessagesCall($value, $hasEmptyColumns, $customerGr
198198
/**
199199
* @return array
200200
*/
201-
public function isValidResultFalseDataProvider()
201+
public static function isValidResultFalseDataProvider()
202202
{
203203
return [
204204
// First if condition cases.
@@ -306,7 +306,7 @@ public function isValidResultFalseDataProvider()
306306
/**
307307
* @return array
308308
*/
309-
public function isValidAddMessagesCallDataProvider()
309+
public static function isValidAddMessagesCallDataProvider()
310310
{
311311
return [
312312
// First if condition cases.

app/code/Magento/AdvancedPricingImportExport/Test/Unit/Model/Import/AdvancedPricing/Validator/TierPriceTypeTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public function testIsValid(array $value, $expectedResult)
5151
*
5252
* @return array
5353
*/
54-
public function isValidDataProvider()
54+
public static function isValidDataProvider()
5555
{
5656
return [
5757
[

app/code/Magento/AdvancedPricingImportExport/Test/Unit/Model/Import/AdvancedPricing/Validator/WebsiteTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class WebsiteTest extends TestCase
4040
protected function setUp(): void
4141
{
4242
$this->webSiteModel = $this->getMockBuilder(Website::class)
43-
->setMethods(['getBaseCurrency'])
43+
->onlyMethods(['getBaseCurrency'])
4444
->disableOriginalConstructor()
4545
->getMock();
4646
$this->storeResolver = $this->createPartialMock(
@@ -56,7 +56,7 @@ protected function setUp(): void
5656
$this->website = $this->getMockBuilder(
5757
WebsiteValidator::class
5858
)
59-
->setMethods(['getAllWebsitesValue', '_clearMessages', '_addMessages'])
59+
->onlyMethods(['getAllWebsitesValue', '_clearMessages', '_addMessages'])
6060
->setConstructorArgs([$this->storeResolver, $this->webSiteModel, $this->currencyResolver])
6161
->getMock();
6262
}
@@ -121,7 +121,7 @@ public function testGetAllWebsitesValue()
121121
$websiteString = $this->getMockBuilder(
122122
WebsiteValidator::class
123123
)
124-
->setMethods(['_clearMessages', '_addMessages'])
124+
->onlyMethods(['_clearMessages', '_addMessages'])
125125
->setConstructorArgs([$this->storeResolver, $this->webSiteModel, $this->currencyResolver])
126126
->getMock();
127127
$result = $websiteString->getAllWebsitesValue();
@@ -132,7 +132,7 @@ public function testGetAllWebsitesValue()
132132
/**
133133
* @return array
134134
*/
135-
public function isValidReturnDataProvider()
135+
public static function isValidReturnDataProvider()
136136
{
137137
return [
138138
// False cases.

app/code/Magento/AdvancedPricingImportExport/Test/Unit/Model/Import/AdvancedPricing/ValidatorTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ protected function setUp(): void
4444
$this->validator = $this->getMockBuilder(
4545
\Magento\AdvancedPricingImportExport\Model\Import\AdvancedPricing\Validator::class
4646
)
47-
->setMethods(['_clearMessages', '_addMessages'])
47+
->onlyMethods(['_clearMessages', '_addMessages'])
4848
->setConstructorArgs([$this->validators])
4949
->getMock();
5050
}
@@ -84,7 +84,7 @@ public function testInit()
8484
/**
8585
* @return array
8686
*/
87-
public function isValidDataProvider()
87+
public static function isValidDataProvider()
8888
{
8989
return [
9090
[

0 commit comments

Comments
 (0)