Skip to content
Extraits de code Groupes Projets
Valider f39d3ccc rédigé par Thomas Steur's avatar Thomas Steur
Parcourir les fichiers

refs #4610 fix tests

parent e7b54d9a
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -209,6 +209,7 @@ class CliMulti { ...@@ -209,6 +209,7 @@ class CliMulti {
{ {
$this->processes[] = new Process($cmdId); $this->processes[] = new Process($cmdId);
$url = $this->appendTestmodeParamToUrlIfNeeded($url);
$query = Url::getQueryFromUrl($url, array('pid' => $cmdId)); $query = Url::getQueryFromUrl($url, array('pid' => $cmdId));
$command = $this->buildCommand($query, $output->getPathToFile()); $command = $this->buildCommand($query, $output->getPathToFile());
...@@ -232,4 +233,17 @@ class CliMulti { ...@@ -232,4 +233,17 @@ class CliMulti {
$output->write($message); $output->write($message);
} }
} }
private function appendTestmodeParamToUrlIfNeeded($url)
{
$isTestMode = $url && false !== strpos($url, 'tests/PHPUnit/proxy');
if ($isTestMode && false === strpos($url, '?')) {
$url .= "?testmode=1";
} elseif ($isTestMode) {
$url .= "&testmode=1";
}
return $url;
}
} }
...@@ -36,6 +36,9 @@ class RequestCommand extends ConsoleCommand ...@@ -36,6 +36,9 @@ class RequestCommand extends ConsoleCommand
if ($this->isTestModeEnabled()) { if ($this->isTestModeEnabled()) {
Config::getInstance()->setTestEnvironment(); Config::getInstance()->setTestEnvironment();
$indexFile = '/tests/PHPUnit/proxy/index.php';
} else {
$indexFile = '/index.php';
} }
if (!empty($_GET['pid'])) { if (!empty($_GET['pid'])) {
...@@ -50,7 +53,7 @@ class RequestCommand extends ConsoleCommand ...@@ -50,7 +53,7 @@ class RequestCommand extends ConsoleCommand
Common::$isCliMode = false; Common::$isCliMode = false;
require_once PIWIK_INCLUDE_PATH . "/index.php"; require_once PIWIK_INCLUDE_PATH . $indexFile;
if (!empty($process)) { if (!empty($process)) {
$process->finishProcess(); $process->finishProcess();
......
...@@ -850,7 +850,7 @@ Notes: ...@@ -850,7 +850,7 @@ Notes:
} }
// ensure there is a trailing slash // ensure there is a trailing slash
if ($piwikUrl[strlen($piwikUrl) - 1] != '/') { if ($piwikUrl[strlen($piwikUrl) - 1] != '/' && !Common::stringEndsWith($piwikUrl, 'index.php')) {
$piwikUrl .= '/'; $piwikUrl .= '/';
} }
} }
...@@ -860,7 +860,12 @@ Notes: ...@@ -860,7 +860,12 @@ Notes:
if (Config::getInstance()->General['force_ssl'] == 1) { if (Config::getInstance()->General['force_ssl'] == 1) {
$piwikUrl = str_replace('http://', 'https://', $piwikUrl); $piwikUrl = str_replace('http://', 'https://', $piwikUrl);
} }
$this->piwikUrl = $piwikUrl . "index.php";
if (!Common::stringEndsWith($piwikUrl, 'index.php')) {
$piwikUrl .= 'index.php';
}
$this->piwikUrl = $piwikUrl;
} }
/** /**
...@@ -1086,5 +1091,6 @@ Notes: ...@@ -1086,5 +1091,6 @@ Notes:
$this->logFatalError("archive.php expects the argument --url to be set to your Piwik URL, for example: --url=http://example.org/piwik/ " $this->logFatalError("archive.php expects the argument --url to be set to your Piwik URL, for example: --url=http://example.org/piwik/ "
. "\n--help for more information", $backtrace = false); . "\n--help for more information", $backtrace = false);
} }
} }
...@@ -732,8 +732,10 @@ class Tracker ...@@ -732,8 +732,10 @@ class Tracker
if (is_null($args)) { if (is_null($args)) {
$args = $_GET + $_POST; $args = $_GET + $_POST;
} }
if (is_null($requestMethod)) { if (is_null($requestMethod) && array_key_exists('REQUEST_METHOD', $_SERVER)) {
$requestMethod = $_SERVER['REQUEST_METHOD']; $requestMethod = $_SERVER['REQUEST_METHOD'];
} else if (is_null($requestMethod)) {
$requestMethod = 'GET';
} }
// Do not run scheduled tasks during tests // Do not run scheduled tasks during tests
......
...@@ -82,7 +82,6 @@ class Test_Piwik_Integration_ArchiveCronTest extends IntegrationTestCase ...@@ -82,7 +82,6 @@ class Test_Piwik_Integration_ArchiveCronTest extends IntegrationTestCase
foreach ($this->getApiForTesting() as $testInfo) { foreach ($this->getApiForTesting() as $testInfo) {
list($api, $params) = $testInfo; list($api, $params) = $testInfo;
if (!isset($params['testSuffix'])) { if (!isset($params['testSuffix'])) {
......
...@@ -2,9 +2,16 @@ ...@@ -2,9 +2,16 @@
// Good old test proxy endpoints have some commons // Good old test proxy endpoints have some commons
define('PIWIK_INCLUDE_PATH', realpath(dirname(__FILE__)) . '/../../../'); if (!defined('PIWIK_INCLUDE_PATH')) {
define('PIWIK_USER_PATH', PIWIK_INCLUDE_PATH); define('PIWIK_INCLUDE_PATH', realpath(dirname(__FILE__)) . '/../../../');
define('PIWIK_PRINT_ERROR_BACKTRACE', true); }
if (!defined('PIWIK_USER_PATH')) {
define('PIWIK_USER_PATH', PIWIK_INCLUDE_PATH);
}
if (!defined('PIWIK_PRINT_ERROR_BACKTRACE')) {
define('PIWIK_PRINT_ERROR_BACKTRACE', true);
}
require_once PIWIK_INCLUDE_PATH . '/core/Loader.php'; require_once PIWIK_INCLUDE_PATH . '/core/Loader.php';
require_once PIWIK_INCLUDE_PATH . '/core/EventDispatcher.php'; require_once PIWIK_INCLUDE_PATH . '/core/EventDispatcher.php';
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter