diff --git a/plugins/Monolog/tests/System/TrackerLoggingTest.php b/plugins/Monolog/tests/System/TrackerLoggingTest.php index 87162291165827780dcc9dc44ae13769d01f7a87..0c8533885035948880134a44e01dee4b2ba3f534 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 3c083130188f79e9203449a7fcb1d8bdd06078be..c1a7fec4338e14650d388b91161ca10bffc2e405 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 a32129c93b6919707d093ff3a1986505a1f395e8..03cb78f9da22073a93ab9d2df5ea703dd7fb8bcc 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 b360d162b31d2f6830256df1b9e1f10fa2c01f54..f5ebc7b364bcfb3792a8e9c03d47cb239d365a98 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 a1d2d316d07b695773fcae3347b78950426f9c56..4b780215d788d499829fd550b0edf98a9280e73f 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 4d53c312ba509d3ac7cf2589611acd80e8b36f42..3f66bd3a76cdfcc9632c3f6eaad98e377580694b 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 22a7c77d46338760b5dc874a9e240e5413169c7c..75ca5eacba0348966108bc41c9ca3b85cd66e315 100644 Binary files a/tests/resources/OmniFixture-dump.sql.gz and b/tests/resources/OmniFixture-dump.sql.gz differ