diff options
author | sgiehl <stefan@matomo.org> | 2020-02-24 11:18:50 +0300 |
---|---|---|
committer | sgiehl <stefan@matomo.org> | 2020-02-24 11:18:50 +0300 |
commit | 31dcb9dbb01460bf9a68dc8b7bc826a05c367f74 (patch) | |
tree | e7dbaf14fb8cf8e34f421df53e22fc88b1b7b0c2 /tests/PHPUnit/Fixtures | |
parent | 92e1b8bc5b8baa7683e4aa7a6abdd40064cd448b (diff) | |
parent | 7c517de3c74b8417230d813ae35e6b5eba06605e (diff) |
Merge branch '3.x-dev' into 4.x-dev
Diffstat (limited to 'tests/PHPUnit/Fixtures')
-rw-r--r-- | tests/PHPUnit/Fixtures/JSTrackingUIFixture.php | 53 | ||||
-rw-r--r-- | tests/PHPUnit/Fixtures/UITestFixture.php | 12 |
2 files changed, 60 insertions, 5 deletions
diff --git a/tests/PHPUnit/Fixtures/JSTrackingUIFixture.php b/tests/PHPUnit/Fixtures/JSTrackingUIFixture.php new file mode 100644 index 0000000000..73c86fef61 --- /dev/null +++ b/tests/PHPUnit/Fixtures/JSTrackingUIFixture.php @@ -0,0 +1,53 @@ +<?php +/** + * Piwik - free/libre analytics platform + * + * @link https://matomo.org + * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later + * + */ + +namespace Piwik\Tests\Fixtures; + +use Piwik\Plugins\GeoIp2\LocationProvider\GeoIp2\Php; +use Piwik\Plugins\PrivacyManager\IPAnonymizer; +use Piwik\Plugins\UserCountry\LocationProvider; +use Piwik\Tests\Framework\Fixture; + +class JSTrackingUIFixture extends Fixture +{ + public function setUp() + { + parent::setUp(); + + self::resetPluginsInstalledConfig(); + self::updateDatabase(); + self::installAndActivatePlugins($this->getTestEnvironment()); + self::updateDatabase(); + + // for proper geolocation + LocationProvider::setCurrentProvider(Php::ID); + IPAnonymizer::deactivate(); + + Fixture::createWebsite('2012-02-02 00:00:00'); + } + + public function performSetUp($setupEnvironmentOnly = false) + { + $this->extraTestEnvVars = array( + 'loadRealTranslations' => 1, + ); + $this->extraPluginsToLoad = array( + 'ExampleTracker', + ); + + parent::performSetUp($setupEnvironmentOnly); + + $this->testEnvironment->overlayUrl = UITestFixture::getLocalTestSiteUrl(); + UITestFixture::createOverlayTestSite($idSite = 1); + + $this->testEnvironment->tokenAuth = self::getTokenAuth(); + $this->testEnvironment->pluginsToLoad = $this->extraPluginsToLoad; + $this->testEnvironment->save(); + } +}
\ No newline at end of file diff --git a/tests/PHPUnit/Fixtures/UITestFixture.php b/tests/PHPUnit/Fixtures/UITestFixture.php index 06b4a5650b..e83070eb8f 100644 --- a/tests/PHPUnit/Fixtures/UITestFixture.php +++ b/tests/PHPUnit/Fixtures/UITestFixture.php @@ -17,6 +17,7 @@ use Piwik\DataTable\Row; use Piwik\Date; use Piwik\Db; use Piwik\DbHelper; +use Piwik\Filesystem; use Piwik\FrontController; use Piwik\Option; use Piwik\Piwik; @@ -144,8 +145,8 @@ class UITestFixture extends SqlDump . " WHERE idsite = 2 AND location_latitude IS NOT NULL LIMIT 1")); $this->testEnvironment->forcedIdVisitor = $visitorIdDeterministic; - $this->testEnvironment->overlayUrl = $this->getLocalTestSiteUrl(); - $this->createOverlayTestSite(); + $this->testEnvironment->overlayUrl = self::getLocalTestSiteUrl(); + self::createOverlayTestSite(); $forcedNowTimestamp = Option::get("Tests.forcedNowTimestamp"); if ($forcedNowTimestamp == false) { @@ -237,11 +238,11 @@ class UITestFixture extends SqlDump self::checkBulkTrackingResponse($t->doBulkTrack()); } - private function createOverlayTestSite() + public static function createOverlayTestSite($idSite = 3) { $realDir = PIWIK_INCLUDE_PATH . "/tests/resources/overlay-test-site-real"; if (is_dir($realDir)) { - return; + Filesystem::unlinkRecursive($realDir, true); } $files = array('index.html', 'page-1.html', 'page-2.html', 'page-3.html', 'page-4.html', 'page-5.html', 'page-6.html'); @@ -263,11 +264,12 @@ class UITestFixture extends SqlDump $contents = file_get_contents($path); $contents = str_replace("%trackerBaseUrl%", $url, $contents); + $contents = str_replace("%idSite%", $idSite, $contents); file_put_contents($path, $contents); } } - private function getLocalTestSiteUrl() + public static function getLocalTestSiteUrl() { return self::getRootUrl() . "tests/resources/overlay-test-site-real/"; } |