diff options
Diffstat (limited to 'tests/PHPUnit/Framework/Fixture.php')
-rw-r--r-- | tests/PHPUnit/Framework/Fixture.php | 71 |
1 files changed, 0 insertions, 71 deletions
diff --git a/tests/PHPUnit/Framework/Fixture.php b/tests/PHPUnit/Framework/Fixture.php index a64f8b6f01..efec12237e 100644 --- a/tests/PHPUnit/Framework/Fixture.php +++ b/tests/PHPUnit/Framework/Fixture.php @@ -809,77 +809,6 @@ class Fixture extends \PHPUnit_Framework_Assert strpos( $gdInfo['GD Version'], self::IMAGES_GENERATED_FOR_GD) !== false; } - public static $geoIpDbUrl = 'http://piwik-team.s3.amazonaws.com/GeoIP.dat.gz'; - public static $geoLiteCityDbUrl = 'http://piwik-team.s3.amazonaws.com/GeoLiteCity.dat.gz'; - - public static function downloadGeoIpDbs() - { - $geoIpOutputDir = PIWIK_INCLUDE_PATH . '/tests/lib/geoip-files'; - self::downloadAndUnzip(self::$geoIpDbUrl, $geoIpOutputDir, 'GeoIP.dat'); - self::downloadAndUnzip(self::$geoLiteCityDbUrl, $geoIpOutputDir, 'GeoIPCity.dat'); - } - - public static function downloadAndUnzip($url, $outputDir, $filename) - { - $bufferSize = 1024 * 1024; - - if (!is_dir($outputDir)) { - mkdir($outputDir); - } - - $deflatedOut = $outputDir . '/' . $filename; - $outfileName = $deflatedOut . '.gz'; - - if (file_exists($deflatedOut)) { - $filesize = filesize($deflatedOut); - if($filesize == 0) { - throw new Exception("The file $deflatedOut is empty. Suggestion: delete it and try again."); - } - - self::copyDownloadedGeoIp($deflatedOut, $filename); - - // Valid geoip db found - return; - } - - echo "Geoip database $outfileName is not found. Downloading from $url...\n"; - - $dump = fopen($url, 'rb'); - if($dump === false){ - throw new Exception('Could not download Geoip database from ' . $url); - } - - $outfile = fopen($outfileName, 'wb'); - if(!$outfile) { - throw new Exception("Failed to create file $outfileName - please check permissions"); - } - - while (!feof($dump)) { - fwrite($outfile, fread($dump, $bufferSize), $bufferSize); - } - fclose($dump); - fclose($outfile); - - // unzip the dump - exec("gunzip -c \"" . $outfileName . "\" > \"$deflatedOut\"", $output, $return); - if ($return !== 0) { - Log::info("gunzip failed with file that has following contents:"); - Log::info(file_get_contents($outfile)); - - 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) { $python = self::getPythonBinary(); |