diff --git a/app/code/Magento/Backend/Block/Template.php b/app/code/Magento/Backend/Block/Template.php index 1bcd3033035dc0bf2de89782ad8972b8236e0d96..45d3830793e116f8d7029b4ae5c87ca80a83f280 100644 --- a/app/code/Magento/Backend/Block/Template.php +++ b/app/code/Magento/Backend/Block/Template.php @@ -70,17 +70,12 @@ class Template extends \Magento\Framework\View\Element\Template * * @param string $moduleName Full module name * @return boolean + * @deprecated + * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function isOutputEnabled($moduleName = null) { - if ($moduleName === null) { - $moduleName = $this->getModuleName(); - } - - return !$this->_scopeConfig->isSetFlag( - 'advanced/modules_disable_output/' . $moduleName, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE - ); + return true; } /** diff --git a/app/code/Magento/Backend/etc/adminhtml/system.xml b/app/code/Magento/Backend/etc/adminhtml/system.xml index 813a097ea6bf3ca2e615f0848619409c61f2dd9f..fc6c8df551913f5ad34d9875bc7e0e9173424681 100644 --- a/app/code/Magento/Backend/etc/adminhtml/system.xml +++ b/app/code/Magento/Backend/etc/adminhtml/system.xml @@ -16,7 +16,7 @@ <tab id="advanced" translate="label" sortOrder="999999"> <label>Advanced</label> </tab> - <section id="advanced" translate="label" type="text" sortOrder="910" showInDefault="1" showInWebsite="1" showInStore="1"> + <section id="advanced" translate="label" type="text" sortOrder="910" showInDefault="0" showInWebsite="0" showInStore="0"> <label>Advanced</label> <tab>advanced</tab> <resource>Magento_Backend::advanced</resource> diff --git a/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Options/AjaxTest.php b/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Options/AjaxTest.php index 0c6f680df486a50c584008b9cee288366c5d0209..1ca01ca6724ce741b58278ffe2d42a8522aa574c 100644 --- a/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Options/AjaxTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Options/AjaxTest.php @@ -55,12 +55,6 @@ class AjaxTest extends \PHPUnit_Framework_TestCase ->getMock(); $eventManager->expects($this->exactly(2))->method('dispatch')->will($this->returnValue(true)); - $scopeConfig = $this->getMockBuilder(\Magento\Framework\App\Config::class) - ->setMethods(['getValue']) - ->disableOriginalConstructor()->getMock(); - $scopeConfig->expects($this->once())->method('getValue')->withAnyParameters() - ->will($this->returnValue(false)); - $product = $this->getMockBuilder(\Magento\Catalog\Model\Product::class)->disableOriginalConstructor() ->setMethods(['setStoreId', 'load', 'getId', '__wakeup', '__sleep']) ->getMock(); @@ -93,8 +87,6 @@ class AjaxTest extends \PHPUnit_Framework_TestCase $this->context->expects($this->once())->method('getEventManager') ->will($this->returnValue($eventManager)); - $this->context->expects($this->once())->method('getScopeConfig') - ->will($this->returnValue($scopeConfig)); $this->context->expects($this->once())->method('getLayout') ->will($this->returnValue($layout)); $this->context->expects($this->once())->method('getRequest') diff --git a/app/code/Magento/Catalog/Test/Unit/Block/Product/Widget/NewWidgetTest.php b/app/code/Magento/Catalog/Test/Unit/Block/Product/Widget/NewWidgetTest.php index 9c153fb920279c48ac2e36014a178b67de66eb3f..90d76e469b7abe4d0c2e253bd174f0ee8437dc00 100644 --- a/app/code/Magento/Catalog/Test/Unit/Block/Product/Widget/NewWidgetTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Block/Product/Widget/NewWidgetTest.php @@ -63,7 +63,7 @@ class NewWidgetTest extends \PHPUnit_Framework_TestCase false, false ); - $this->scopeConfig = $this->getMock(\Magento\Framework\App\Config::class, ['getValue'], [], '', false, false); + $this->scopeConfig = $this->getMock(\Magento\Framework\App\Config::class, [], [], '', false, false); $this->cacheState = $this->getMock( \Magento\Framework\App\Cache\State::class, ['isEnabled'], @@ -188,8 +188,6 @@ class NewWidgetTest extends \PHPUnit_Framework_TestCase { $this->eventManager->expects($this->exactly(2))->method('dispatch') ->will($this->returnValue(true)); - $this->scopeConfig->expects($this->once())->method('getValue')->withAnyParameters() - ->willReturn(false); $this->cacheState->expects($this->atLeastOnce())->method('isEnabled')->withAnyParameters() ->willReturn(false); $this->catalogConfig->expects($this->once())->method('getProductAttributes') diff --git a/app/code/Magento/Checkout/Test/Unit/Block/Cart/Item/Renderer/ActionsTest.php b/app/code/Magento/Checkout/Test/Unit/Block/Cart/Item/Renderer/ActionsTest.php index 526a1d580a5d5efe0a14109345113edcc22936e9..48c6eb87c4d73755372d66d7172f2a4aa9073bd5 100644 --- a/app/code/Magento/Checkout/Test/Unit/Block/Cart/Item/Renderer/ActionsTest.php +++ b/app/code/Magento/Checkout/Test/Unit/Block/Cart/Item/Renderer/ActionsTest.php @@ -65,10 +65,6 @@ class ActionsTest extends \PHPUnit_Framework_TestCase $childNameTwo = 'child.2'; $childNames = [$childNameOne, $childNameTwo]; - $this->scopeConfigMock->expects($this->once()) - ->method('getValue') - ->willReturn(false); - /** * @var Item|\PHPUnit_Framework_MockObject_MockObject $itemMock */ diff --git a/app/code/Magento/Config/Block/System/Config/Form/Fieldset/Modules/DisableOutput.php b/app/code/Magento/Config/Block/System/Config/Form/Fieldset/Modules/DisableOutput.php index cda1a6a80cce639bf511f8400d4f13119a728e5d..e938de4aad64353d54f279525b142612911963bc 100644 --- a/app/code/Magento/Config/Block/System/Config/Form/Fieldset/Modules/DisableOutput.php +++ b/app/code/Magento/Config/Block/System/Config/Form/Fieldset/Modules/DisableOutput.php @@ -9,6 +9,9 @@ */ namespace Magento\Config\Block\System\Config\Form\Fieldset\Modules; +/** + * @deprecated + */ class DisableOutput extends \Magento\Config\Block\System\Config\Form\Fieldset { /** diff --git a/app/code/Magento/Config/Test/Unit/Block/System/Config/Form/Fieldset/Modules/DisableOutputTest.php b/app/code/Magento/Config/Test/Unit/Block/System/Config/Form/Fieldset/Modules/DisableOutputTest.php index 218ea75643939fb116512ced43aca46d7566e5c4..b8f420880ff6d231a36ec2e50126d36eaa149adf 100644 --- a/app/code/Magento/Config/Test/Unit/Block/System/Config/Form/Fieldset/Modules/DisableOutputTest.php +++ b/app/code/Magento/Config/Test/Unit/Block/System/Config/Form/Fieldset/Modules/DisableOutputTest.php @@ -7,6 +7,7 @@ namespace Magento\Config\Test\Unit\Block\System\Config\Form\Fieldset\Modules; /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + * @deprecated */ class DisableOutputTest extends \PHPUnit_Framework_TestCase { diff --git a/app/code/Magento/Payment/Test/Unit/Block/Info/SubstitutionTest.php b/app/code/Magento/Payment/Test/Unit/Block/Info/SubstitutionTest.php index 78946d236391e90eccec0d29def00f810db91eea..f4a2b1a81d7feeead8c6365f5291b6dd9466f02a 100644 --- a/app/code/Magento/Payment/Test/Unit/Block/Info/SubstitutionTest.php +++ b/app/code/Magento/Payment/Test/Unit/Block/Info/SubstitutionTest.php @@ -3,9 +3,6 @@ * Copyright © 2013-2017 Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ - -// @codingStandardsIgnoreFile - namespace Magento\Payment\Test\Unit\Block\Info; /** @@ -31,71 +28,23 @@ class SubstitutionTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - - $this->layout = $this->getMockBuilder( - \Magento\Framework\View\LayoutInterface::class - )->disableOriginalConstructor()->setMethods( - [] - )->getMock(); - - $eventManager = $this->getMockBuilder( - \Magento\Framework\Event\ManagerInterface::class - )->disableOriginalConstructor()->setMethods( - [] - )->getMock(); - - $scopeConfig = $this->getMockBuilder( - \Magento\Framework\App\Config\ScopeConfigInterface::class - )->disableOriginalConstructor()->setMethods( - [] - )->getMock(); - $scopeConfig->expects( - $this->any() - )->method( - 'getValue' - )->with( - $this->stringContains( - 'advanced/modules_disable_output/' - ), - \Magento\Store\Model\ScopeInterface::SCOPE_STORE - )->will( - $this->returnValue( - false - ) - ); - - $context = $this->getMockBuilder( - \Magento\Framework\View\Element\Template\Context::class - )->disableOriginalConstructor()->setMethods( - ['getLayout', 'getEventManager', 'getScopeConfig'] - )->getMock(); - $context->expects( - $this->any() - )->method( - 'getLayout' - )->will( - $this->returnValue( - $this->layout - ) - ); - $context->expects( - $this->any() - )->method( - 'getEventManager' - )->will( - $this->returnValue( - $eventManager - ) - ); - $context->expects( - $this->any() - )->method( - 'getScopeConfig' - )->will( - $this->returnValue( - $scopeConfig - ) - ); + $this->layout = $this->getMockBuilder(\Magento\Framework\View\LayoutInterface::class) + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $eventManager = $this->getMockBuilder(\Magento\Framework\Event\ManagerInterface::class) + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $context = $this->getMockBuilder(\Magento\Framework\View\Element\Template\Context::class) + ->disableOriginalConstructor() + ->setMethods(['getLayout', 'getEventManager', 'getScopeConfig']) + ->getMock(); + $context->expects($this->any()) + ->method('getLayout') + ->willReturn($this->layout); + $context->expects($this->any())->method('getEventManager') + ->willReturn($eventManager); $this->block = $this->objectManager->getObject( \Magento\Payment\Block\Info\Substitution::class, @@ -110,52 +59,45 @@ class SubstitutionTest extends \PHPUnit_Framework_TestCase public function testBeforeToHtml() { - $abstractBlock = $this->getMockBuilder( - \Magento\Framework\View\Element\AbstractBlock::class - )->disableOriginalConstructor()->setMethods( - [] - )->getMock(); - $childAbstractBlock = clone($abstractBlock); - - $abstractBlock->expects($this->any())->method('getParentBlock')->will($this->returnValue($childAbstractBlock)); + $abstractBlock = $this->getMockBuilder(\Magento\Framework\View\Element\AbstractBlock::class) + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $childAbstractBlock = clone $abstractBlock; + + $abstractBlock->expects($this->any()) + ->method('getParentBlock') + ->willReturn($childAbstractBlock); + $this->layout->expects($this->any()) + ->method('getParentName') + ->willReturn('parentName'); + $this->layout->expects($this->any()) + ->method('getBlock') + ->willReturn($abstractBlock); + + $infoMock = $this->getMockBuilder(\Magento\Payment\Model\Info::class) + ->disableOriginalConstructor() + ->getMock(); + $methodMock = $this->getMockBuilder(\Magento\Payment\Model\MethodInterface::class) + ->getMockForAbstractClass(); + $infoMock->expects($this->once()) + ->method('getMethodInstance') + ->willReturn($methodMock); - $this->layout->expects($this->any())->method('getParentName')->will($this->returnValue('parentName')); - $this->layout->expects($this->any())->method('getBlock')->will($this->returnValue($abstractBlock)); - - $infoMock = $this->getMockBuilder( - \Magento\Payment\Model\Info::class - )->disableOriginalConstructor()->setMethods( - [] - )->getMock(); - $methodMock = $this->getMockBuilder( - \Magento\Payment\Model\MethodInterface::class - )->getMockForAbstractClass(); - $infoMock->expects($this->once())->method('getMethodInstance')->will($this->returnValue($methodMock)); $this->block->setInfo($infoMock); $fakeBlock = new \StdClass(); - $this->layout->expects( - $this->any() - )->method( - 'createBlock' - )->with( - \Magento\Framework\View\Element\Template::class, - '', - ['data' => ['method' => $methodMock, 'template' => 'Magento_Payment::info/substitution.phtml']] - )->will( - $this->returnValue( - $fakeBlock - ) - ); - - $childAbstractBlock->expects( - $this->any() - )->method( - 'setChild' - )->with( - 'order_payment_additional', - $fakeBlock - ); + $this->layout->expects($this->any()) + ->method('createBlock') + ->with( + \Magento\Framework\View\Element\Template::class, + '', + ['data' => ['method' => $methodMock, 'template' => 'Magento_Payment::info/substitution.phtml']] + )->willReturn($fakeBlock); + + $childAbstractBlock->expects($this->any()) + ->method('setChild') + ->with('order_payment_additional', $fakeBlock); $this->block->toHtml(); } diff --git a/app/code/Magento/Paypal/Test/Unit/Block/Billing/AgreementsTest.php b/app/code/Magento/Paypal/Test/Unit/Block/Billing/AgreementsTest.php index f478ea085e47a378573fc945a1afdf77b6eb942a..64f278c8e9f118b6b7e564da0c6de434052d4184 100644 --- a/app/code/Magento/Paypal/Test/Unit/Block/Billing/AgreementsTest.php +++ b/app/code/Magento/Paypal/Test/Unit/Block/Billing/AgreementsTest.php @@ -243,10 +243,6 @@ class AgreementsTest extends \PHPUnit_Framework_TestCase ->expects($this->at(1)) ->method('dispatch') ->with('view_block_abstract_to_html_after', ['block' => $this->block, 'transport' => $transport]); - $this->scopeConfig - ->expects($this->once()) - ->method('getValue') - ->willReturn(false); $this->urlBuilder->expects($this->once())->method('getUrl')->with('paypal/billing_agreement/startWizard', []); $this->block->toHtml(); } diff --git a/app/code/Magento/Paypal/Test/Unit/Block/Express/ReviewTest.php b/app/code/Magento/Paypal/Test/Unit/Block/Express/ReviewTest.php index cf16349e5873468cef013f42601895a28244cba5..17468c02578693be75efd4af8bbef3f73d868871 100644 --- a/app/code/Magento/Paypal/Test/Unit/Block/Express/ReviewTest.php +++ b/app/code/Magento/Paypal/Test/Unit/Block/Express/ReviewTest.php @@ -3,11 +3,9 @@ * Copyright © 2013-2017 Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ - namespace Magento\Paypal\Test\Unit\Block\Express; use Magento\Paypal\Block\Express\Review; -use Magento\Quote\Model\Quote\Address\Rate; /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) @@ -35,14 +33,6 @@ class ReviewTest extends \PHPUnit_Framework_TestCase $layout = $this->getMock(\Magento\Framework\View\LayoutInterface::class, [], [], '', false); $eventManager = $this->getMock(\Magento\Framework\Event\ManagerInterface::class, [], [], '', false); - $scopeConfig = $this->getMock(\Magento\Framework\App\Config\ScopeConfigInterface::class, [], [], '', false); - - $scopeConfig->expects($this->any()) - ->method('getValue') - ->with( - $this->stringContains('advanced/modules_disable_output/'), - \Magento\Store\Model\ScopeInterface::SCOPE_STORE - )->will($this->returnValue(false)); $urlBuilder = $this->getMock(\Magento\Framework\UrlInterface::class); $urlBuilder->expects($this->any())->method('getUrl')->will($this->returnArgument(0)); @@ -60,7 +50,6 @@ class ReviewTest extends \PHPUnit_Framework_TestCase $context->expects($this->any())->method('getLayout')->will($this->returnValue($layout)); $context->expects($this->any())->method('getEventManager')->will($this->returnValue($eventManager)); - $context->expects($this->any())->method('getScopeConfig')->will($this->returnValue($scopeConfig)); $context->expects($this->any())->method('getRequest')->will($this->returnValue($this->request)); $context->expects($this->any())->method('getAssetRepository')->will($this->returnValue($this->assetRepo)); $context->expects($this->any())->method('getUrlBuilder')->will($this->returnValue($urlBuilder)); diff --git a/app/code/Magento/Persistent/Test/Unit/Block/Header/AdditionalTest.php b/app/code/Magento/Persistent/Test/Unit/Block/Header/AdditionalTest.php index 44b494f2a41df8c7394c83396387d577bbb5e641..f80c1018d322c35bd8dd823e2c6e1d0d58fca96b 100644 --- a/app/code/Magento/Persistent/Test/Unit/Block/Header/AdditionalTest.php +++ b/app/code/Magento/Persistent/Test/Unit/Block/Header/AdditionalTest.php @@ -149,8 +149,7 @@ class AdditionalTest extends \PHPUnit_Framework_TestCase '', false, true, - true, - ['getValue'] + true ); $this->cacheStateMock = $this->getMockForAbstractClass( \Magento\Framework\App\Cache\StateInterface::class, @@ -267,12 +266,6 @@ class AdditionalTest extends \PHPUnit_Framework_TestCase $this->eventManagerMock->expects($this->at(1)) ->method('dispatch') ->with('view_block_abstract_to_html_after'); - $this->scopeConfigMock->expects($this->once()) - ->method('getValue') - ->with( - 'advanced/modules_disable_output/Magento_Persistent', - \Magento\Store\Model\ScopeInterface::SCOPE_STORE - )->willReturn(false); // get cache $this->cacheStateMock->expects($this->at(0)) diff --git a/app/code/Magento/Widget/Test/Unit/Block/Adminhtml/Widget/Instance/Edit/Chooser/ContainerTest.php b/app/code/Magento/Widget/Test/Unit/Block/Adminhtml/Widget/Instance/Edit/Chooser/ContainerTest.php index 837b7f7135d29d22580aaf1103b9a5c3ae2579d2..c23a8019e37eeb3ebebd8662aea23a773dff036e 100644 --- a/app/code/Magento/Widget/Test/Unit/Block/Adminhtml/Widget/Instance/Edit/Chooser/ContainerTest.php +++ b/app/code/Magento/Widget/Test/Unit/Block/Adminhtml/Widget/Instance/Edit/Chooser/ContainerTest.php @@ -67,7 +67,6 @@ class ContainerTest extends AbstractContainerTest . '<option value="content.top" >Main Content Top</option></select>'; $this->eventManagerMock->expects($this->exactly(2))->method('dispatch')->willReturn(true); - $this->scopeConfigMock->expects($this->once())->method('getValue')->willReturn(false); $this->themeCollectionFactoryMock->expects($this->once()) ->method('create') @@ -154,7 +153,6 @@ class ContainerTest extends AbstractContainerTest . '<option value="sidebar.main" >Sidebar Main</option></select>'; $this->eventManagerMock->expects($this->exactly(2))->method('dispatch')->willReturn(true); - $this->scopeConfigMock->expects($this->once())->method('getValue')->willReturn(false); $this->themeCollectionFactoryMock->expects($this->once()) ->method('create') @@ -285,7 +283,6 @@ class ContainerTest extends AbstractContainerTest . '<option value="sidebar.main" >Sidebar Main</option></select>'; $this->eventManagerMock->expects($this->exactly(2))->method('dispatch')->willReturn(true); - $this->scopeConfigMock->expects($this->once())->method('getValue')->willReturn(false); $this->themeCollectionFactoryMock->expects($this->once()) ->method('create') @@ -403,7 +400,6 @@ class ContainerTest extends AbstractContainerTest . 'Sidebar Main</option></select>'; $this->eventManagerMock->expects($this->exactly(2))->method('dispatch')->willReturn(true); - $this->scopeConfigMock->expects($this->once())->method('getValue')->willReturn(false); $this->themeCollectionFactoryMock->expects($this->once()) ->method('create') diff --git a/app/code/Magento/Wishlist/Test/Unit/Model/Rss/WishlistTest.php b/app/code/Magento/Wishlist/Test/Unit/Model/Rss/WishlistTest.php index b9dcc8d6fe73f500b1d314b90bf992c672fe14cf..e9c22670b1a104a46aa30525c70593ee40bdf81f 100644 --- a/app/code/Magento/Wishlist/Test/Unit/Model/Rss/WishlistTest.php +++ b/app/code/Magento/Wishlist/Test/Unit/Model/Rss/WishlistTest.php @@ -136,7 +136,6 @@ class WishlistTest extends \PHPUnit_Framework_TestCase ); $customerServiceMock = $this->getMock(\Magento\Customer\Api\Data\CustomerInterface::class, [], [], '', false); $wishlistSharingUrl = 'wishlist/shared/index/1'; - $locale = 'en_US'; $productUrl = 'http://product.url/'; $productName = 'Product name'; @@ -160,25 +159,6 @@ class WishlistTest extends \PHPUnit_Framework_TestCase $this->urlBuilderMock->expects($this->once()) ->method('getUrl') ->will($this->returnValue($wishlistSharingUrl)); - $this->scopeConfig->expects($this->any()) - ->method('getValue') - ->will($this->returnValueMap( - [ - [ - 'advanced/modules_disable_output/Magento_Rss', - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, - null, - null, - ], - [ - Data::XML_PATH_DEFAULT_LOCALE, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, - null, - $locale - ], - ] - ) - ); $staticArgs = [ 'productName' => $productName, diff --git a/dev/tests/integration/testsuite/Magento/Backend/Block/TemplateTest.php b/dev/tests/integration/testsuite/Magento/Backend/Block/TemplateTest.php index 2a3441afcd2aad6d1eeab87a1c4c3e7f7c266bd2..ea450cbe81c2ff5bc4ad8a28705dc7ba97a84a82 100644 --- a/dev/tests/integration/testsuite/Magento/Backend/Block/TemplateTest.php +++ b/dev/tests/integration/testsuite/Magento/Backend/Block/TemplateTest.php @@ -34,26 +34,4 @@ class TemplateTest extends \PHPUnit_Framework_TestCase { $this->assertGreaterThan(15, strlen($this->_block->getFormKey())); } - - /** - * @magentoAppArea adminhtml - * @covers \Magento\Backend\Block\Template::isOutputEnabled - * @magentoConfigFixture current_store advanced/modules_disable_output/dummy 1 - */ - public function testIsOutputEnabledTrue() - { - $this->_block->setData('module_name', 'dummy'); - $this->assertFalse($this->_block->isOutputEnabled('dummy')); - } - - /** - * @magentoAppArea adminhtml - * @covers \Magento\Backend\Block\Template::isOutputEnabled - * @magentoConfigFixture current_store advanced/modules_disable_output/dummy 0 - */ - public function testIsOutputEnabledFalse() - { - $this->_block->setData('module_name', 'dummy'); - $this->assertTrue($this->_block->isOutputEnabled('dummy')); - } } diff --git a/lib/internal/Magento/Framework/Module/Manager.php b/lib/internal/Magento/Framework/Module/Manager.php index 7df83917075651eb63f167aa759f9c931ba5edd7..cf22583184b1c89c79da06513a59c588a09faf25 100644 --- a/lib/internal/Magento/Framework/Module/Manager.php +++ b/lib/internal/Magento/Framework/Module/Manager.php @@ -3,90 +3,94 @@ * Copyright © 2013-2017 Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ +namespace Magento\Framework\Module; /** - * Module statuses manager + * Module status manager. + * + * Usage: + * + * $manager->isEnabled('Vendor_Module') */ -namespace Magento\Framework\Module; - class Manager { /** - * @var Output\ConfigInterface + * The checker of output modules. + * + * @var Output\ConfigInterface the config checker of output modules. + * @deprecated */ - private $_outputConfig; + private $outputConfig; /** - * @var ModuleListInterface + * The list of all modules. + * + * @var ModuleListInterface the list of all modules. */ - private $_moduleList; + private $moduleList; /** - * @var array + * The list of config paths to ignore. + * + * @var array the list of config paths to ignore. + * @deprecated */ - private $_outputConfigPaths; + private $outputConfigPaths; /** - * @param Output\ConfigInterface $outputConfig - * @param ModuleListInterface $moduleList - * @param array $outputConfigPaths + * Constructor. + * + * @param Output\ConfigInterface $outputConfig the checker of output modules + * @param ModuleListInterface $moduleList the list of all modules + * @param array $outputConfigPaths the list of config paths to ignore */ public function __construct( Output\ConfigInterface $outputConfig, ModuleListInterface $moduleList, array $outputConfigPaths = [] ) { - $this->_outputConfig = $outputConfig; - $this->_moduleList = $moduleList; - $this->_outputConfigPaths = $outputConfigPaths; + $this->outputConfig = $outputConfig; + $this->moduleList = $moduleList; + $this->outputConfigPaths = $outputConfigPaths; } /** - * Whether a module is enabled in the configuration or not + * Checks whether a module is enabled in the configuration or not. * - * @param string $moduleName Fully-qualified module name - * @return boolean + * @param string $moduleName the fully-qualified module name + * + * @return boolean true if module is enabled, false otherwise */ public function isEnabled($moduleName) { - return $this->_moduleList->has($moduleName); + return $this->moduleList->has($moduleName); } /** - * Whether a module output is permitted by the configuration or not + * Checks whether a module output is permitted by the configuration or not. + * + * @param string $moduleName the fully-qualified module name. * - * @param string $moduleName Fully-qualified module name * @return boolean + * @deprecated + * @see \Magento\Framework\Module\Manager::isEnabled() */ public function isOutputEnabled($moduleName) { - if (!$this->isEnabled($moduleName)) { - return false; - } - if (!$this->_isCustomOutputConfigEnabled($moduleName)) { - return false; - } - if ($this->_outputConfig->isEnabled($moduleName)) { - return false; - } - return true; + return $this->isEnabled($moduleName); } /** - * Whether a configuration switch for a module output permits output or not + * Checks whether a configuration switch for a module output permits output. * * @param string $moduleName Fully-qualified module name + * * @return boolean + * @deprecated + * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ protected function _isCustomOutputConfigEnabled($moduleName) { - if (isset($this->_outputConfigPaths[$moduleName])) { - $configPath = $this->_outputConfigPaths[$moduleName]; - if (defined($configPath)) { - $configPath = constant($configPath); - } - return $this->_outputConfig->isSetFlag($configPath); - } return true; } } diff --git a/lib/internal/Magento/Framework/Module/Output/Config.php b/lib/internal/Magento/Framework/Module/Output/Config.php index 27a99fdff4121c6514b51533d9e6626fb5f579f8..ca9d8d742d05cd410409f17161649471b17e08b1 100644 --- a/lib/internal/Magento/Framework/Module/Output/Config.php +++ b/lib/internal/Magento/Framework/Module/Output/Config.php @@ -7,6 +7,9 @@ */ namespace Magento\Framework\Module\Output; +/** + * @deprecated + */ class Config implements \Magento\Framework\Module\Output\ConfigInterface { /** @@ -41,7 +44,7 @@ class Config implements \Magento\Framework\Module\Output\ConfigInterface */ public function isEnabled($moduleName) { - return $this->isSetFlag(sprintf(self::XML_PATH_MODULE_OUTPUT_STATUS, $moduleName)); + return false; } /** @@ -49,6 +52,6 @@ class Config implements \Magento\Framework\Module\Output\ConfigInterface */ public function isSetFlag($path) { - return $this->_scopeConfig->isSetFlag($path, $this->_storeType); + return false; } } diff --git a/lib/internal/Magento/Framework/Module/Output/ConfigInterface.php b/lib/internal/Magento/Framework/Module/Output/ConfigInterface.php index e417391ed547455f1d6ccc2a14edbc7a02dc1ae2..2025f5c6f42c5b3312f0907b4f0deaaa3c6cefb9 100644 --- a/lib/internal/Magento/Framework/Module/Output/ConfigInterface.php +++ b/lib/internal/Magento/Framework/Module/Output/ConfigInterface.php @@ -5,6 +5,9 @@ */ namespace Magento\Framework\Module\Output; +/** + * @deprecated + */ interface ConfigInterface { /** diff --git a/lib/internal/Magento/Framework/Module/Test/Unit/ManagerTest.php b/lib/internal/Magento/Framework/Module/Test/Unit/ManagerTest.php index f8fdc438b940cd5dbf604056c26f6727d03c990e..284367c84a721e3ce0202e9ab1f180c0eba96473 100644 --- a/lib/internal/Magento/Framework/Module/Test/Unit/ManagerTest.php +++ b/lib/internal/Magento/Framework/Module/Test/Unit/ManagerTest.php @@ -5,106 +5,60 @@ */ namespace Magento\Framework\Module\Test\Unit; -use Magento\Framework\Module\Plugin\DbStatusValidator; +use Magento\Framework\Module\Manager; +use Magento\Framework\Module\ModuleListInterface; +use Magento\Framework\Module\Output\ConfigInterface; +use PHPUnit_Framework_MockObject_MockObject as Mock; class ManagerTest extends \PHPUnit_Framework_TestCase { /** * XPath in the configuration of a module output flag + * @deprecated */ const XML_PATH_OUTPUT_ENABLED = 'custom/is_module_output_enabled'; /** - * @var \Magento\Framework\Module\Manager + * @var Manager */ - private $_model; + private $model; /** - * @var \PHPUnit_Framework_MockObject_MockObject + * @var ModuleListInterface|Mock */ - private $_moduleList; + private $moduleList; /** - * @var \PHPUnit_Framework_MockObject_MockObject + * @var ConfigInterface|Mock + * @deprecated */ - private $_outputConfig; + private $outputConfig; protected function setUp() { - $this->_moduleList = $this->getMockForAbstractClass(\Magento\Framework\Module\ModuleListInterface::class); - $this->_moduleList->expects($this->any()) - ->method('getOne') - ->will($this->returnValueMap([ - ['Module_One', ['name' => 'One_Module', 'setup_version' => '1']], - ['Module_Two', ['name' => 'Two_Module', 'setup_version' => '2']], - ['Module_Three', ['name' => 'Two_Three']], - ])); - $this->_outputConfig = $this->getMockForAbstractClass(\Magento\Framework\Module\Output\ConfigInterface::class); - $this->_model = new \Magento\Framework\Module\Manager( - $this->_outputConfig, - $this->_moduleList, - [ - 'Module_Two' => self::XML_PATH_OUTPUT_ENABLED, - ] + $this->moduleList = $this->getMockBuilder(ModuleListInterface::class) + ->getMockForAbstractClass(); + $this->outputConfig = $this->getMockBuilder(ConfigInterface::class) + ->getMockForAbstractClass(); + + $this->model = new Manager( + $this->outputConfig, + $this->moduleList ); } public function testIsEnabled() { - $this->_moduleList->expects($this->exactly(2))->method('has')->will($this->returnValueMap([ - ['Module_Exists', true], - ['Module_NotExists', false], - ])); - $this->assertTrue($this->_model->isEnabled('Module_Exists')); - $this->assertFalse($this->_model->isEnabled('Module_NotExists')); - } - - public function testIsOutputEnabledReturnsFalseForDisabledModule() - { - $this->_outputConfig->expects($this->any())->method('isSetFlag')->will($this->returnValue(true)); - $this->assertFalse($this->_model->isOutputEnabled('Disabled_Module')); - } - - /** - * @param bool $configValue - * @param bool $expectedResult - * @dataProvider isOutputEnabledGenericConfigPathDataProvider - */ - public function testIsOutputEnabledGenericConfigPath($configValue, $expectedResult) - { - $this->_moduleList->expects($this->once())->method('has')->will($this->returnValue(true)); - $this->_outputConfig->expects($this->once()) - ->method('isEnabled') - ->with('Module_One') - ->will($this->returnValue($configValue)); - $this->assertEquals($expectedResult, $this->_model->isOutputEnabled('Module_One')); - } + $this->moduleList->expects($this->exactly(2)) + ->method('has') + ->willReturnMap( + [ + ['Module_Exists', true], + ['Module_NotExists', false], + ] + ); - public function isOutputEnabledGenericConfigPathDataProvider() - { - return ['output disabled' => [true, false], 'output enabled' => [false, true]]; - } - - /** - * @param bool $configValue - * @param bool $expectedResult - * @dataProvider isOutputEnabledCustomConfigPathDataProvider - */ - public function testIsOutputEnabledCustomConfigPath($configValue, $expectedResult) - { - $this->_moduleList->expects($this->once())->method('has')->will($this->returnValue(true)); - $this->_outputConfig->expects($this->at(0)) - ->method('isSetFlag') - ->with(self::XML_PATH_OUTPUT_ENABLED) - ->will($this->returnValue($configValue)); - $this->assertEquals($expectedResult, $this->_model->isOutputEnabled('Module_Two')); - } - - public function isOutputEnabledCustomConfigPathDataProvider() - { - return [ - 'path literal, output disabled' => [false, false], - 'path literal, output enabled' => [true, true], - ]; + $this->assertTrue($this->model->isEnabled('Module_Exists')); + $this->assertFalse($this->model->isEnabled('Module_NotExists')); } } diff --git a/lib/internal/Magento/Framework/View/Element/AbstractBlock.php b/lib/internal/Magento/Framework/View/Element/AbstractBlock.php index bebeb7917f5010e768ac6b10ce4ca139de98900d..ee0b51b4b71d0dccae94956fcc44593340bbf992 100644 --- a/lib/internal/Magento/Framework/View/Element/AbstractBlock.php +++ b/lib/internal/Magento/Framework/View/Element/AbstractBlock.php @@ -647,12 +647,7 @@ abstract class AbstractBlock extends \Magento\Framework\DataObject implements Bl public function toHtml() { $this->_eventManager->dispatch('view_block_abstract_to_html_before', ['block' => $this]); - if ($this->_scopeConfig->getValue( - 'advanced/modules_disable_output/' . $this->getModuleName(), - \Magento\Store\Model\ScopeInterface::SCOPE_STORE - )) { - return ''; - } + $this->getModuleName(); $html = $this->_loadCache(); if ($html === false) { diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Element/AbstractBlockTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Element/AbstractBlockTest.php index b6846b52972e8b12287f727e56866c5452d04dcf..b6fde2c0f6a7fe465a82b47108dd9d9dd57b99a8 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Element/AbstractBlockTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Element/AbstractBlockTest.php @@ -3,9 +3,6 @@ * Copyright © 2013-2017 Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ - -// @codingStandardsIgnoreFile - namespace Magento\Framework\View\Test\Unit\Element; use Magento\Framework\View\Element\AbstractBlock; @@ -207,13 +204,12 @@ class AbstractBlockTest extends \PHPUnit_Framework_TestCase $moduleName = 'Test'; $this->block->setData('module_name', $moduleName); - $this->eventManagerMock->expects($this->any()) + $this->eventManagerMock->expects($this->exactly(2)) ->method('dispatch') - ->with('view_block_abstract_to_html_before', ['block' => $this->block]); - $this->scopeConfigMock->expects($this->once()) - ->method('getValue') - ->with('advanced/modules_disable_output/' . $moduleName, \Magento\Store\Model\ScopeInterface::SCOPE_STORE) - ->willReturn(true); + ->willReturnMap([ + ['view_block_abstract_to_html_before', ['block' => $this->block]], + ['view_block_abstract_to_html_after', ['block' => $this->block]], + ]); $this->assertSame('', $this->block->toHtml()); } @@ -246,10 +242,6 @@ class AbstractBlockTest extends \PHPUnit_Framework_TestCase $this->eventManagerMock->expects($expectsDispatchEvent) ->method('dispatch'); - $this->scopeConfigMock->expects($this->once()) - ->method('getValue') - ->with('advanced/modules_disable_output/' . $moduleName, \Magento\Store\Model\ScopeInterface::SCOPE_STORE) - ->willReturn(false); $this->cacheStateMock->expects($this->any()) ->method('isEnabled') ->with(AbstractBlock::CACHE_GROUP)