public function testViewPreservesCommentsAndEnvVarsIfExistingYml() { $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'); $parser = new Parser(); $existingSections = $parser->processExistingTravisYml(__DIR__ . '/../resources/test.travis.yml'); $view->setExistingSections($existingSections); $output = $view->render(); $yaml = Spyc::YAMLLoadString($output); $this->assertNotEmpty($yaml['env']); $this->assertNotEmpty($yaml['env']['global']); $this->assertContains("PRESERVED_VAR=123", $yaml['env']['global']); $this->assertContains(array('secure' => 'anotherpreservedvar'), $yaml['env']['global']); $this->assertNotContains("PLUGIN_NAME=ExamplePlugin", $yaml['env']['global']); $this->assertNotContains("PIWIK_ROOT_DIR=\$TRAVIS_BUILD_DIR/piwik", $yaml['env']['global']); $this->assertEquals('required', $yaml['sudo']); $this->assertBuildSectionsNotEmpty($yaml); $this->assertNotEmpty($yaml['custom_section']); $this->assertContains("custom_section:\n - this will be preserved\n # as should this", $output); $this->assertNotEmpty($yaml['notifications']); $this->assertContains("notifications:\n # another section\n - a\n - b\n - c", $output); $this->assertViewUsesPluginSpecifiedTravisCommands($yaml); $this->assertViewUsesPluginSpecifiedAptPackages($yaml); }