Skip to content

Commit 3c84234

Browse files
committed
Merge remote-tracking branch 'mainline/2.4-develop' into 2.4-develop-pr13
2 parents 8c308c6 + 9e9703a commit 3c84234

File tree

19 files changed

+557
-175
lines changed

19 files changed

+557
-175
lines changed

app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/AbstractRenderer.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
use Magento\Framework\DataObject;
1010

1111
/**
12+
* Produce html output using the given data source.
13+
*
14+
* phpcs:disable Magento2.Classes.AbstractApi
1215
* Backend grid item abstract renderer
1316
* @api
1417
* @SuppressWarnings(PHPMD.NumberOfChildren)
@@ -53,7 +56,7 @@ public function getColumn()
5356
* Renders grid column
5457
*
5558
* @param DataObject $row
56-
* @return string
59+
* @return string
5760
*/
5861
public function render(DataObject $row)
5962
{
@@ -62,7 +65,7 @@ public function render(DataObject $row)
6265
$result .= $this->getColumn()->getEditOnly() ? ''
6366
: '<span class="admin__grid-control-value">' . $this->_getValue($row) . '</span>';
6467

65-
return $result . $this->_getInputValueElement($row) . '</div>' ;
68+
return $result . $this->_getInputValueElement($row) . '</div>';
6669
}
6770
return $this->_getValue($row);
6871
}
@@ -90,6 +93,7 @@ protected function _getValue(DataObject $row)
9093
if (is_string($getter)) {
9194
return $row->{$getter}();
9295
} elseif (is_callable($getter)) {
96+
//phpcs:ignore Magento2.Functions.DiscouragedFunction
9397
return call_user_func($getter, $row);
9498
}
9599
return '';

app/code/Magento/Backend/etc/adminhtml/system.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,15 +115,15 @@
115115
<label>Enable Template Path Hints for Storefront</label>
116116
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
117117
</field>
118-
<field id="template_hints_storefront_show_with_parameter" translate="label" type="select" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="1">
118+
<field id="template_hints_storefront_show_with_parameter" translate="label comment" type="select" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="1">
119119
<label>Enable Hints for Storefront with URL Parameter</label>
120120
<depends>
121121
<field id="*/*/template_hints_storefront">1</field>
122122
</depends>
123123
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
124124
<comment>Use URL parameter to enable template path hints for Storefront</comment>
125125
</field>
126-
<field id="template_hints_parameter_value" translate="label" type="text" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1">
126+
<field id="template_hints_parameter_value" translate="label comment" type="text" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1">
127127
<label>Parameter Value</label>
128128
<depends>
129129
<field id="*/*/template_hints_storefront">1</field>

app/code/Magento/Backend/i18n/en_US.csv

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -461,3 +461,5 @@ Pagination,Pagination
461461
"Alternative text for the next pages link in the pagination menu. If empty, default arrow image is used.","Alternative text for the next pages link in the pagination menu. If empty, default arrow image is used."
462462
"Anchor Text for Next","Anchor Text for Next"
463463
"Theme Name","Theme Name"
464+
"Use URL parameter to enable template path hints for Storefront","Use URL parameter to enable template path hints for Storefront"
465+
"Add the following parameter to the URL to show template hints ?templatehints=[parameter_value]","Add the following parameter to the URL to show template hints ?templatehints=[parameter_value]"

app/code/Magento/CatalogGraphQl/DataProvider/Product/SearchCriteriaBuilder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ private function addVisibilityFilter(SearchCriteriaInterface $searchCriteria, bo
123123
{
124124
if ($isFilter && $isSearch) {
125125
// Index already contains products filtered by visibility: catalog, search, both
126-
return ;
126+
return;
127127
}
128128
$visibilityIds = $isSearch
129129
? $this->visibility->getVisibleInSearchIds()

app/code/Magento/Csp/Model/Collector/CspWhitelistXml/SchemaLocator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class SchemaLocator implements SchemaLocatorInterface
2222
*
2323
* @var string
2424
*/
25-
private $schema ;
25+
private $schema;
2626

2727
/**
2828
* @param Reader $moduleReader
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
declare(strict_types=1);
8+
9+
namespace Magento\Directory\Test\Unit\Block\Adminhtml\Frontend\Currency;
10+
11+
use Magento\Directory\Block\Adminhtml\Frontend\Currency\Base;
12+
use Magento\Framework\App\Config\ScopeConfigInterface;
13+
use Magento\Framework\App\RequestInterface;
14+
use Magento\Framework\Data\Form\Element\AbstractElement;
15+
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
16+
use Magento\Store\Model\Store;
17+
use PHPUnit\Framework\MockObject\MockObject;
18+
use PHPUnit\Framework\TestCase;
19+
20+
/**
21+
* Unit test for \Magento\Directory\Block\Adminhtml\Frontend\Currency\Base
22+
*/
23+
class BaseTest extends TestCase
24+
{
25+
const STUB_WEBSITE_PARAM = 'website';
26+
27+
/**
28+
* @var AbstractElement|MockObject
29+
*/
30+
private $elementMock;
31+
32+
/**
33+
* @var RequestInterface|MockObject
34+
*/
35+
private $requestMock;
36+
37+
/**
38+
* @var ScopeConfigInterface|MockObject
39+
*/
40+
private $scopeConfigMock;
41+
42+
/**
43+
* @var Base
44+
*/
45+
private $baseCurrency;
46+
47+
/**
48+
* @inheritDoc
49+
*/
50+
protected function setUp()
51+
{
52+
$this->elementMock = $this->createMock(AbstractElement::class);
53+
$this->scopeConfigMock = $this->createMock(ScopeConfigInterface::class);
54+
$this->requestMock = $this->getMockBuilder(RequestInterface::class)
55+
->disableOriginalConstructor()
56+
->setMethods(['getParam'])
57+
->getMockForAbstractClass();
58+
59+
$this->baseCurrency = (new ObjectManagerHelper($this))->getObject(
60+
Base::class,
61+
['_request' => $this->requestMock, '_scopeConfig' => $this->scopeConfigMock]
62+
);
63+
}
64+
65+
/**
66+
* Test case when no Website param provided
67+
*/
68+
public function testRenderWithoutWebsiteParam()
69+
{
70+
$this->requestMock->expects($this->once())
71+
->method('getParam')
72+
->willReturn('');
73+
$this->scopeConfigMock->expects($this->never())->method('getValue');
74+
75+
$result = $this->baseCurrency->render(($this->elementMock));
76+
$this->assertFalse(empty($result), 'Result should not be empty.');
77+
}
78+
79+
/**
80+
* Test case when Website param is provided and Price Scope is set to Global
81+
*/
82+
public function testRenderWhenWebsiteParamSetAndPriceScopeGlobal()
83+
{
84+
$this->requestMock->expects($this->once())
85+
->method('getParam')
86+
->willReturn(self::STUB_WEBSITE_PARAM);
87+
$this->scopeConfigMock->expects($this->once())
88+
->method('getValue')
89+
->willReturn(Store::PRICE_SCOPE_GLOBAL);
90+
91+
$result = $this->baseCurrency->render(($this->elementMock));
92+
$this->assertEquals('', $result, 'Result should be an empty string.');
93+
}
94+
95+
/**
96+
* Test case when Website param is provided and Price Scope is not Global
97+
*/
98+
public function testRenderWhenWebsiteParamSetAndPriceScopeOther()
99+
{
100+
$this->requestMock->expects($this->once())
101+
->method('getParam')
102+
->willReturn(self::STUB_WEBSITE_PARAM);
103+
$this->scopeConfigMock->expects($this->once())
104+
->method('getValue')
105+
->willReturn(Store::PRICE_SCOPE_WEBSITE);
106+
107+
$result = $this->baseCurrency->render(($this->elementMock));
108+
$this->assertFalse(empty($result), 'Result should not be empty.');
109+
}
110+
}
Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,25 @@
11
<?php
22
/**
3-
*
43
* Copyright © Magento, Inc. All rights reserved.
54
* See COPYING.txt for license details.
65
*/
6+
declare(strict_types=1);
7+
78
namespace Magento\PageCache\Observer;
89

9-
use Magento\Framework\App\ObjectManager;
10+
use Magento\Framework\App\PageCache\Cache;
11+
use Magento\Framework\Event\Observer;
1012
use Magento\Framework\Event\ObserverInterface;
13+
use Magento\PageCache\Model\Cache\Type;
14+
use Magento\PageCache\Model\Config;
1115

16+
/**
17+
* Observer used to flush all caches with built-in full page cache
18+
*/
1219
class FlushAllCache implements ObserverInterface
1320
{
1421
/**
15-
* @var \Magento\Framework\App\PageCache\Cache
22+
* @var Cache
1623
*
1724
* @deprecated 100.1.0
1825
*/
@@ -21,48 +28,42 @@ class FlushAllCache implements ObserverInterface
2128
/**
2229
* Application config object
2330
*
24-
* @var \Magento\PageCache\Model\Config
31+
* @var Config
2532
*/
2633
protected $_config;
2734

2835
/**
29-
* @var \Magento\PageCache\Model\Cache\Type
36+
* @var Type
3037
*/
3138
private $fullPageCache;
3239

3340
/**
34-
* @param \Magento\PageCache\Model\Config $config
35-
* @param \Magento\Framework\App\PageCache\Cache $cache
41+
* @param Config $config
42+
* @param Cache $cache
43+
* @param Type $fullPageCache
3644
*/
37-
public function __construct(\Magento\PageCache\Model\Config $config, \Magento\Framework\App\PageCache\Cache $cache)
38-
{
45+
public function __construct(
46+
Config $config,
47+
Cache $cache,
48+
Type $fullPageCache
49+
) {
3950
$this->_config = $config;
4051
$this->_cache = $cache;
52+
$this->fullPageCache = $fullPageCache;
4153
}
4254

4355
/**
4456
* Flash Built-In cache
45-
* @param \Magento\Framework\Event\Observer $observer
57+
*
58+
* @param Observer $observer
59+
*
4660
* @return void
4761
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
4862
*/
49-
public function execute(\Magento\Framework\Event\Observer $observer)
50-
{
51-
if ($this->_config->getType() == \Magento\PageCache\Model\Config::BUILT_IN) {
52-
$this->getCache()->clean();
53-
}
54-
}
55-
56-
/**
57-
* TODO: Workaround to support backwards compatibility, will rework to use Dependency Injection in MAGETWO-49547
58-
*
59-
* @return \Magento\PageCache\Model\Cache\Type
60-
*/
61-
private function getCache()
63+
public function execute(Observer $observer)
6264
{
63-
if (!$this->fullPageCache) {
64-
$this->fullPageCache = ObjectManager::getInstance()->get(\Magento\PageCache\Model\Cache\Type::class);
65+
if ($this->_config->getType() == Config::BUILT_IN) {
66+
$this->fullPageCache->clean();
6567
}
66-
return $this->fullPageCache;
6768
}
6869
}

0 commit comments

Comments
 (0)