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
diff options
context:
space:
mode:
authordiosmosis <benaka@piwik.pro>2015-12-25 16:52:23 +0300
committerdiosmosis <benaka@piwik.pro>2016-01-13 15:42:23 +0300
commit477740e118e0f1f19fa2721530438aa59159e42e (patch)
tree6d9c3650acc03430f65b582cc42eaa742ce29be9
parenta9033a0dbfaf11e2e4f79a05e9a34e3e2af6679a (diff)
Archive in UITestFixture using correct test environment overrides (loadRealTranslations=1 is needed for archiving) so results are accurate. Also, do not use Fixture::getTestEnvironment() in fixtures, instead create new instances of TestingEnvironmentVariables so changes made to the file are not ignored/lost.
-rw-r--r--plugins/Monolog/tests/System/TrackerLoggingTest.php3
-rw-r--r--tests/PHPUnit/Fixtures/OmniFixture.php16
-rw-r--r--tests/PHPUnit/Fixtures/SomeVisitsCustomVariablesCampaignsNotHeuristics.php3
-rw-r--r--tests/PHPUnit/Fixtures/SqlDump.php6
-rw-r--r--tests/PHPUnit/Fixtures/UITestFixture.php13
-rw-r--r--tests/PHPUnit/Framework/Fixture.php6
-rw-r--r--tests/resources/OmniFixture-dump.sql.gzbin1137931 -> 81192 bytes
7 files changed, 34 insertions, 13 deletions
diff --git a/plugins/Monolog/tests/System/TrackerLoggingTest.php b/plugins/Monolog/tests/System/TrackerLoggingTest.php
index 8716229116..0c85338850 100644
--- a/plugins/Monolog/tests/System/TrackerLoggingTest.php
+++ b/plugins/Monolog/tests/System/TrackerLoggingTest.php
@@ -12,6 +12,7 @@ use Piwik\Config;
use Piwik\Date;
use Piwik\Tests\Framework\Fixture;
use Piwik\Tests\Framework\TestCase\SystemTestCase;
+use Piwik\Tests\Framework\TestingEnvironmentVariables;
use PiwikTracker;
/**
@@ -82,7 +83,7 @@ DEBUG: 'apiv' => '1',", $response);
private function setTrackerConfig($trackerConfig)
{
- $testingEnvironment = self::$fixture->getTestEnvironment();
+ $testingEnvironment = new TestingEnvironmentVariables();
$testingEnvironment->overrideConfig('Tracker', $trackerConfig);
$testingEnvironment->overrideConfig('log', 'log_writers', array('screen'));
$testingEnvironment->save();
diff --git a/tests/PHPUnit/Fixtures/OmniFixture.php b/tests/PHPUnit/Fixtures/OmniFixture.php
index 3c08313018..c1a7fec433 100644
--- a/tests/PHPUnit/Fixtures/OmniFixture.php
+++ b/tests/PHPUnit/Fixtures/OmniFixture.php
@@ -21,15 +21,24 @@ use Piwik\Tests\Framework\OverrideLogin;
*/
class OmniFixture extends Fixture
{
+ const DEFAULT_SEGMENT = "browserCode==FF";
+
public $month = '2012-01';
public $idSite = 'all';
public $dateTime = '2012-02-01';
+
+ /**
+ * @var Date
+ */
public $now = null;
- public $segment = "browserCode==FF";
+ public $segment = self::DEFAULT_SEGMENT;
// Visitor profile screenshot test needs visitor id
public $visitorIdDeterministic = null;
+ /**
+ * @var Fixture[]
+ */
public $fixtures = array();
private function requireAllFixtures()
@@ -118,11 +127,6 @@ class OmniFixture extends Fixture
}
Option::set("Tests.forcedNowTimestamp", $this->now->getTimestamp());
-
- // launch archiving so tests don't run out of time
- $date = Date::factory($this->dateTime)->toString();
- VisitsSummaryAPI::getInstance()->get($this->idSite, 'year', $date);
- VisitsSummaryAPI::getInstance()->get($this->idSite, 'year', $date, urlencode($this->segment));
}
public function tearDown()
diff --git a/tests/PHPUnit/Fixtures/SomeVisitsCustomVariablesCampaignsNotHeuristics.php b/tests/PHPUnit/Fixtures/SomeVisitsCustomVariablesCampaignsNotHeuristics.php
index a32129c93b..03cb78f9da 100644
--- a/tests/PHPUnit/Fixtures/SomeVisitsCustomVariablesCampaignsNotHeuristics.php
+++ b/tests/PHPUnit/Fixtures/SomeVisitsCustomVariablesCampaignsNotHeuristics.php
@@ -10,6 +10,7 @@ namespace Piwik\Tests\Fixtures;
use Piwik\Date;
use Piwik\Plugins\Goals\API;
use Piwik\Tests\Framework\Fixture;
+use Piwik\Tests\Framework\TestingEnvironmentVariables;
use PiwikTracker;
/**
@@ -36,7 +37,7 @@ class SomeVisitsCustomVariablesCampaignsNotHeuristics extends Fixture
private function setPiwikEnvironmentOverrides()
{
- $env = $this->getTestEnvironment();
+ $env = new TestingEnvironmentVariables();
$env->overrideConfig('Tracker', 'create_new_visit_when_website_referrer_changes', 1);
$env->save();
}
diff --git a/tests/PHPUnit/Fixtures/SqlDump.php b/tests/PHPUnit/Fixtures/SqlDump.php
index b360d162b3..f5ebc7b364 100644
--- a/tests/PHPUnit/Fixtures/SqlDump.php
+++ b/tests/PHPUnit/Fixtures/SqlDump.php
@@ -13,6 +13,7 @@ use Piwik\Config;
use Piwik\Db;
use Piwik\Tests\Framework\Fixture;
use Exception;
+use Piwik\Tests\Framework\TestingEnvironmentVariables;
/**
* Reusable fixture. Loads a SQL dump into the DB.
@@ -74,12 +75,13 @@ class SqlDump extends Fixture
// reload access
Access::getInstance()->reloadAccess();
- $this->getTestEnvironment()->configOverride = array(
+ $testVars = new TestingEnvironmentVariables();
+ $testVars->configOverride = array(
'database' => array(
'tables_prefix' => $this->tablesPrefix
)
);
- $this->getTestEnvironment()->save();
+ $testVars->save();
}
/**
diff --git a/tests/PHPUnit/Fixtures/UITestFixture.php b/tests/PHPUnit/Fixtures/UITestFixture.php
index a1d2d316d0..4b780215d7 100644
--- a/tests/PHPUnit/Fixtures/UITestFixture.php
+++ b/tests/PHPUnit/Fixtures/UITestFixture.php
@@ -71,13 +71,14 @@ class UITestFixture extends SqlDump
// create non super user
UsersManagerAPI::getInstance()->addUser('oliverqueen', 'smartypants', 'oli@queenindustries.com');
UsersManagerAPI::getInstance()->setUserAccess('oliverqueen', 'view', array(1));
-
- // launch archiving so UI test requests don't launch it
- VisitsSummaryAPI::getInstance()->get('all', 'year', '2012-08-09');
}
public function performSetUp($setupEnvironmentOnly = false)
{
+ $this->extraTestEnvVars = array(
+ 'loadRealTranslations' => 1,
+ );
+
parent::performSetUp($setupEnvironmentOnly);
$this->createSegments();
@@ -98,6 +99,12 @@ class UITestFixture extends SqlDump
$this->testEnvironment->forcedNowTimestamp = $forcedNowTimestamp;
$this->testEnvironment->save();
+
+ // launch archiving so tests don't run out of time
+ print("Archiving in fixture set up...");
+ VisitsSummaryAPI::getInstance()->get('all', 'year', '2012-08-09');
+ VisitsSummaryAPI::getInstance()->get('all', 'year', '2012-08-09', urlencode(OmniFixture::DEFAULT_SEGMENT));
+ print("Done.");
}
private function addOverlayVisits()
diff --git a/tests/PHPUnit/Framework/Fixture.php b/tests/PHPUnit/Framework/Fixture.php
index 4d53c312ba..3f66bd3a76 100644
--- a/tests/PHPUnit/Framework/Fixture.php
+++ b/tests/PHPUnit/Framework/Fixture.php
@@ -304,6 +304,12 @@ class Fixture extends \PHPUnit_Framework_Assert
}
}
+ /**
+ * NOTE: This method should not be used to get a TestingEnvironmentVariables instance.
+ * Instead just create a new instance.
+ *
+ * @return null|\Piwik\Tests\Framework\TestingEnvironmentVariables
+ */
public function getTestEnvironment()
{
if ($this->testEnvironment === null) {
diff --git a/tests/resources/OmniFixture-dump.sql.gz b/tests/resources/OmniFixture-dump.sql.gz
index 22a7c77d46..75ca5eacba 100644
--- a/tests/resources/OmniFixture-dump.sql.gz
+++ b/tests/resources/OmniFixture-dump.sql.gz
Binary files differ