예제 #1
0
 public function testViewGeneratesCorrectLookingYAML()
 {
     $view = new TravisYmlView();
     $view->setGenerationMode('plugin');
     $view->setPlugin('ExamplePlugin');
     $view->setExtraGlobalEnvVars(array('secure: artifactspass', 'secure: githubtoken'));
     $view->setGenerateYmlCommand('./console generate:travis-yml \'arg1\' arg2');
     $view->setPathToCustomTravisStepsFiles(PIWIK_INCLUDE_PATH . '/plugins/ExamplePlugin/tests/travis');
     $view->setLatestStableVersion('2.14.0');
     $view->setTestsToRun(array(array('name' => "PluginTests", 'vars' => "MYSQL_ADAPTER=PDO_MYSQL"), array('name' => "PluginTests", 'vars' => "MYSQL_ADAPTER=PDO_MYSQL TEST_AGAINST_CORE=latest_stable")));
     $view->useNewTravisInfrastructure();
     $output = $view->render();
     $yaml = Spyc::YAMLLoadString($output);
     $this->assertNotEmpty($yaml['env']);
     $this->assertNotEmpty($yaml['env']['global']);
     $this->assertContains("PLUGIN_NAME=ExamplePlugin", $yaml['env']['global']);
     $this->assertContains("PIWIK_ROOT_DIR=\$TRAVIS_BUILD_DIR/piwik", $yaml['env']['global']);
     $this->assertContains(array('secure' => 'artifactspass'), $yaml['env']['global']);
     $this->assertContains(array('secure' => 'githubtoken'), $yaml['env']['global']);
     $this->assertNotEmpty($yaml['env']['matrix']);
     $this->assertContains("TEST_SUITE=PluginTests MYSQL_ADAPTER=PDO_MYSQL", $yaml['env']['matrix']);
     $this->assertContains("TEST_SUITE=PluginTests MYSQL_ADAPTER=PDO_MYSQL TEST_AGAINST_CORE=latest_stable", $yaml['env']['matrix']);
     $this->assertNotContains("TEST_SUITE=UITests MYSQL_ADAPTER=PDO_MYSQL", $yaml['env']['matrix']);
     $this->assertEquals(false, $yaml['sudo']);
     $this->assertBuildSectionsNotEmpty($yaml);
     $this->assertContains("export GENERATE_TRAVIS_YML_COMMAND=\"./console generate:travis-yml \\'arg1\\' arg2\"", $yaml['install']);
     $this->assertViewUsesPluginSpecifiedTravisCommands($yaml);
     $this->assertViewUsesPluginSpecifiedAptPackages($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();
     }
 }