public function testIsDevAllowed() { $store = 'some store'; $result = 'result'; $this->helperMock->expects($this->once())->method('isDevAllowed')->with($store)->will($this->returnValue($result)); $this->assertEquals($result, $this->model->isDevAllowed($store)); }
/** * @param array $allowedIps * @param bool $expected * @dataProvider isDevAllowedDataProvider */ public function testIsDevAllowed($allowedIps, $expected, $callNum = 1) { $storeId = 'storeId'; $this->scopeConfigMock->expects($this->once())->method('getValue')->with(\Magento\Developer\Helper\Data::XML_PATH_DEV_ALLOW_IPS, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $storeId)->will($this->returnValue($allowedIps)); $this->remoteAddressMock->expects($this->once())->method('getRemoteAddress')->will($this->returnValue('remoteAddress')); $this->httpHeaderMock->expects($this->exactly($callNum))->method('getHttpHost')->will($this->returnValue('httpHost')); $this->assertEquals($expected, $this->helper->isDevAllowed($storeId)); }
/** * Wrap template engine instance with the debugging hints decorator, depending of the store configuration * * @param \Magento\Framework\View\TemplateEngineFactory $subject * @param \Magento\Framework\View\TemplateEngineInterface $invocationResult * * @return \Magento\Framework\View\TemplateEngineInterface * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function afterCreate(\Magento\Framework\View\TemplateEngineFactory $subject, \Magento\Framework\View\TemplateEngineInterface $invocationResult) { if ($this->scopeConfig->getValue(self::XML_PATH_DEBUG_TEMPLATE_HINTS, ScopeInterface::SCOPE_STORE) && $this->devHelper->isDevAllowed()) { $showBlockHints = $this->scopeConfig->getValue(self::XML_PATH_DEBUG_TEMPLATE_HINTS_BLOCKS, ScopeInterface::SCOPE_STORE); return $this->objectManager->create('Magento\\Developer\\Model\\TemplateEngine\\Decorator\\DebugHints', ['subject' => $invocationResult, 'showBlockHints' => $showBlockHints]); } return $invocationResult; }
/** * @magentoConfigFixture current_store dev/restrict/allow_ips 192.168.0.1 * @magentoAppIsolation enabled */ public function testIsDevAllowedFalse() { $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); /** @var \Magento\TestFramework\Request $request */ $request = $objectManager->get('Magento\\TestFramework\\Request'); $request->setServer(new Parameters(['REMOTE_ADDR' => '192.168.0.3'])); $this->assertFalse($this->helper->isDevAllowed()); }
/** * @param string $debugHintsPath * @param bool $isDevAllowed * @param bool $showTemplateHints * @return void * @dataProvider afterCreateInactiveDataProvider */ public function testAfterCreateInactive($debugHintsPath, $isDevAllowed, $showTemplateHints) { $this->devHelperMock->expects($this->any())->method('isDevAllowed')->willReturn($isDevAllowed); $this->setupConfigFixture($debugHintsPath, $showTemplateHints, true); $engine = $this->getMock('Magento\\Framework\\View\\TemplateEngineInterface'); $subjectMock = $this->getMockBuilder('Magento\\Framework\\View\\TemplateEngineFactory')->disableOriginalConstructor()->getMock(); $debugHints = new DebugHints($this->scopeConfigMock, $this->storeManager, $this->devHelperMock, $this->debugHintsFactory, $debugHintsPath); $this->assertSame($engine, $debugHints->afterCreate($subjectMock, $engine)); }
/** * Wrap template engine instance with the debugging hints decorator, depending of the store configuration * * @param TemplateEngineFactory $subject * @param TemplateEngineInterface $invocationResult * * @return TemplateEngineInterface * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function afterCreate(TemplateEngineFactory $subject, TemplateEngineInterface $invocationResult) { $storeCode = $this->storeManager->getStore()->getCode(); if ($this->scopeConfig->getValue($this->debugHintsPath, ScopeInterface::SCOPE_STORE, $storeCode) && $this->devHelper->isDevAllowed()) { $showBlockHints = $this->scopeConfig->getValue(self::XML_PATH_DEBUG_TEMPLATE_HINTS_BLOCKS, ScopeInterface::SCOPE_STORE, $storeCode); return $this->debugHintsFactory->create(['subject' => $invocationResult, 'showBlockHints' => $showBlockHints]); } return $invocationResult; }
/** * {@inheritdoc} */ public function isDevAllowed($scope = null) { return $this->devHelper->isDevAllowed($scope); }