Skip to content
Extraits de code Groupes Projets
Valider f4dbc612 rédigé par diosmosis's avatar diosmosis
Parcourir les fichiers

Refs #6513, make sure archive.php can be run w/ php-cgi (remove regression...

Refs #6513, make sure archive.php can be run w/ php-cgi (remove regression that caused it to fail) and add system test to catch future regressions, if any.
parent c02da3ff
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -58,15 +58,17 @@ if (isset($_SERVER['argv']) && Piwik\Console::isSupported()) { ...@@ -58,15 +58,17 @@ if (isset($_SERVER['argv']) && Piwik\Console::isSupported()) {
} else { // if running via web request, use CronArchive directly } else { // if running via web request, use CronArchive directly
$archiver = new Piwik\CronArchive(); $archiver = new Piwik\CronArchive();
$token_auth = Piwik\Common::getRequestVar('token_auth', '', 'string'); if (!Piwik\Common::isPhpCliMode()) {
$token_auth = Piwik\Common::getRequestVar('token_auth', '', 'string');
if ($token_auth !== $archiver->getTokenAuth() if ($token_auth !== $archiver->getTokenAuth()
|| strlen($token_auth) != 32 || strlen($token_auth) != 32
) { ) {
die('<b>You must specify the Super User token_auth as a parameter to this script, eg. <code>?token_auth=XYZ</code> if you wish to run this script through the browser. </b><br> die('<b>You must specify the Super User token_auth as a parameter to this script, eg. <code>?token_auth=XYZ</code> if you wish to run this script through the browser. </b><br>
However it is recommended to run it <a href="http://piwik.org/docs/setup-auto-archiving/">via cron in the command line</a>, since it can take a long time to run.<br/> However it is recommended to run it <a href="http://piwik.org/docs/setup-auto-archiving/">via cron in the command line</a>, since it can take a long time to run.<br/>
In a shell, execute for example the following to trigger archiving on the local Piwik server:<br/> In a shell, execute for example the following to trigger archiving on the local Piwik server:<br/>
<code>$ /path/to/php /path/to/piwik/console core:archive --url=http://your-website.org/path/to/piwik/</code>'); <code>$ /path/to/php /path/to/piwik/console core:archive --url=http://your-website.org/path/to/piwik/</code>');
}
} }
$archiver->main(); $archiver->main();
......
...@@ -53,12 +53,18 @@ class ArchiveWebTest extends SystemTestCase ...@@ -53,12 +53,18 @@ class ArchiveWebTest extends SystemTestCase
Option::delete('piwikUrl'); Option::delete('piwikUrl');
} }
$this->assertContains('Starting Piwik reports archiving...', $output); $this->assertWebArchivingDone($output);
$this->assertContains('Archived website id = 1', $output);
$this->assertContains('Done archiving!', $output);
$this->compareArchivePhpOutputAgainstExpected($output); $this->compareArchivePhpOutputAgainstExpected($output);
} }
public function test_WebArchiveScriptCanBeRun_WithPhpCgi_AndWithoutTokenAuth()
{
list($returnCode, $output) = $this->runArchivePhpScriptWithPhpCgi();
$this->assertEquals(0, $returnCode);
$this->assertWebArchivingDone($output);
}
private function compareArchivePhpOutputAgainstExpected($output) private function compareArchivePhpOutputAgainstExpected($output)
{ {
$fileName = 'test_ArchiveCronTest_archive_php_cron_output.txt'; $fileName = 'test_ArchiveCronTest_archive_php_cron_output.txt';
...@@ -73,6 +79,24 @@ class ArchiveWebTest extends SystemTestCase ...@@ -73,6 +79,24 @@ class ArchiveWebTest extends SystemTestCase
$this->comparisonFailures[] = $ex; $this->comparisonFailures[] = $ex;
} }
} }
private function assertWebArchivingDone($output)
{
$this->assertContains('Starting Piwik reports archiving...', $output);
$this->assertContains('Archived website id = 1', $output);
$this->assertContains('Done archiving!', $output);
}
private function runArchivePhpScriptWithPhpCgi()
{
$command = "php-cgi \"" . PIWIK_INCLUDE_PATH . "/tests/PHPUnit/proxy/archive.php" . "\"";
exec($command, $output, $returnCode);
$output = implode("\n", $output);
return array($returnCode, $output);
}
} }
ArchiveWebTest::$fixture = new ManySitesImportedLogs(); ArchiveWebTest::$fixture = new ManySitesImportedLogs();
......
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