Skip to content

Commit

Permalink
Fixed the issue with vagrant & failing tests. The solution is to setu…
Browse files Browse the repository at this point in the history
…p 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
  • Loading branch information
mattab committed Feb 7, 2013
1 parent 39768c4 commit f2bd670
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
2 changes: 1 addition & 1 deletion tests/PHPUnit/IntegrationTestCase.php
Expand Up @@ -554,7 +554,7 @@ protected static function checkResponse($response)
*
* @return string
*/
protected static function getRootUrl()
public static function getRootUrl()
{
$piwikUrl = Piwik_Url::getCurrentUrlWithoutFileName();

Expand Down
30 changes: 29 additions & 1 deletion tests/PHPUnit/bootstrap.php
Expand Up @@ -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';
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();
}

0 comments on commit f2bd670

Please sign in to comment.