diff options
author | Benaka <diosmosis@users.noreply.github.com> | 2015-03-17 22:54:20 +0300 |
---|---|---|
committer | Benaka <diosmosis@users.noreply.github.com> | 2015-03-17 22:54:20 +0300 |
commit | 00c394065d518e32cb535b6452bb657dc7672035 (patch) | |
tree | 82043a4cd50bb72b276d5c581981cf3cf1801881 /tests | |
parent | 4ecaa3f06672ac17f24ae90844dd8dfc0718458c (diff) | |
parent | 82cf9823525dc6f7ddff33b1833cfcb5283b0a58 (diff) |
Merge pull request #7381 from piwik/geo-attribution-task
Adding command to attribute or re-attribute existing visits w/ geolocated location info. Includes small refactor to location dimensions and new UserCountry service, VisitorGeolocator. Also includes new DAO class in Piwik core.
Diffstat (limited to 'tests')
5 files changed, 13 insertions, 3 deletions
diff --git a/tests/PHPUnit/Fixtures/ManyVisitsWithGeoIP.php b/tests/PHPUnit/Fixtures/ManyVisitsWithGeoIP.php index 3abb1ee414..a9d77d5813 100644 --- a/tests/PHPUnit/Fixtures/ManyVisitsWithGeoIP.php +++ b/tests/PHPUnit/Fixtures/ManyVisitsWithGeoIP.php @@ -7,6 +7,7 @@ */ namespace Piwik\Tests\Fixtures; +use Piwik\Cache; use Piwik\Date; use Piwik\Plugins\Goals\API; use Piwik\Plugins\UserCountry\LocationProvider\GeoIp; @@ -90,6 +91,10 @@ class ManyVisitsWithGeoIP extends Fixture $dateTime = $this->dateTime; $idSite = $this->idSite; + if ($useLocal) { + Cache::getTransientCache()->flushAll(); // make sure dimension cache is empty between local tracking runs + } + // use local tracker so mock location provider can be used $t = self::getTracker($idSite, $dateTime, $defaultInit = true, $useLocal); if ($doBulk) { @@ -192,7 +197,7 @@ class ManyVisitsWithGeoIP extends Fixture self::checkResponse($t->doTrackPageView('It\'s pitch black...')); } - private function setLocationProvider($file) + public function setLocationProvider($file) { GeoIp::$dbNames['loc'] = array($file); GeoIp::$geoIPDatabaseDir = 'tests/lib/geoip-files'; diff --git a/tests/PHPUnit/Framework/Fixture.php b/tests/PHPUnit/Framework/Fixture.php index 9d2fb8a2d7..ba2b8da23b 100644 --- a/tests/PHPUnit/Framework/Fixture.php +++ b/tests/PHPUnit/Framework/Fixture.php @@ -40,6 +40,7 @@ use Piwik\SettingsServer; use Piwik\Site; use Piwik\Tests\Framework\Mock\FakeAccess; use Piwik\Tests\Framework\TestCase\SystemTestCase; +use Piwik\Tracker; use Piwik\Tracker\Cache; use Piwik\Translate; use Piwik\Url; @@ -172,6 +173,7 @@ class Fixture extends \PHPUnit_Framework_Assert DbHelper::createDatabase($this->dbName); DbHelper::disconnectDatabase(); + Tracker::disconnectCachedDbConnection(); // reconnect once we're sure the database exists Config::getInstance()->database['dbname'] = $this->dbName; diff --git a/tests/PHPUnit/Framework/Mock/LocationProvider.php b/tests/PHPUnit/Framework/Mock/LocationProvider.php index 3a7b9505aa..8b40a81108 100755 --- a/tests/PHPUnit/Framework/Mock/LocationProvider.php +++ b/tests/PHPUnit/Framework/Mock/LocationProvider.php @@ -14,6 +14,8 @@ use Piwik\Plugins\UserCountry\LocationProvider as CountryLocationProvider; */ class LocationProvider extends CountryLocationProvider { + const ID = 'mock_provider'; + public static $locations = array(); private $currentLocation = 0; private $ipToLocations = array(); @@ -38,7 +40,7 @@ class LocationProvider extends CountryLocationProvider public function getInfo() { - return array('id' => 'mock_provider', 'title' => 'mock provider', 'description' => 'mock provider'); + return array('id' => self::ID, 'title' => 'mock provider', 'description' => 'mock provider'); } public function isAvailable() diff --git a/tests/PHPUnit/Framework/TestCase/IntegrationTestCase.php b/tests/PHPUnit/Framework/TestCase/IntegrationTestCase.php index bbd76f453f..033cbcfc1b 100644 --- a/tests/PHPUnit/Framework/TestCase/IntegrationTestCase.php +++ b/tests/PHPUnit/Framework/TestCase/IntegrationTestCase.php @@ -12,6 +12,7 @@ use Piwik\Config; use Piwik\Db; use Piwik\Tests\Framework\Fixture; use Piwik\Cache as PiwikCache; +use Piwik\Translate; /** * Tests extending IntegrationTestCase are much slower to run: the setUp will diff --git a/tests/PHPUnit/Framework/TestCase/SystemTestCase.php b/tests/PHPUnit/Framework/TestCase/SystemTestCase.php index fdec9cb09b..0681c151d5 100755 --- a/tests/PHPUnit/Framework/TestCase/SystemTestCase.php +++ b/tests/PHPUnit/Framework/TestCase/SystemTestCase.php @@ -566,7 +566,7 @@ abstract class SystemTestCase extends PHPUnit_Framework_TestCase } else if (is_numeric($value)) { $values[] = $value; } else if (!ctype_print($value)) { - $values[] = "x'" . bin2hex(substr($value, 1)) . "'"; + $values[] = "x'" . bin2hex($value) . "'"; } else { $values[] = "?"; $bind[] = $value; |