public function testExecute()
{
/**
* Check autoloading
*/
/* @var $application Application */
$application = (require __DIR__ . '/../../../src/bootstrap.php');
$application->setMagentoRootFolder($this->getTestMagentoRoot());
$this->assertInstanceOf('\\N98\\Magento\\Application', $application);
$loader = $application->getAutoloader();
$this->assertInstanceOf('\\Composer\\Autoload\\ClassLoader', $loader);
/**
* Check version
*/
$this->assertEquals(Application::APP_VERSION, trim(file_get_contents(__DIR__ . '/../../../version.txt')));
/* @var $loader \Composer\Autoload\ClassLoader */
$prefixes = $loader->getPrefixes();
$this->assertArrayHasKey('N98', $prefixes);
$distConfigArray = Yaml::parse(file_get_contents(__DIR__ . '/../../../config.yaml'));
$configArray = array('autoloaders' => array('N98MagerunTest' => __DIR__ . '/_ApplicationTestSrc'), 'commands' => array('customCommands' => array(0 => 'N98MagerunTest\\TestDummyCommand'), 'aliases' => array(array('ssl' => 'sys:store:list'))), 'init' => array('options' => array('config_model' => 'N98MagerunTest\\AlternativeConfigModel')));
$application->setAutoExit(false);
$application->init(ArrayFunctions::mergeArrays($distConfigArray, $configArray));
$application->run(new StringInput('list'), new NullOutput());
// Check if autoloaders, commands and aliases are registered
$prefixes = $loader->getPrefixes();
$this->assertArrayHasKey('N98MagerunTest', $prefixes);
$testDummyCommand = $application->find('n98mageruntest:test:dummy');
$this->assertInstanceOf('\\N98MagerunTest\\TestDummyCommand', $testDummyCommand);
$commandTester = new CommandTester($testDummyCommand);
$commandTester->execute(array('command' => $testDummyCommand->getName()));
$this->assertContains('dummy', $commandTester->getDisplay());
$this->assertTrue($application->getDefinition()->hasOption('root-dir'));
// check alias
$this->assertInstanceOf('\\N98\\Magento\\Command\\System\\Store\\ListCommand', $application->find('ssl'));
}