N98\Magento\ApplicationTest::testExecute PHP Method

testExecute() public method

public testExecute ( )
    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('cl' => 'cache: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'));
        // Test alternative config model
        $application->initMagento();
        if (version_compare(\Mage::getVersion(), '1.7.0.2', '>=')) {
            // config_model option is only available in Magento CE >1.6
            $this->assertInstanceOf('\\N98MagerunTest\\AlternativeConfigModel', \Mage::getConfig());
        }
        // check alias
        $this->assertInstanceOf('\\N98\\Magento\\Command\\Cache\\ListCommand', $application->find('cl'));
    }