Exemplo n.º 1
0
 public function testViewGeneratesCorrectLookingYAMLForCore()
 {
     $view = new TravisYmlView();
     // no setPlugin call here signifies generating for core
     $view->processExistingTravisYml(PIWIK_INCLUDE_PATH . '/.travis.yml');
     $view->setExtraGlobalEnvVars(array('secure: artifactspass', 'secure: githubtoken'));
     $view->setGenerateYmlCommand('./console generate:travis-yml \'arg1\' arg2');
     $output = $view->render();
     $yaml = Spyc::YAMLLoadString($output);
     $this->assertNotEmpty($yaml['env']);
     $this->assertNotEmpty($yaml['env']['global']);
     $this->assertBuildSectionsNotEmpty($yaml);
     $this->assertViewDoesNotUsePluginSpecifiedTravisCommands($yaml);
 }
 private function createTravisYmlView(InputInterface $input, OutputInterface $output, $targetPlugin, $outputYmlPath)
 {
     $view = new TravisYmlView();
     $view->setPlugin($targetPlugin);
     $thisConsoleCommand = $this->getExecutedConsoleCommandForTravis($input);
     $view->setGenerateYmlCommand($thisConsoleCommand);
     $phpVersions = $input->getOption('php-versions');
     if (!empty($phpVersions)) {
         $view->setPhpVersions(explode(',', $phpVersions));
     }
     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>");
     }
     $this->setExtraEnvironmentVariables($view, $input, $output);
     return $view;
 }
 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}'!"));
 }