diff options
-rw-r--r-- | core/Application/Kernel/EnvironmentValidator.php | 3 | ||||
-rw-r--r-- | piwik.php | 6 | ||||
-rw-r--r-- | tests/PHPUnit/System/EnvironmentValidationTest.php | 19 |
3 files changed, 21 insertions, 7 deletions
diff --git a/core/Application/Kernel/EnvironmentValidator.php b/core/Application/Kernel/EnvironmentValidator.php index bfdb7c4460..a94c6f98de 100644 --- a/core/Application/Kernel/EnvironmentValidator.php +++ b/core/Application/Kernel/EnvironmentValidator.php @@ -9,6 +9,7 @@ namespace Piwik\Application\Kernel; use Piwik\Common; +use Piwik\Exception\NotYetInstalledException; use Piwik\Filechecks; use Piwik\Piwik; use Piwik\SettingsPiwik; @@ -50,7 +51,7 @@ class EnvironmentValidator if(SettingsServer::isTrackerApiRequest()) { // if Piwik is not installed yet, the piwik.php should do nothing and not return an error - throw new \Exception("As Piwik is not installed yet, the Tracking API will now exit without error."); + throw new NotYetInstalledException("As Piwik is not installed yet, the Tracking API cannot proceed and will exit without error."); } if(Common::isPhpCliMode()) { @@ -52,7 +52,11 @@ require_once PIWIK_INCLUDE_PATH . '/core/Cookie.php'; SettingsServer::setIsTrackerApiRequest(); $environment = new \Piwik\Application\Environment('tracker'); -$environment->init(); +try { + $environment->init(); +} catch(\Piwik\Exception\NotYetInstalledException $e) { + die($e->getMessage()); +} Tracker::loadTrackerEnvironment(); diff --git a/tests/PHPUnit/System/EnvironmentValidationTest.php b/tests/PHPUnit/System/EnvironmentValidationTest.php index f96032f36d..8f87d999f3 100644 --- a/tests/PHPUnit/System/EnvironmentValidationTest.php +++ b/tests/PHPUnit/System/EnvironmentValidationTest.php @@ -56,7 +56,7 @@ class EnvironmentValidationTest extends SystemTestCase $this->simulateAbsentConfigFile('config.ini.php'); $output = $this->triggerPiwikFrom('tracker'); - $this->assertContains('As Piwik is not installed yet, the Tracking API will now exit without error', $output); + $this->assertContains('As Piwik is not installed yet, the Tracking API cannot proceed and will exit without error.', $output); } public function test_NoLocalConfigFile_TriggersError_inConsole() @@ -191,17 +191,24 @@ class EnvironmentValidationTest extends SystemTestCase private function sendRequestToTracker() { - return $this->curl(Fixture::getRootUrl() . 'tests/PHPUnit/proxy/piwik.php?idsite=1&rec=1&action_name=something'); + list($response, $info) = $this->curl(Fixture::getRootUrl() . 'tests/PHPUnit/proxy/piwik.php?idsite=1&rec=1&action_name=something'); + + // Check Tracker requests return 200 + $this->assertEquals(200, $info["http_code"], 'Ok response'); + + return $response; } private function sendRequestToWeb() { - return $this->curl(Fixture::getRootUrl() . 'tests/PHPUnit/proxy/index.php'); + list($response, $info) = $this->curl(Fixture::getRootUrl() . 'tests/PHPUnit/proxy/index.php'); + return $response; } private function sendArchiveWebRequest() { - return $this->curl(Fixture::getRootUrl() . 'tests/PHPUnit/proxy/archive.php?token_auth=' . Fixture::getTokenAuth()); + list($response, $info) = $this->curl(Fixture::getRootUrl() . 'tests/PHPUnit/proxy/archive.php?token_auth=' . Fixture::getTokenAuth()); + return $response; } private function startConsoleProcess() @@ -226,8 +233,10 @@ class EnvironmentValidationTest extends SystemTestCase $headerSize = curl_getinfo($ch, CURLINFO_HEADER_SIZE); $response = substr($response, $headerSize); + $responseInfo = curl_getinfo($ch); + curl_close($ch); - return $response; + return array($response, $responseInfo); } }
\ No newline at end of file |