/** * @throws \RuntimeException * @return PHPUnit_Framework_MockObject_MockObject|\IMI\Contao\Application */ public function getApplication() { if ($this->application === null) { $root = getenv('IMI_MAGERUN_TEST_MAGENTO_ROOT'); if (empty($root)) { throw new \RuntimeException('Please specify environment variable IMI_MAGERUN_TEST_MAGENTO_ROOT with path to your test contao installation!'); } $this->application = $this->getMock('IMI\\Contao\\Application', array('getContaoRootFolder')); $loader = (require __DIR__ . '/../../../../../vendor/autoload.php'); $this->application->setAutoloader($loader); $this->application->expects($this->any())->method('getContaoRootFolder')->will($this->returnValue($root)); $this->application->init(); $this->application->initContao(); if ($this->application->getContaoMajorVersion() == Application::MAGENTO_MAJOR_VERSION_1) { spl_autoload_unregister(array(\Varien_Autoload::instance(), 'autoload')); } } return $this->application; }