Skip to content

Commit 6df4b3c

Browse files
Merge pull request magento#1418 from magento-okapis/Okapis-PR-8-15
[okapis] Bugfix PR
2 parents e2473ec + 2cf6cc7 commit 6df4b3c

File tree

29 files changed

+545
-202
lines changed

29 files changed

+545
-202
lines changed

app/code/Magento/Backend/Block/Template.php

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,22 @@ public function getFormKey()
8585
*
8686
* @param string $moduleName Full module name
8787
* @return boolean
88-
* @deprecated 100.2.0 Magento does not support custom disabling/enabling module output since 2.2.0 version
89-
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
88+
* @deprecated 100.2.0 Magento does not support disabling/enabling modules output from the Admin Panel since 2.2.0
89+
* version. Module output can still be enabled/disabled in configuration files. However, this functionality should
90+
* not be used in future development. Module design should explicitly state dependencies to avoid requiring output
91+
* disabling. This functionality will temporarily be kept in Magento core, as there are unresolved modularity
92+
* issues that will be addressed in future releases.
9093
*/
9194
public function isOutputEnabled($moduleName = null)
9295
{
93-
return true;
96+
if ($moduleName === null) {
97+
$moduleName = $this->getModuleName();
98+
}
99+
100+
return !$this->_scopeConfig->isSetFlag(
101+
'advanced/modules_disable_output/' . $moduleName,
102+
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
103+
);
94104
}
95105

96106
/**

app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Options/AjaxTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,12 @@ public function testToHtml()
5858
->getMock();
5959
$eventManager->expects($this->exactly(2))->method('dispatch')->will($this->returnValue(true));
6060

61+
$scopeConfig = $this->getMockBuilder(\Magento\Framework\App\Config::class)
62+
->setMethods(['getValue'])
63+
->disableOriginalConstructor()->getMock();
64+
$scopeConfig->expects($this->once())->method('getValue')->withAnyParameters()
65+
->will($this->returnValue(false));
66+
6167
$product = $this->getMockBuilder(\Magento\Catalog\Model\Product::class)->disableOriginalConstructor()
6268
->setMethods(['setStoreId', 'load', 'getId', '__wakeup', '__sleep'])
6369
->getMock();
@@ -90,6 +96,8 @@ public function testToHtml()
9096

9197
$this->context->expects($this->once())->method('getEventManager')
9298
->will($this->returnValue($eventManager));
99+
$this->context->expects($this->once())->method('getScopeConfig')
100+
->will($this->returnValue($scopeConfig));
93101
$this->context->expects($this->once())->method('getLayout')
94102
->will($this->returnValue($layout));
95103
$this->context->expects($this->once())->method('getRequest')

app/code/Magento/Catalog/Test/Unit/Block/Product/Widget/NewWidgetTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,8 @@ protected function generalGetProductCollection()
186186
{
187187
$this->eventManager->expects($this->exactly(2))->method('dispatch')
188188
->will($this->returnValue(true));
189+
$this->scopeConfig->expects($this->once())->method('getValue')->withAnyParameters()
190+
->willReturn(false);
189191
$this->cacheState->expects($this->atLeastOnce())->method('isEnabled')->withAnyParameters()
190192
->willReturn(false);
191193
$this->catalogConfig->expects($this->once())->method('getProductAttributes')

app/code/Magento/CatalogSearch/Model/Layer/Filter/Price.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,9 @@ public function getCurrencyRate()
175175
*/
176176
protected function _renderRangeLabel($fromPrice, $toPrice)
177177
{
178+
$fromPrice = empty($fromPrice) ? 0 : $fromPrice * $this->getCurrencyRate();
179+
$toPrice = empty($toPrice) ? $toPrice : $toPrice * $this->getCurrencyRate();
180+
178181
$formattedFromPrice = $this->priceCurrency->format($fromPrice);
179182
if ($toPrice === '') {
180183
return __('%1 and above', $formattedFromPrice);
@@ -261,10 +264,7 @@ private function prepareData($key, $count)
261264
if ($to == '*') {
262265
$to = $this->getTo($to);
263266
}
264-
$label = $this->_renderRangeLabel(
265-
empty($from) ? 0 : $from * $this->getCurrencyRate(),
266-
empty($to) ? $to : $to * $this->getCurrencyRate()
267-
);
267+
$label = $this->_renderRangeLabel($from, $to);
268268
$value = $from . '-' . $to . $this->dataProvider->getAdditionalRequestData();
269269

270270
$data = [

app/code/Magento/CatalogSearch/Test/Unit/Model/Layer/Filter/PriceTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,7 @@ function ($field) use ($requestVar, $priceId) {
225225
->with('price')
226226
->will($this->returnSelf());
227227

228+
$this->target->setCurrencyRate(1);
228229
$this->target->apply($this->request);
229230
}
230231

app/code/Magento/Checkout/Test/Unit/Block/Cart/Item/Renderer/ActionsTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ public function testToHtml()
6868
$childNameTwo = 'child.2';
6969
$childNames = [$childNameOne, $childNameTwo];
7070

71+
$this->scopeConfigMock->expects($this->once())
72+
->method('getValue')
73+
->willReturn(false);
74+
7175
/**
7276
* @var Item|\PHPUnit_Framework_MockObject_MockObject $itemMock
7377
*/

app/code/Magento/Config/Block/System/Config/Form/Fieldset/Modules/DisableOutput.php

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,33 +10,37 @@
1010
* on the store settings page.
1111
*
1212
* @method \Magento\Config\Block\System\Config\Form getForm()
13-
* @deprecated 100.2.0 Magento does not support custom disabling/enabling module output since 2.2.0 version
13+
* @deprecated 100.2.0 Magento does not support disabling/enabling modules output from the Admin Panel since 2.2.0
14+
* version. Module output can still be enabled/disabled in configuration files. However, this functionality should
15+
* not be used in future development. Module design should explicitly state dependencies to avoid requiring output
16+
* disabling. This functionality will temporarily be kept in Magento core, as there are unresolved modularity
17+
* issues that will be addressed in future releases.
1418
* @api
1519
* @since 100.0.2
1620
*/
1721
class DisableOutput extends \Magento\Config\Block\System\Config\Form\Fieldset
1822
{
1923
/**
2024
* @var \Magento\Framework\DataObject
21-
* @deprecated 100.2.0 Magento does not support custom disabling/enabling module output since 2.2.0 version
25+
* @deprecated 100.2.0
2226
*/
2327
protected $_dummyElement;
2428

2529
/**
2630
* @var \Magento\Config\Block\System\Config\Form\Field
27-
* @deprecated 100.2.0 Magento does not support custom disabling/enabling module output since 2.2.0 version
31+
* @deprecated 100.2.0
2832
*/
2933
protected $_fieldRenderer;
3034

3135
/**
3236
* @var array
33-
* @deprecated 100.2.0 Magento does not support custom disabling/enabling module output since 2.2.0 version
37+
* @deprecated 100.2.0
3438
*/
3539
protected $_values;
3640

3741
/**
3842
* @var \Magento\Framework\Module\ModuleListInterface
39-
* @deprecated 100.2.0 Magento does not support custom disabling/enabling module output since 2.2.0 version
43+
* @deprecated 100.2.0
4044
*/
4145
protected $_moduleList;
4246

@@ -60,7 +64,11 @@ public function __construct(
6064

6165
/**
6266
* {@inheritdoc}
63-
* @deprecated 100.2.0 Magento does not support custom disabling/enabling module output since 2.2.0 version
67+
* @deprecated 100.2.0 Magento does not support disabling/enabling modules output from the Admin Panel since 2.2.0
68+
* version. Module output can still be enabled/disabled in configuration files. However, this functionality should
69+
* not be used in future development. Module design should explicitly state dependencies to avoid requiring output
70+
* disabling. This functionality will temporarily be kept in Magento core, as there are unresolved modularity
71+
* issues that will be addressed in future releases.
6472
*/
6573
public function render(\Magento\Framework\Data\Form\Element\AbstractElement $element)
6674
{
@@ -89,7 +97,7 @@ public function render(\Magento\Framework\Data\Form\Element\AbstractElement $ele
8997
}
9098

9199
/**
92-
* @deprecated 100.2.0 Magento does not support custom disabling/enabling module output since 2.2.0 version
100+
* @deprecated 100.2.0
93101
* @return \Magento\Framework\DataObject
94102
*/
95103
protected function _getDummyElement()
@@ -101,7 +109,7 @@ protected function _getDummyElement()
101109
}
102110

103111
/**
104-
* @deprecated 100.2.0 Magento does not support custom disabling/enabling module output since 2.2.0 version
112+
* @deprecated 100.2.0
105113
* @return \Magento\Config\Block\System\Config\Form\Field
106114
*/
107115
protected function _getFieldRenderer()
@@ -115,7 +123,7 @@ protected function _getFieldRenderer()
115123
}
116124

117125
/**
118-
* @deprecated 100.2.0 Magento does not support custom disabling/enabling module output since 2.2.0 version
126+
* @deprecated 100.2.0
119127
* @return array
120128
*/
121129
protected function _getValues()
@@ -132,7 +140,7 @@ protected function _getValues()
132140
/**
133141
* @param \Magento\Framework\Data\Form\Element\Fieldset $fieldset
134142
* @param string $moduleName
135-
* @deprecated 100.2.0 Magento does not support custom disabling/enabling module output since 2.2.0 version
143+
* @deprecated 100.2.0
136144
* @return mixed
137145
*/
138146
protected function _getFieldHtml($fieldset, $moduleName)

app/code/Magento/Config/Test/Unit/Block/System/Config/Form/Fieldset/Modules/DisableOutputTest.php

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

88
/**
99
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
10-
* @deprecated because \Magento\Config\Block\System\Config\Form\Fieldset\Modules\DisableOutput is deprecated
1110
*/
1211
class DisableOutputTest extends \PHPUnit\Framework\TestCase
1312
{

app/code/Magento/Payment/Test/Unit/Block/Info/SubstitutionTest.php

Lines changed: 110 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
7+
// @codingStandardsIgnoreFile
8+
69
namespace Magento\Payment\Test\Unit\Block\Info;
710

811
/**
@@ -31,23 +34,71 @@ class SubstitutionTest extends \PHPUnit\Framework\TestCase
3134
protected function setUp()
3235
{
3336
$this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
34-
$this->layout = $this->getMockBuilder(\Magento\Framework\View\LayoutInterface::class)
35-
->disableOriginalConstructor()
36-
->setMethods([])
37-
->getMock();
38-
$eventManager = $this->getMockBuilder(\Magento\Framework\Event\ManagerInterface::class)
39-
->disableOriginalConstructor()
40-
->setMethods([])
41-
->getMock();
42-
$context = $this->getMockBuilder(\Magento\Framework\View\Element\Template\Context::class)
43-
->disableOriginalConstructor()
44-
->setMethods(['getLayout', 'getEventManager', 'getScopeConfig'])
45-
->getMock();
46-
$context->expects($this->any())
47-
->method('getLayout')
48-
->willReturn($this->layout);
49-
$context->expects($this->any())->method('getEventManager')
50-
->willReturn($eventManager);
37+
38+
$this->layout = $this->getMockBuilder(
39+
\Magento\Framework\View\LayoutInterface::class
40+
)->disableOriginalConstructor()->setMethods(
41+
[]
42+
)->getMock();
43+
44+
$eventManager = $this->getMockBuilder(
45+
\Magento\Framework\Event\ManagerInterface::class
46+
)->disableOriginalConstructor()->setMethods(
47+
[]
48+
)->getMock();
49+
50+
$scopeConfig = $this->getMockBuilder(
51+
\Magento\Framework\App\Config\ScopeConfigInterface::class
52+
)->disableOriginalConstructor()->setMethods(
53+
[]
54+
)->getMock();
55+
$scopeConfig->expects(
56+
$this->any()
57+
)->method(
58+
'getValue'
59+
)->with(
60+
$this->stringContains(
61+
'advanced/modules_disable_output/'
62+
),
63+
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
64+
)->will(
65+
$this->returnValue(
66+
false
67+
)
68+
);
69+
70+
$context = $this->getMockBuilder(
71+
\Magento\Framework\View\Element\Template\Context::class
72+
)->disableOriginalConstructor()->setMethods(
73+
['getLayout', 'getEventManager', 'getScopeConfig']
74+
)->getMock();
75+
$context->expects(
76+
$this->any()
77+
)->method(
78+
'getLayout'
79+
)->will(
80+
$this->returnValue(
81+
$this->layout
82+
)
83+
);
84+
$context->expects(
85+
$this->any()
86+
)->method(
87+
'getEventManager'
88+
)->will(
89+
$this->returnValue(
90+
$eventManager
91+
)
92+
);
93+
$context->expects(
94+
$this->any()
95+
)->method(
96+
'getScopeConfig'
97+
)->will(
98+
$this->returnValue(
99+
$scopeConfig
100+
)
101+
);
51102

52103
$this->block = $this->objectManager->getObject(
53104
\Magento\Payment\Block\Info\Substitution::class,
@@ -62,45 +113,52 @@ protected function setUp()
62113

63114
public function testBeforeToHtml()
64115
{
65-
$abstractBlock = $this->getMockBuilder(\Magento\Framework\View\Element\AbstractBlock::class)
66-
->disableOriginalConstructor()
67-
->setMethods([])
68-
->getMock();
69-
$childAbstractBlock = clone $abstractBlock;
70-
71-
$abstractBlock->expects($this->any())
72-
->method('getParentBlock')
73-
->willReturn($childAbstractBlock);
74-
$this->layout->expects($this->any())
75-
->method('getParentName')
76-
->willReturn('parentName');
77-
$this->layout->expects($this->any())
78-
->method('getBlock')
79-
->willReturn($abstractBlock);
80-
81-
$infoMock = $this->getMockBuilder(\Magento\Payment\Model\Info::class)
82-
->disableOriginalConstructor()
83-
->getMock();
84-
$methodMock = $this->getMockBuilder(\Magento\Payment\Model\MethodInterface::class)
85-
->getMockForAbstractClass();
86-
$infoMock->expects($this->once())
87-
->method('getMethodInstance')
88-
->willReturn($methodMock);
116+
$abstractBlock = $this->getMockBuilder(
117+
\Magento\Framework\View\Element\AbstractBlock::class
118+
)->disableOriginalConstructor()->setMethods(
119+
[]
120+
)->getMock();
121+
$childAbstractBlock = clone($abstractBlock);
122+
123+
$abstractBlock->expects($this->any())->method('getParentBlock')->will($this->returnValue($childAbstractBlock));
89124

125+
$this->layout->expects($this->any())->method('getParentName')->will($this->returnValue('parentName'));
126+
$this->layout->expects($this->any())->method('getBlock')->will($this->returnValue($abstractBlock));
127+
128+
$infoMock = $this->getMockBuilder(
129+
\Magento\Payment\Model\Info::class
130+
)->disableOriginalConstructor()->setMethods(
131+
[]
132+
)->getMock();
133+
$methodMock = $this->getMockBuilder(
134+
\Magento\Payment\Model\MethodInterface::class
135+
)->getMockForAbstractClass();
136+
$infoMock->expects($this->once())->method('getMethodInstance')->will($this->returnValue($methodMock));
90137
$this->block->setInfo($infoMock);
91138

92139
$fakeBlock = new \StdClass();
93-
$this->layout->expects($this->any())
94-
->method('createBlock')
95-
->with(
96-
\Magento\Framework\View\Element\Template::class,
97-
'',
98-
['data' => ['method' => $methodMock, 'template' => 'Magento_Payment::info/substitution.phtml']]
99-
)->willReturn($fakeBlock);
100-
101-
$childAbstractBlock->expects($this->any())
102-
->method('setChild')
103-
->with('order_payment_additional', $fakeBlock);
140+
$this->layout->expects(
141+
$this->any()
142+
)->method(
143+
'createBlock'
144+
)->with(
145+
\Magento\Framework\View\Element\Template::class,
146+
'',
147+
['data' => ['method' => $methodMock, 'template' => 'Magento_Payment::info/substitution.phtml']]
148+
)->will(
149+
$this->returnValue(
150+
$fakeBlock
151+
)
152+
);
153+
154+
$childAbstractBlock->expects(
155+
$this->any()
156+
)->method(
157+
'setChild'
158+
)->with(
159+
'order_payment_additional',
160+
$fakeBlock
161+
);
104162

105163
$this->block->toHtml();
106164
}

app/code/Magento/Paypal/Test/Unit/Block/Billing/AgreementsTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,10 @@ public function testToHtml()
231231
->expects($this->at(1))
232232
->method('dispatch')
233233
->with('view_block_abstract_to_html_after', ['block' => $this->block, 'transport' => $transport]);
234+
$this->scopeConfig
235+
->expects($this->once())
236+
->method('getValue')
237+
->willReturn(false);
234238
$this->urlBuilder->expects($this->once())->method('getUrl')->with('paypal/billing_agreement/startWizard', []);
235239
$this->block->toHtml();
236240
}

0 commit comments

Comments
 (0)