From f2bd670e441938a245b5c59e652af21ea1c11209 Mon Sep 17 00:00:00 2001 From: mattab Date: Fri, 8 Feb 2013 11:39:22 +1300 Subject: [PATCH] Fixed the issue with vagrant & failing tests. The solution is to setup webserver to Piwik. * added documentation in the test output to prevent useless test failures messages * I just write out the message and exit. Not sure if that's the proper way to do this * also added help text in case user hasn't up Refs #3722 --- tests/PHPUnit/IntegrationTestCase.php | 2 +- tests/PHPUnit/bootstrap.php | 30 ++++++++++++++++++++++++++- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/tests/PHPUnit/IntegrationTestCase.php b/tests/PHPUnit/IntegrationTestCase.php index 59f65fdf6d8..65eb54bde33 100755 --- a/tests/PHPUnit/IntegrationTestCase.php +++ b/tests/PHPUnit/IntegrationTestCase.php @@ -554,7 +554,7 @@ protected static function checkResponse($response) * * @return string */ - protected static function getRootUrl() + public static function getRootUrl() { $piwikUrl = Piwik_Url::getCurrentUrlWithoutFileName(); diff --git a/tests/PHPUnit/bootstrap.php b/tests/PHPUnit/bootstrap.php index 5dea0f97cc4..9f523030c71 100644 --- a/tests/PHPUnit/bootstrap.php +++ b/tests/PHPUnit/bootstrap.php @@ -35,4 +35,32 @@ require_once PIWIK_INCLUDE_PATH .'/tests/PHPUnit/MockEventDispatcher.php'; // required to build code coverage for uncovered files -require_once PIWIK_INCLUDE_PATH .'/plugins/SecurityInfo/PhpSecInfo/PhpSecInfo.php'; \ No newline at end of file +require_once PIWIK_INCLUDE_PATH .'/plugins/SecurityInfo/PhpSecInfo/PhpSecInfo.php'; + + +// General requirement checks & help: a webserver must be running for tests to work! +$hasConfigBeenUpdated = $_SERVER['REQUEST_URI'] != '@REQUEST_URI@'; +if($hasConfigBeenUpdated) { + $piwikServerUrl = IntegrationTestCase::getRootUrl(); + try { + $fetched = Piwik_Http::sendHttpRequest($piwikServerUrl, $timeout = 3); + } catch(Exception $e) { + $fetched = $e->getMessage(); + } + $expectedString = 'plugins/CoreHome/templates/images/favicon.ico'; + + if(strpos($fetched, $expectedString) === false) { + echo "\nPiwik should be running at: " . $piwikServerUrl . "\nbut this URL returned an unexpected response: '". $fetched . "'\n\n"; + exit; + } +} +if(!$hasConfigBeenUpdated) { + echo "WARNING: for tests to pass, you must first: +1) Install webserver on localhost, eg. apache +2) Make these Piwik files available on the webserver, at eg. http://localhost/dev/piwik/ - Piwik does need to be installed to run tests, but this URL must work. +3) Copy phpunit.xml.dist to phpunit.xml +4) Edit in phpunit.xml the @REQUEST_URI@ and replace with the webserver path to Piwik, eg. '/dev/piwik/' + +Try again and now the tests should run!"; + exit(); +}