diff options
author | diosmosis <benaka@piwik.pro> | 2015-07-19 01:54:24 +0300 |
---|---|---|
committer | diosmosis <benaka@piwik.pro> | 2015-07-19 01:54:24 +0300 |
commit | 01bae0c2f79ca589f1964a13409117e8bcfc4849 (patch) | |
tree | 007b5c15d4cb0205d66d948b55ac9466410335dc /plugins/TestRunner | |
parent | 96a6805ea68b362f232598e6b799bd0abda14811 (diff) |
Move tests for travis.yml generation from core to travis-scripts repo.
Diffstat (limited to 'plugins/TestRunner')
-rw-r--r-- | plugins/TestRunner/tests/Integration/TravisYmlViewTest.php | 185 | ||||
-rw-r--r-- | plugins/TestRunner/tests/resources/test.travis.yml | 55 |
2 files changed, 0 insertions, 240 deletions
diff --git a/plugins/TestRunner/tests/Integration/TravisYmlViewTest.php b/plugins/TestRunner/tests/Integration/TravisYmlViewTest.php deleted file mode 100644 index aa9bdc91e4..0000000000 --- a/plugins/TestRunner/tests/Integration/TravisYmlViewTest.php +++ /dev/null @@ -1,185 +0,0 @@ -<?php -/** - * Piwik - free/libre analytics platform - * - * @link http://piwik.org - * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later - * - */ -namespace Piwik\Plugins\TestRunner\tests\Integration; - -use Piwik\Plugins\TestRunner\TravisYml\Parser; -use Piwik\Plugins\TestRunner\TravisYml\TravisYmlView; -use Piwik\Plugin\Manager as PluginManager; -use PHPUnit_Framework_TestCase; -use Spyc; // DeviceDectector requires Spyc - -/** - * @group TestRunner - * @group TestRunner_TravisYmlViewTest - */ -class TravisYmlViewTest extends PHPUnit_Framework_TestCase -{ - public function setUp() - { - PluginManager::getInstance()->loadPlugin('Morpheus'); - PluginManager::getInstance()->loadPlugin('TestRunner'); - } - - 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->setLatestStable('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") - )); - $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->assertBuildSectionsNotEmpty($yaml); - - $this->assertContains("export GENERATE_TRAVIS_YML_COMMAND=\"./console generate:travis-yml \\'arg1\\' arg2\"", $yaml['before_script']); - - $this->assertViewUsesPluginSpecifiedTravisCommands($yaml); - } - - 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(PIWIK_INCLUDE_PATH . '/plugins/TestRunner/tests/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->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); - } - - public function testViewGeneratesCorrectLookingYAMLForCore() - { - $view = new TravisYmlView(); - $view->setGenerationMode('core'); - - // no setPlugin call here signifies generating for core - $parser = new Parser(); - $existingSections = $parser->processExistingTravisYml(PIWIK_INCLUDE_PATH . '/plugins/TestRunner/tests/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); - } - - public function testViewGeneratesCorrectLookingYAMLWhenCustomPhpVersionsUsed() - { - $view = new TravisYmlView(); - $view->setGenerationMode('plugin'); - $view->setPlugin('ExamplePlugin'); - $view->setPhpVersions(array('5.4', '5.6', 'hhvm')); - $view->setLatestStable('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']); - } - - private function assertBuildSectionsNotEmpty($yaml) - { - $this->assertNotEmpty($yaml['before_install']); - $this->assertNotEmpty($yaml['install']); - $this->assertNotEmpty($yaml['before_script']); - $this->assertNotEmpty($yaml['after_script']); - $this->assertNotEmpty($yaml['after_success']); - } - - private function assertViewUsesPluginSpecifiedTravisCommands($yaml) - { - $this->assertEquals("before_install hook line 1", reset($yaml['before_install'])); - $this->assertEquals("before_install hook line 2", end($yaml['before_install'])); - - $this->assertEquals("before_script hook line 1", reset($yaml['before_script'])); - $this->assertEquals("before_script hook line 2", end($yaml['before_script'])); - - $this->assertEquals("install hook line 1", reset($yaml['install'])); - $this->assertEquals("install hook line 2", end($yaml['install'])); - - $this->assertEquals("after_success hook line 1", reset($yaml['after_success'])); - $this->assertEquals("after_success hook line 2", end($yaml['after_success'])); - - $this->assertEquals("after_script hook line 1", reset($yaml['after_script'])); - $this->assertEquals("after_script hook line 2", end($yaml['after_script'])); - } - - private function assertViewDoesNotUsePluginSpecifiedTravisCommands($yaml) - { - $this->assertNotEquals("before_install hook line 1", reset($yaml['before_install'])); - $this->assertNotEquals("before_install hook line 2", end($yaml['before_install'])); - - $this->assertNotEquals("before_script hook line 1", reset($yaml['before_script'])); - $this->assertNotEquals("before_script hook line 2", end($yaml['before_script'])); - - $this->assertNotEquals("install hook line 1", reset($yaml['install'])); - $this->assertNotEquals("install hook line 2", end($yaml['install'])); - - $this->assertNotEquals("after_success hook line 1", reset($yaml['after_success'])); - $this->assertNotEquals("after_success hook line 2", end($yaml['after_success'])); - - $this->assertNotEquals("after_script hook line 1", reset($yaml['after_script'])); - $this->assertNotEquals("after_script hook line 2", end($yaml['after_script'])); - } -}
\ No newline at end of file diff --git a/plugins/TestRunner/tests/resources/test.travis.yml b/plugins/TestRunner/tests/resources/test.travis.yml deleted file mode 100644 index e92dabeba1..0000000000 --- a/plugins/TestRunner/tests/resources/test.travis.yml +++ /dev/null @@ -1,55 +0,0 @@ -language: php - -php: - - 5.3 - -env: - global: - - PRESERVED_VAR=123 - - secure: anotherpreservedvar - matrix: - - TEST_SUITE=UnitTests MYSQL_ADAPTER=PDO_MYSQL - - TEST_SUITE=PluginTests MYSQL_ADAPTER=PDO_MYSQL - -script: ./travis.sh - -install: - - TEST_PIWIK_VERSION=$(wget builds.piwik.org/LATEST -q -O -) - - TEST_PIWIK_VERSION=`echo $TEST_PIWIK_VERSION | tr -d ' ' | tr -d '\n'` - - mkdir ExamplePlugin - - cp -R !(ExamplePlugin) ExamplePlugin - - cp -R .git/ ExamplePlugin/ - - git clone https://github.com/piwik/piwik.git piwik - - cd piwik - - git checkout "$TEST_PIWIK_VERSION" - - git submodule init - - git submodule update || true - - composer self-update - - composer install - - rm -rf plugins/ExamplePlugin - - cd ../ - - mv ExamplePlugin piwik/plugins - -before_script: - - cd piwik - - uname -a - - date - - mysql -e 'create database piwik_tests;' - - ./tests/travis/prepare.sh - - ./tests/travis/setup_webserver.sh - - wget https://raw.github.com/piwik/piwik-tests-plugins/master/activateplugin.php - - php activateplugin.php ExamplePlugin - - cd tests/PHPUnit - -custom_section: - - this will be preserved - # as should this - -after_script: - - cat /var/log/nginx/error.log - -notifications: - # another section - - a - - b - - c |