Beispiel #1
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();
     }
 }
 public function testViewGeneratesCorrectLookingYAMLWhenCustomPhpVersionsUsed()
 {
     $view = new TravisYmlView();
     $view->setGenerationMode('plugin');
     $view->setPlugin('ExamplePlugin');
     $view->setPhpVersions(array('5.4', '5.6', 'hhvm'));
     $view->setLatestStableVersion('2.14.0');
     $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']);
 }