IvanChepurnyi/EcomDev_PHPUnit — Issue #26: Adminhtml controller dispatch issue
Author: Demoli
Created: 2012-03-09 13:50:45+00:00
State: open

Hello

I'm trying to test my adminhtml controllers, each test works fine in isolation, but as soon as I have 2 test cases that dispatch a request, I get a fatal error.

I've created a gist with the relevant classes https://gist.github.com/2006542
The abstract.php is just to create a fake admin user and set the session.

It looks to me like the layout is not being cleared, so when dispatch is called twice the functions / classes involved in rendering it have already been included and declared.

This doesn't occur when testing frontend controllers.

I'm using the master branch, I haven't tried this on dev as I haven't had much luck getting it to work on my test box.

**Stack Trace**

Fatal error: Cannot redeclare drawMenuLevel() (previously declared in [redacted]\magento\app\design\adminhtml\default\default\template\page\menu.phtml:33) in [redacted]\magento\app\design\adminhtml\default\default\template\page\menu.phtml on line 43

Call Stack:
0.0004 327888 1. {main}() [redacted]\php\phpunit:0
0.0195 764928 2. PHPUnit_TextUI_Command::main() [redacted]\php\phpunit:44
0.0195 765280 3. PHPUnit_TextUI_Command->run() [redacted]\php\PEAR\PHPUnit\TextUI\Command.php:125
0.4717 13550840 4. PHPUnit_TextUI_TestRunner->doRun() [redacted]\php\PEAR\PHPUnit\TextUI\Command.php:187
20.3997 15425856 5. PHPUnit_Framework_TestSuite->run() [redacted]\php\PEAR\PHPUnit\TextUI\TestRunner.php:325
20.3998 15427864 6. PHPUnit_Framework_TestSuite->run() [redacted]\php\PEAR\PHPUnit\Framework\TestSuite.php:705
29.6948 35766328 7. PHPUnit_Framework_TestSuite->run() [redacted]\php\PEAR\PHPUnit\Framework\TestSuite.php:705
29.6952 35766568 8. PHPUnit_Framework_TestSuite->runTest() [redacted]\php\PEAR\PHPUnit\Framework\TestSuite.php:745
29.6952 35766568 9. PHPUnit_Framework_TestCase->run() [redacted]\php\PEAR\PHPUnit\Framework\TestSuite.php:772
29.6953 35766568 10. PHPUnit_Framework_TestResult->run() [redacted]\php\PEAR\PHPUnit\Framework\TestCase.php:748
29.6984 35769360 11. PHPUnit_Framework_TestCase->runBare() [redacted]\php\PEAR\PHPUnit\Framework\TestResult.php:649
29.8478 36000912 12. PHPUnit_Framework_TestCase->runTest() [redacted]\php\PEAR\PHPUnit\Framework\TestCase.php:801
29.8479 36001800 13. ReflectionMethod->invokeArgs() [redacted]\php\PEAR\PHPUnit\Framework\TestCase.php:939
29.8479 36001816 14. Skywire_PressRelease_Test_Controller_Adminhtml_IndexAction->testIndexAction() [redacted]\php\PEAR\PHPUnit\Framework\TestCase.php:939
29.8479 36001888 15. EcomDev_PHPUnit_Test_Case_Controller->dispatch() [redacted]\magento\app\code\local\Skywire\PressRelease\Test\Controller\Adminhtml\IndexAction.php:36
29.8683 36032752 16. Mage_Core_Controller_Varien_Front->dispatch() [redacted]\magento\app\code\community\EcomDev\PHPUnit\Test\Case\Controller.php:1978
29.8769 36032816 17. Mage_Core_Controller_Varien_Router_Standard->match() [redacted]\magento\app\code\core\Mage\Core\Controller\Varien\Front.php:176
29.8805 36033328 18. Mage_Core_Controller_Varien_Action->dispatch() [redacted]\magento\app\code\core\Mage\Core\Controller\Varien\Router\Standard.php:250
29.9068 36034296 19. Skywire_PressRelease_Adminhtml_IndexController->indexAction() [redacted]\magento\app\code\core\Mage\Core\Controller\Varien\Action.php:420
30.0618 36193448 20. Mage_Core_Controller_Varien_Action->renderLayout() [redacted]\magento\app\code\local\Skywire\PressRelease\controllers\Adminhtml\IndexController.php:35
30.0636 36194152 21. EcomDev_PHPUnit_Model_Layout->getOutput() [redacted]\magento\app\code\core\Mage\Core\Controller\Varien\Action.php:391
30.0637 36194672 22. Mage_Core_Model_Layout->getOutput() [redacted]\magento\app\code\community\EcomDev\PHPUnit\Model\Layout.php:492
30.0637 36194720 23. Mage_Core_Block_Abstract->toHtml() [redacted]\magento\app\code\core\Mage\Core\Model\Layout.php:529
30.0650 36195152 24. Mage_Adminhtml_Block_Template->_toHtml() [redacted]\magento\app\code\core\Mage\Core\Block\Abstract.php:863
30.0653 36195360 25. Mage_Core_Block_Template->_toHtml() [redacted]\magento\app\code\core\Mage\Adminhtml\Block\Template.php:81
30.0654 36195360 26. Mage_Core_Block_Template->renderView() [redacted]\magento\app\code\core\Mage\Core\Block\Template.php:286
30.0707 36195448 27. Mage_Core_Block_Template->fetchView() [redacted]\magento\app\code\core\Mage\Core\Block\Template.php:272
30.0723 36264480 28. include('[redacted]\magento\app\design\adminhtml\default\default\template\page.phtml') [redacted]\magento\app\code\core\Mage\Core\Block\Template.php:241
30.3002 36262896 29. Mage_Core_Block_Abstract->getChildHtml() [redacted]\magento\app\design\adminhtml\default\default\template\page.phtml:53
30.3002 36262960 30. Mage_Core_Block_Abstract->_getChildHtml() [redacted]\magento\app\code\core\Mage\Core\Block\Abstract.php:526
30.3003 36262960 31. Mage_Core_Block_Abstract->toHtml() [redacted]\magento\app\code\core\Mage\Core\Block\Abstract.php:582
30.3016 36263104 32. Mage_Adminhtml_Block_Template->_toHtml() [redacted]\magento\app\code\core\Mage\Core\Block\Abstract.php:863
30.3019 36263104 33. Mage_Core_Block_Template->_toHtml() [redacted]\magento\app\code\core\Mage\Adminhtml\Block\Template.php:81
30.3019 36263104 34. Mage_Core_Block_Template->renderView() [redacted]\magento\app\code\core\Mage\Core\Block\Template.php:286
30.3064 36263200 35. Mage_Core_Block_Template->fetchView() [redacted]\magento\app\code\core\Mage\Core\Block\Template.php:272

iew() [redacted]\magento\app\code\core\Mage\Core\Block\Template.php:286
PHP 35. Mage_Core_Block_Template->fetchView() [redacted]\magento\app\code\core\Mage\Core\Block\Template.php:272