Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthieu Napoli <matthieu@mnapoli.fr>2015-06-23 18:47:28 +0300
committerMatthieu Napoli <matthieu@mnapoli.fr>2015-08-12 12:40:39 +0300
commitc9cffd97f7a1f9764f8f5f18e3b6029a38cc5f9e (patch)
tree2b3efa9a45e8db29ac0d2c963da7e91fed81dd76 /plugins/TestRunner
parent85e2e5320d1f180c97f45171ab9727ac3bf5e01d (diff)
Make UI tests use the test config in config.ini.php
The command that runs UI tests now writes a /tests/UI/config.js file that contains the variable configured in config.ini.php. If a file already exists and wasn't autogenerated by this command, it is not overwritten. That allows to run UI tests with another remote than localhost, which happens for example with Docker where phantomjs runs in another container than Piwik.
Diffstat (limited to 'plugins/TestRunner')
-rw-r--r--plugins/TestRunner/Commands/TestsRunUI.php40
1 files changed, 40 insertions, 0 deletions
diff --git a/plugins/TestRunner/Commands/TestsRunUI.php b/plugins/TestRunner/Commands/TestsRunUI.php
index 453b777570..ea2cf6f305 100644
--- a/plugins/TestRunner/Commands/TestsRunUI.php
+++ b/plugins/TestRunner/Commands/TestsRunUI.php
@@ -8,7 +8,9 @@
namespace Piwik\Plugins\TestRunner\Commands;
use Piwik\AssetManager;
+use Piwik\Config;
use Piwik\Plugin\ConsoleCommand;
+use Piwik\Tests\Framework\Fixture;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
@@ -47,6 +49,8 @@ class TestsRunUI extends ConsoleCommand
AssetManager::getInstance()->removeMergedAssets();
}
+ $this->writeJsConfig();
+
$options = array();
if ($persistFixtureData) {
$options[] = "--persist-fixture-data";
@@ -87,4 +91,40 @@ class TestsRunUI extends ConsoleCommand
passthru($cmd);
}
+
+ /**
+ * We override the default values of tests/UI/config.dist.js with config
+ * values from the local INI config.
+ */
+ private function writeJsConfig()
+ {
+ $localConfigFile = PIWIK_INCLUDE_PATH . '/tests/UI/config.js';
+ $tag = 'File generated by the tests:run-ui command';
+
+ // If the file wasn't generated by this command, we don't ovewrite it
+ if (file_exists($localConfigFile)) {
+ $fileContent = file_get_contents($localConfigFile);
+ if (strpos($fileContent, $tag) === false) {
+ return;
+ }
+ }
+
+ $url = Fixture::getRootUrl();
+ $host = Config::getInstance()->tests['http_host'];
+ $uri = Config::getInstance()->tests['request_uri'];
+
+ $js = <<<JS
+/**
+ * $tag
+ */
+exports.piwikUrl = "$url";
+exports.phpServer = {
+ HTTP_HOST: '$host',
+ REQUEST_URI: '$uri',
+ REMOTE_ADDR: '127.0.0.1'
+};
+JS;
+
+ file_put_contents(PIWIK_INCLUDE_PATH . '/tests/UI/config.js', $js);
+ }
}