diff --git a/tests/PHPUnit/Framework/Fixture.php b/tests/PHPUnit/Framework/Fixture.php index f25e6f4c2dae64e4545b2a751f4fc70c1ad7c8bc..ee3a3f863f191d7f439c306cec3c915a40f8f611 100644 --- a/tests/PHPUnit/Framework/Fixture.php +++ b/tests/PHPUnit/Framework/Fixture.php @@ -744,11 +744,14 @@ class Fixture extends \PHPUnit_Framework_Assert throw new Exception("The file $deflatedOut is empty. Suggestion: delete it and try again."); } + self::copyDownloadedGeoIp($deflatedOut, $filename); + // Valid geoip db found return; } - Log::warning("Geoip database $outfileName is not found. Downloading from $url..."); + echo "Geoip database $outfileName is not found. Downloading from $url...\n"; + $dump = fopen($url, 'rb'); $outfile = fopen($outfileName, 'wb'); if(!$outfile) { @@ -769,6 +772,16 @@ class Fixture extends \PHPUnit_Framework_Assert throw new Exception("gunzip failed($return): " . implode("\n", $output)); } + + self::copyDownloadedGeoIp($deflatedOut, $filename); + } + + private static function copyDownloadedGeoIp($deflatedOut, $filename) + { + $realFileOut = PIWIK_INCLUDE_PATH . '/' . LocationProvider\GeoIp::$geoIPDatabaseDir . '/' . $filename; + if (!file_exists($realFileOut)) { + copy($deflatedOut, $realFileOut); + } } public static function executeLogImporter($logFile, $options, $allowFailure = false)