Skip to content
Extraits de code Groupes Projets
Valider 6d7fbab5 rédigé par Benaka's avatar Benaka Validation de Matthieu Aubry
Parcourir les fichiers

Pass --piwik-domain value to phpunit via environment variable so correct INI...

Pass --piwik-domain value to phpunit via environment variable so correct INI config will be used in tests. (#12119)
parent 948e1f04
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -41,6 +41,7 @@ class TestsRun extends ConsoleCommand ...@@ -41,6 +41,7 @@ class TestsRun extends ConsoleCommand
$options = $input->getOption('options'); $options = $input->getOption('options');
$groups = $input->getOption('group'); $groups = $input->getOption('group');
$magics = $input->getArgument('variables'); $magics = $input->getArgument('variables');
$piwikDomain = $input->getOption('piwik-domain');
$groups = $this->getGroupsFromString($groups); $groups = $this->getGroupsFromString($groups);
...@@ -113,7 +114,7 @@ class TestsRun extends ConsoleCommand ...@@ -113,7 +114,7 @@ class TestsRun extends ConsoleCommand
} }
} }
$this->executeTests($suite, $testFile, $groups, $options, $command, $output); $this->executeTests($piwikDomain, $suite, $testFile, $groups, $options, $command, $output);
return $this->returnVar; return $this->returnVar;
} }
...@@ -158,12 +159,12 @@ class TestsRun extends ConsoleCommand ...@@ -158,12 +159,12 @@ class TestsRun extends ConsoleCommand
return $this->fixPathToTestFileOrDirectory($testFile); return $this->fixPathToTestFileOrDirectory($testFile);
} }
private function executeTests($suite, $testFile, $groups, $options, $command, OutputInterface $output) private function executeTests($piwikDomain, $suite, $testFile, $groups, $options, $command, OutputInterface $output)
{ {
if (empty($suite) && empty($groups) && empty($testFile)) { if (empty($suite) && empty($groups) && empty($testFile)) {
foreach ($this->getTestsSuites() as $suite) { foreach ($this->getTestsSuites() as $suite) {
$suite = $this->buildTestSuiteName($suite); $suite = $this->buildTestSuiteName($suite);
$this->executeTests($suite, $testFile, $groups, $options, $command, $output); $this->executeTests($piwikDomain, $suite, $testFile, $groups, $options, $command, $output);
} }
return; return;
...@@ -175,12 +176,17 @@ class TestsRun extends ConsoleCommand ...@@ -175,12 +176,17 @@ class TestsRun extends ConsoleCommand
$params = $params . " " . $testFile; $params = $params . " " . $testFile;
} }
$this->executeTestRun($command, $params, $output); $this->executeTestRun($piwikDomain, $command, $params, $output);
} }
private function executeTestRun($command, $params, OutputInterface $output) private function executeTestRun($piwikDomain, $command, $params, OutputInterface $output)
{ {
$cmd = $this->getCommand($command, $params); $envVars = '';
if (!empty($piwikDomain)) {
$envVars .= "PIWIK_DOMAIN=$piwikDomain";
}
$cmd = $this->getCommand($envVars, $command, $params);
$output->writeln('Executing command: <info>' . $cmd . '</info>'); $output->writeln('Executing command: <info>' . $cmd . '</info>');
passthru($cmd, $returnVar); passthru($cmd, $returnVar);
$output->writeln(""); $output->writeln("");
...@@ -198,9 +204,9 @@ class TestsRun extends ConsoleCommand ...@@ -198,9 +204,9 @@ class TestsRun extends ConsoleCommand
* @param $params * @param $params
* @return string * @return string
*/ */
private function getCommand($command, $params) private function getCommand($envVars, $command, $params)
{ {
return sprintf('cd %s/tests/PHPUnit && %s %s', PIWIK_DOCUMENT_ROOT, $command, $params); return sprintf('cd %s/tests/PHPUnit && %s %s %s', PIWIK_DOCUMENT_ROOT, $envVars, $command, $params);
} }
private function buildPhpUnitCliParams($suite, $groups, $options) private function buildPhpUnitCliParams($suite, $groups, $options)
......
...@@ -44,6 +44,16 @@ if (getenv('PIWIK_USE_XHPROF') == 1) { ...@@ -44,6 +44,16 @@ if (getenv('PIWIK_USE_XHPROF') == 1) {
\Piwik\Profiler::setupProfilerXHProf(); \Piwik\Profiler::setupProfilerXHProf();
} }
function setPiwikDomainFromEnvVar()
{
$piwikDomain = getenv('PIWIK_DOMAIN');
if (!empty($piwikDomain)) {
$_SERVER['HTTP_HOST'] = $piwikDomain;
}
}
setPiwikDomainFromEnvVar();
// setup container for tests // setup container for tests
function setupRootContainer() { function setupRootContainer() {
// before running tests, delete the TestingEnvironmentVariables file, since it can indirectly mess w/ // before running tests, delete the TestingEnvironmentVariables file, since it can indirectly mess w/
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter