protected function execute(InputInterface $input, OutputInterface $output)
 {
     $targetPlugin = $input->getOption('plugin');
     $artifactsPass = $input->getOption('artifacts-pass');
     $githubToken = $input->getOption('github-token');
     $outputYmlPath = $this->getTravisYmlOutputPath($input, $targetPlugin);
     $thisConsoleCommand = $this->getExecutedConsoleCommandForTravis($input);
     $view = new TravisYmlView();
     if (file_exists($outputYmlPath)) {
         $output->writeln("<info>Found existing YAML file at {$outputYmlPath}.</info>");
         $view->processExistingTravisYml($outputYmlPath);
     } else {
         $output->writeln("<info>Could not find existing YAML file at {$outputYmlPath}, generating a new one.</info>");
     }
     $view->configure($targetPlugin, $artifactsPass, $githubToken, $thisConsoleCommand, $output);
     $travisYmlContents = $view->render();
     $writePath = $input->getOption('dump');
     if (empty($writePath)) {
         $writePath = $outputYmlPath;
     }
     file_put_contents($writePath, $travisYmlContents);
     $this->writeSuccessMessage($output, array("Generated .travis.yml file at '{$writePath}'!"));
 }
예제 #2
0
 public function testViewGeneratesCorrectLookingYAMLWhenCustomPhpVersionsUsed()
 {
     $view = new TravisYmlView();
     $view->setPlugin('ExamplePlugin');
     $view->setPhpVersions(array('5.4', '5.6', 'hhvm'));
     $view->setGenerateYmlCommand('./console generate:travis-yml arg1 arg2');
     $output = $view->render();
     $yaml = Spyc::YAMLLoadString($output);
     $this->assertNotEmpty($yaml['php']);
     $this->assertEquals(array('5.4', '5.6', 'hhvm'), $yaml['php']);
 }