public function testViewGeneratesCorrectLookingYAMLForCore()
 {
     $view = new TravisYmlView();
     $view->setGenerationMode('core');
     // no setPlugin call here signifies generating for core
     $parser = new Parser();
     $existingSections = $parser->processExistingTravisYml(__DIR__ . '/../resources/test.travis.yml');
     $view->setExistingSections($existingSections);
     $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);
     $this->assertViewDoesNotUsePluginSpecifiedAptPackages($yaml);
 }
示例#2
0
 protected function configureView()
 {
     if (empty($this->minimumPhpVersion)) {
         $this->setMinimumPhpVersionFromPhpVersions();
     }
     $this->log("info", "Using minimum PHP version: {$this->minimumPhpVersion}");
     $thisConsoleCommand = $this->getExecutedConsoleCommandForTravis();
     $this->view->setGenerateYmlCommand($thisConsoleCommand);
     if (!empty($this->phpVersions)) {
         $phpVersions = $this->getPhpVersionsKnownToExistOnTravis();
         $this->view->setPhpVersions($phpVersions);
     }
     $outputYmlPath = $this->getTravisYmlOutputPath();
     if (file_exists($outputYmlPath)) {
         $this->log('info', "Found existing YAML file at {$outputYmlPath}.");
         $parser = new Parser();
         $existingSections = $parser->processExistingTravisYml($outputYmlPath);
         $this->view->setExistingSections($existingSections);
     } else {
         $this->log('info', "Could not find existing YAML file at {$outputYmlPath}, generating a new one.");
     }
     $this->setExtraEnvironmentVariables();
     if (!empty($this->options['sudo-false'])) {
         $this->view->useNewTravisInfrastructure();
     }
 }