Пример #1
0
 public function testExecute()
 {
     /**
      * Check autoloading
      */
     $application = (require __DIR__ . '/../../../src/bootstrap.php');
     $application->setContaoRootFolder(getenv('IMI_MAGERUN_TEST_MAGENTO_ROOT'));
     /* @var $application Application */
     $this->assertInstanceOf('\\IMI\\Contao\\Application', $application);
     $loader = $application->getAutoloader();
     $this->assertInstanceOf('\\Composer\\Autoload\\ClassLoader', $loader);
     /**
      * Check version
      */
     $this->assertEquals(\IMI\Contao\Application::APP_VERSION, trim(file_get_contents(__DIR__ . '/../../../version.txt')));
     /* @var $loader \Composer\Autoload\ClassLoader */
     $prefixes = $loader->getPrefixes();
     $this->assertArrayHasKey('IMI', $prefixes);
     $distConfigArray = Yaml::parse(file_get_contents(__DIR__ . '/../../../config.yaml'));
     $configArray = array('autoloaders' => array('IMIContrunTest' => __DIR__ . '/_ApplicationTestSrc'), 'commands' => array('customCommands' => array(0 => 'IMIContrunTest\\TestDummyCommand'), 'aliases' => array(array('cl' => 'cache:list'))), 'init' => array('options' => array('config_model' => 'IMIContrunTest\\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('IMIContrunTest', $prefixes);
     $testDummyCommand = $application->find('imiconruntest:test:dummy');
     $this->assertInstanceOf('\\IMIContrunTest\\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->initContao();
     if (version_compare(\Mage::getVersion(), '1.7.0.2', '>=')) {
         // config_model option is only available in Contao CE >1.6
         $this->assertInstanceOf('\\IMIContrunTest\\AlternativeConfigModel', \Mage::getConfig());
     }
     // check alias
     $this->assertInstanceOf('\\IMI\\Contao\\Command\\Cache\\ListCommand', $application->find('cl'));
 }
 /**
  * Loads a plugin config file and merges it to plugin config
  *
  * @param string       $contaoRootFolder
  * @param SplFileInfo $file
  */
 protected function registerPluginConfigFile($contaoRootFolder, $file)
 {
     if (String::startsWith($file->getPathname(), 'vfs://')) {
         $path = $file->getPathname();
     } else {
         $path = $file->getRealPath();
     }
     if (OutputInterface::VERBOSITY_DEBUG <= $this->_output->getVerbosity()) {
         $this->_output->writeln('<debug>Load plugin config <comment>' . $path . '</comment></debug>');
     }
     $localPluginConfig = \file_get_contents($path);
     $localPluginConfig = Yaml::parse($this->applyVariables($localPluginConfig, $contaoRootFolder, $file));
     $this->_pluginConfig = ArrayFunctions::mergeArrays($this->_pluginConfig, $localPluginConfig);
 }
Пример #3
0
 /**
  * @param array $initConfig
  * @param OutputInterface $output
  * @return ConfigurationLoader
  */
 public function getConfigurationLoader(array $initConfig = array(), OutputInterface $output)
 {
     if ($this->configurationLoader === null) {
         $this->configurationLoader = new ConfigurationLoader(ArrayFunctions::mergeArrays($this->config, $initConfig), $this->isPharMode(), $output);
     }
     return $this->configurationLoader;
 }