Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorStefan Giehl <stefan@piwik.org>2015-11-23 23:37:47 +0300
committerStefan Giehl <stefan@piwik.org>2015-11-23 23:37:47 +0300
commitfac7c27a004dea209f92aac8ebc895dd19a8f64b (patch)
tree771a40bf1743b7be69bf589183fb9719a3d38f65 /tests
parent13295613614dd3bf3326b61ea5f00f4345dccfd5 (diff)
parent4c722433777bd84bd603419ed04667fe82c22f62 (diff)
Merge pull request #9262 from piwik/omnifixture_fixes
Fixing issues causing omnifixture setup to fail.
Diffstat (limited to 'tests')
-rw-r--r--tests/PHPUnit/Fixtures/ManySitesImportedLogsWithXssAttempts.php5
-rw-r--r--tests/PHPUnit/Fixtures/ManyVisitsWithGeoIP.php7
-rw-r--r--tests/PHPUnit/Fixtures/ManyVisitsWithMockLocationProvider.php2
-rw-r--r--tests/PHPUnit/Fixtures/OmniFixture.php22
-rwxr-xr-xtests/PHPUnit/Framework/Mock/LocationProvider.php5
5 files changed, 34 insertions, 7 deletions
diff --git a/tests/PHPUnit/Fixtures/ManySitesImportedLogsWithXssAttempts.php b/tests/PHPUnit/Fixtures/ManySitesImportedLogsWithXssAttempts.php
index b516c85d65..227e45bd4a 100644
--- a/tests/PHPUnit/Fixtures/ManySitesImportedLogsWithXssAttempts.php
+++ b/tests/PHPUnit/Fixtures/ManySitesImportedLogsWithXssAttempts.php
@@ -57,6 +57,11 @@ class ManySitesImportedLogsWithXssAttempts extends ManySitesImportedLogs
self::createWebsite($this->dateTime, $ecommerce = 0, $siteName = 'Piwik test two',
$siteUrl = 'http://example-site-two.com');
}
+
+ if (!self::siteCreated($idSite = 3)) {
+ self::createWebsite($this->dateTime, $ecommerce = 0, $siteName = 'Piwik test three',
+ $siteUrl = 'http://example-site-three.com');
+ }
}
public function addAnnotations()
diff --git a/tests/PHPUnit/Fixtures/ManyVisitsWithGeoIP.php b/tests/PHPUnit/Fixtures/ManyVisitsWithGeoIP.php
index c413635c8e..ce454b38d2 100644
--- a/tests/PHPUnit/Fixtures/ManyVisitsWithGeoIP.php
+++ b/tests/PHPUnit/Fixtures/ManyVisitsWithGeoIP.php
@@ -265,13 +265,6 @@ class ManyVisitsWithGeoIP extends Fixture
public static function unsetLocationProvider()
{
- // also fails on other PHP, is it really needed?
- return;
-
- // this randomly fails on PHP 5.3
- if(strpos(PHP_VERSION, '5.3') === 0) {
- return;
- }
try {
LocationProvider::setCurrentProvider('default');
} catch(Exception $e) {
diff --git a/tests/PHPUnit/Fixtures/ManyVisitsWithMockLocationProvider.php b/tests/PHPUnit/Fixtures/ManyVisitsWithMockLocationProvider.php
index dd2a2c773c..9fbd6f986d 100644
--- a/tests/PHPUnit/Fixtures/ManyVisitsWithMockLocationProvider.php
+++ b/tests/PHPUnit/Fixtures/ManyVisitsWithMockLocationProvider.php
@@ -33,6 +33,8 @@ class ManyVisitsWithMockLocationProvider extends Fixture
$this->setUpWebsitesAndGoals();
$this->setMockLocationProvider();
$this->trackVisits();
+
+ ManyVisitsWithGeoIP::unsetLocationProvider();
}
public function tearDown()
diff --git a/tests/PHPUnit/Fixtures/OmniFixture.php b/tests/PHPUnit/Fixtures/OmniFixture.php
index 123e214bd3..3c08313018 100644
--- a/tests/PHPUnit/Fixtures/OmniFixture.php
+++ b/tests/PHPUnit/Fixtures/OmniFixture.php
@@ -32,11 +32,29 @@ class OmniFixture extends Fixture
public $fixtures = array();
+ private function requireAllFixtures()
+ {
+ $fixturesToLoad = array(
+ '/tests/PHPUnit/Fixtures/*.php',
+ '/tests/UI/Fixtures/*.php',
+ '/plugins/*/tests/Fixtures/*.php',
+ '/plugins/*/Test/Fixtures/*.php',
+ );
+
+ foreach($fixturesToLoad as $fixturePath) {
+ foreach (glob(PIWIK_INCLUDE_PATH . $fixturePath) as $file) {
+ require_once $file;
+ }
+ }
+ }
+
/**
* Constructor.
*/
public function __construct()
{
+ $this->requireAllFixtures();
+
$date = $this->month . '-01';
$classes = get_declared_classes();
@@ -94,6 +112,8 @@ class OmniFixture extends Fixture
public function setUp()
{
foreach ($this->fixtures as $fixture) {
+ echo "Setting up " . get_class($fixture) . "...\n";
+
$fixture->setUp();
}
@@ -108,6 +128,8 @@ class OmniFixture extends Fixture
public function tearDown()
{
foreach ($this->fixtures as $fixture) {
+ echo "Tearing down " . get_class($fixture) . "...\n";
+
$fixture->tearDown();
}
}
diff --git a/tests/PHPUnit/Framework/Mock/LocationProvider.php b/tests/PHPUnit/Framework/Mock/LocationProvider.php
index 545f71130e..3423c53a7b 100755
--- a/tests/PHPUnit/Framework/Mock/LocationProvider.php
+++ b/tests/PHPUnit/Framework/Mock/LocationProvider.php
@@ -27,6 +27,11 @@ class LocationProvider extends CountryLocationProvider
if (isset($this->ipToLocations[$ip])) {
$result = $this->ipToLocations[$ip];
} else {
+ if (!isset(self::$locations[$this->currentLocation])) {
+ throw new \Exception("Unknown location index in mock LocationProvider {$this->currentLocation}. This "
+ . "shouldn't ever happen, it is likely something is using the mock LocationProvider when it should be using a real one.");
+ }
+
$result = self::$locations[$this->currentLocation];
$this->currentLocation = ($this->currentLocation + 1) % count(self::$locations);