public function getApplication()
{
if ($this->application === null) {
$root = $this->getTestMagentoRoot();
/** @var Application|PHPUnit_Framework_MockObject_MockObject $application */
$application = $this->getMock('N98\\Magento\\Application', array('getMagentoRootFolder'));
// Get the composer bootstrap
if (defined('PHPUNIT_COMPOSER_INSTALL')) {
$loader = (require PHPUNIT_COMPOSER_INSTALL);
} elseif (file_exists(__DIR__ . '/../../../../../../autoload.php')) {
// Installed via composer, already in vendor
$loader = (require __DIR__ . '/../../../../../../autoload.php');
} else {
// Check if testing root package without PHPUnit
$loader = (require __DIR__ . '/../../../../vendor/autoload.php');
}
$application->setAutoloader($loader);
$application->expects($this->any())->method('getMagentoRootFolder')->will($this->returnValue($root));
spl_autoload_unregister(array(\Varien_Autoload::instance(), 'autoload'));
$application->init();
$application->initMagento();
if ($application->getMagentoMajorVersion() == Application::MAGENTO_MAJOR_VERSION_1) {
spl_autoload_unregister(array(\Varien_Autoload::instance(), 'autoload'));
}
$this->application = $application;
}
return $this->application;
}