Testing Block output
-
30-09-2020 - |
Frage
I made a customization to the TopMenu and want to run an integration test.
I have the following code:
/**
* Check if menu items have the right URL
*/
public function testUrlInMenu()
{
\Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Framework\App\State')
->setAreaCode(Area::AREA_FRONTEND);
\Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(
'Magento\Framework\View\DesignInterface'
)->setDesignTheme(
'Magento/blank'
);
/**
* @var $layout \Magento\Framework\View\LayoutInterface
*/
$layout = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(
\Magento\Framework\View\LayoutInterface::class
);
$block = $layout->addBlock(\Magento\Theme\Block\Html\Topmenu::class, 'test');
$result = $block->toHtml();
$this->assertContains('http://localhost/index.php/', $result);
}
This test fails with
BadMethodCallException : Missing required argument $debugHintsPath of Magento\Developer\Model\TemplateEngine\Plugin\DebugHints.
/foo/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php:45
/foo/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php:82
/foo/vendor/magento/framework/ObjectManager/ObjectManager.php:71
/foo/vendor/magento/framework/Interception/PluginList/PluginList.php:233
/foo/vendor/magento/framework/Interception/Interceptor.php:151
/foo/var/generation/Magento/Framework/View/TemplateEngineFactory/Interceptor.php:26
/foo/vendor/magento/framework/View/TemplateEnginePool.php:44
/foo/vendor/magento/framework/View/Element/Template.php:254
/foo/var/generation/Magento/Theme/Block/Html/Topmenu/Interceptor.php:167
/foo/vendor/magento/framework/View/Element/Template.php:279
/foo/vendor/magento/framework/View/Element/AbstractBlock.php:659
/foo/var/generation/Magento/Theme/Block/Html/Topmenu/Interceptor.php:479
/foo/vendor/mestrona/magento-module-categoryredirect/Test/Integration/CatalogAttributesTest.php:110
How can I fix this?
Lösung
debugHintsPath is not defined for global aria.
Can you try add @magentoAppArea frontend
to you test? I hope it will resolve problem.
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit magento.stackexchange