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:
authorThomas Steur <thomas.steur@googlemail.com>2014-10-06 09:25:22 +0400
committerThomas Steur <thomas.steur@googlemail.com>2014-10-06 09:25:22 +0400
commit3e134db7cf87e28b37037b650b3378fe9deeb475 (patch)
tree67b162d07cd414aec78cd528796da14ff810647a /tests
parent8aaa1aba44e541ca260de505a3e98996b98c9f37 (diff)
refs #5940 we might stay backwards compatible this way for 2 months. moved some tests from unit to integration and explained when a test is a unit test, an integration test or a system test.
Diffstat (limited to 'tests')
-rwxr-xr-xtests/PHPUnit/BenchmarkTestCase.php6
-rw-r--r--tests/PHPUnit/Benchmarks/Fixtures/ManyThousandSitesOneVisitEach.php2
-rw-r--r--tests/PHPUnit/Benchmarks/Fixtures/OneSiteThousandsOfDistinctUrlsOverMonth.php2
-rwxr-xr-xtests/PHPUnit/Benchmarks/Fixtures/OneSiteTwelveThousandVisitsOneYear.php2
-rwxr-xr-xtests/PHPUnit/Benchmarks/Fixtures/ThousandSitesTwelveVisitsEachOneDay.php2
-rw-r--r--tests/PHPUnit/ConsoleCommandTestCase.php1
-rwxr-xr-xtests/PHPUnit/DatabaseTestCase.php21
-rw-r--r--tests/PHPUnit/Fixture.php846
-rw-r--r--tests/PHPUnit/Fixtures/FewVisitsWithSetVisitorIdAndUserId.php4
-rw-r--r--tests/PHPUnit/Fixtures/InvalidVisits.php4
-rw-r--r--tests/PHPUnit/Fixtures/ManySitesImportedLogs.php4
-rw-r--r--tests/PHPUnit/Fixtures/ManySitesImportedLogsWithXssAttempts.php4
-rw-r--r--tests/PHPUnit/Fixtures/ManyVisitsWithGeoIP.php4
-rw-r--r--tests/PHPUnit/Fixtures/ManyVisitsWithMockLocationProvider.php4
-rw-r--r--tests/PHPUnit/Fixtures/ManyVisitsWithSubDirReferrersAndCustomVars.php4
-rw-r--r--tests/PHPUnit/Fixtures/OmniFixture.php4
-rw-r--r--tests/PHPUnit/Fixtures/OneVisitSeveralPageViews.php4
-rw-r--r--tests/PHPUnit/Fixtures/OneVisitWithAbnormalPageviewUrls.php4
-rw-r--r--tests/PHPUnit/Fixtures/OneVisitorTwoVisits.php4
-rw-r--r--tests/PHPUnit/Fixtures/SomeVisitsAllConversions.php4
-rw-r--r--tests/PHPUnit/Fixtures/SomeVisitsCustomVariablesCampaignsNotHeuristics.php4
-rw-r--r--tests/PHPUnit/Fixtures/SomeVisitsManyPageviewsWithTransitions.php4
-rw-r--r--tests/PHPUnit/Fixtures/SomeVisitsWithLongUrls.php4
-rw-r--r--tests/PHPUnit/Fixtures/SomeVisitsWithNonUnicodePageTitles.php4
-rw-r--r--tests/PHPUnit/Fixtures/SqlDump.php4
-rw-r--r--tests/PHPUnit/Fixtures/ThreeGoalsOnePageview.php4
-rw-r--r--tests/PHPUnit/Fixtures/ThreeSitesWithManyVisitsWithSiteSearch.php4
-rw-r--r--tests/PHPUnit/Fixtures/ThreeSitesWithSharedVisitors.php4
-rw-r--r--tests/PHPUnit/Fixtures/TwoSitesEcommerceOrderWithItems.php4
-rw-r--r--tests/PHPUnit/Fixtures/TwoSitesManyVisitsOverSeveralDaysWithSearchEngineReferrers.php4
-rw-r--r--tests/PHPUnit/Fixtures/TwoSitesTwoVisitorsDifferentDays.php4
-rw-r--r--tests/PHPUnit/Fixtures/TwoSitesVisitsInPast.php4
-rw-r--r--tests/PHPUnit/Fixtures/TwoSitesWithAnnotations.php4
-rw-r--r--tests/PHPUnit/Fixtures/TwoVisitsNoKeywordWithBot.php4
-rw-r--r--tests/PHPUnit/Fixtures/TwoVisitsWithCustomEvents.php4
-rw-r--r--tests/PHPUnit/Fixtures/TwoVisitsWithCustomVariables.php4
-rw-r--r--tests/PHPUnit/Fixtures/UITestFixture.php2
-rw-r--r--tests/PHPUnit/Fixtures/VisitOverSeveralDaysImportedLogs.php4
-rw-r--r--tests/PHPUnit/Fixtures/VisitsInDifferentTimezones.php4
-rw-r--r--tests/PHPUnit/Fixtures/VisitsOverSeveralDays.php4
-rw-r--r--tests/PHPUnit/Fixtures/VisitsTwoWebsitesWithAdditionalVisits.php4
-rw-r--r--tests/PHPUnit/Impl/Fixture.php861
-rw-r--r--tests/PHPUnit/Impl/IntegrationTestCase.php97
-rwxr-xr-xtests/PHPUnit/Impl/SystemTestCase.php (renamed from tests/PHPUnit/SystemTestCase.php)11
-rw-r--r--tests/PHPUnit/Impl/TestRequestCollection.php1
-rw-r--r--tests/PHPUnit/Impl/TestRequestResponse.php1
-rw-r--r--tests/PHPUnit/Integration/AccessTest.php1
-rw-r--r--tests/PHPUnit/Integration/ArchiveProcessingTest.php1
-rw-r--r--tests/PHPUnit/Integration/AssetManager/UIAssetMinifierTest.php (renamed from tests/PHPUnit/Unit/AssetManager/UIAssetMinifierTest.php)2
-rw-r--r--tests/PHPUnit/Integration/CliMultiTest.php4
-rw-r--r--tests/PHPUnit/Integration/CronArchive/SharedSiteIdsTest.php1
-rw-r--r--tests/PHPUnit/Integration/DbTest.php1
-rw-r--r--tests/PHPUnit/Integration/HttpTest.php (renamed from tests/PHPUnit/Unit/HttpTest.php)4
-rw-r--r--tests/PHPUnit/Integration/JsProxyTest.php2
-rw-r--r--tests/PHPUnit/Integration/LogTest.php5
-rw-r--r--tests/PHPUnit/Integration/OptionTest.php1
-rw-r--r--tests/PHPUnit/Integration/PiwikTest.php1
-rw-r--r--tests/PHPUnit/Integration/Plugin/SettingsTest.php3
-rw-r--r--tests/PHPUnit/Integration/ReleaseCheckListTest.php (renamed from tests/PHPUnit/Unit/ReleaseCheckListTest.php)4
-rw-r--r--tests/PHPUnit/Integration/ReportTest.php3
-rw-r--r--tests/PHPUnit/Integration/SegmentTest.php1
-rw-r--r--tests/PHPUnit/Integration/ServeStaticFileTest.php (renamed from tests/PHPUnit/Unit/ServeStaticFileTest.php)2
-rwxr-xr-xtests/PHPUnit/Integration/SqlTest.php1
-rw-r--r--tests/PHPUnit/Integration/Tracker/ActionTest.php2
-rw-r--r--tests/PHPUnit/Integration/Tracker/DbTest.php1
-rw-r--r--tests/PHPUnit/Integration/Tracker/Visit2Test.php3
-rw-r--r--tests/PHPUnit/Integration/Tracker/VisitTest.php1
-rw-r--r--tests/PHPUnit/Integration/TrackerTest.php3
-rw-r--r--tests/PHPUnit/Integration/TravisEnvironmentTest.php1
-rw-r--r--tests/PHPUnit/Integration/UpdaterTest.php4
-rw-r--r--tests/PHPUnit/Integration/ViewDataTable/ManagerTest.php1
-rw-r--r--tests/PHPUnit/Integration/WidgetsListTest.php3
-rw-r--r--tests/PHPUnit/IntegrationTestCase.php83
-rwxr-xr-xtests/PHPUnit/System/AnnotationsTest.php4
-rwxr-xr-xtests/PHPUnit/System/ApiGetReportMetadataTest.php4
-rwxr-xr-xtests/PHPUnit/System/ApiGetReportMetadataYearTest.php4
-rw-r--r--tests/PHPUnit/System/ArchiveCronTest.php6
-rw-r--r--tests/PHPUnit/System/ArchiveInvalidationTest.php4
-rw-r--r--tests/PHPUnit/System/ArchiveWebTest.php6
-rw-r--r--tests/PHPUnit/System/AutoSuggestAPITest.php6
-rw-r--r--tests/PHPUnit/System/BackwardsCompatibility1XTest.php6
-rwxr-xr-xtests/PHPUnit/System/BlobReportLimitingTest.php4
-rwxr-xr-xtests/PHPUnit/System/CsvExportTest.php4
-rw-r--r--tests/PHPUnit/System/CustomEventsTest.php4
-rwxr-xr-xtests/PHPUnit/System/EcommerceOrderWithItemsTest.php4
-rw-r--r--tests/PHPUnit/System/FlattenReportsTest.php4
-rwxr-xr-xtests/PHPUnit/System/ImportLogsTest.php4
-rw-r--r--tests/PHPUnit/System/LabelFilterTest.php4
-rwxr-xr-xtests/PHPUnit/System/ManyVisitorsOneWebsiteTest.php4
-rw-r--r--tests/PHPUnit/System/MultipleSitesArchivingTest.php6
-rwxr-xr-xtests/PHPUnit/System/NoVisitTest.php4
-rwxr-xr-xtests/PHPUnit/System/NonUnicodeTest.php4
-rw-r--r--tests/PHPUnit/System/OneVisitorLongUrlsTruncatedTest.php4
-rwxr-xr-xtests/PHPUnit/System/OneVisitorNoKeywordSpecifiedTest.php4
-rwxr-xr-xtests/PHPUnit/System/OneVisitorOneWebsiteSeveralDaysDateRangeArchivingTestsTest.php4
-rwxr-xr-xtests/PHPUnit/System/OneVisitorOneWebsiteSeveralDaysDateRangeTest.php4
-rw-r--r--tests/PHPUnit/System/OneVisitorSeveralDaysImportedInRandomOrderTest.php4
-rwxr-xr-xtests/PHPUnit/System/OneVisitorTwoVisitsTest.php4
-rwxr-xr-xtests/PHPUnit/System/OneVisitorTwoVisitsWithCookieSupportTest.php4
-rwxr-xr-xtests/PHPUnit/System/PeriodIsRangeDateIsLastNMetadataAndNormalAPITest.php4
-rw-r--r--tests/PHPUnit/System/PivotByQueryParamTest.php4
-rw-r--r--tests/PHPUnit/System/PrivacyManagerTest.php6
-rwxr-xr-xtests/PHPUnit/System/PurgeDataTest.php4
-rwxr-xr-xtests/PHPUnit/System/RowEvolutionTest.php4
-rwxr-xr-xtests/PHPUnit/System/SiteSearchTest.php4
-rw-r--r--tests/PHPUnit/System/TimezonesTest.php4
-rwxr-xr-xtests/PHPUnit/System/TrackCustomVariablesAndCampaignsForceUsingVisitIdNotHeuristicsTest.php4
-rwxr-xr-xtests/PHPUnit/System/TrackGoalsAllowMultipleConversionsPerVisitTest.php4
-rw-r--r--tests/PHPUnit/System/TrackerWindowLookBackTest.php4
-rw-r--r--tests/PHPUnit/System/TransitionsTest.php4
-rwxr-xr-xtests/PHPUnit/System/TwoVisitorsTwoWebsitesDifferentDaysArchivingDisabledTest.php4
-rwxr-xr-xtests/PHPUnit/System/TwoVisitorsTwoWebsitesDifferentDaysConversionsTest.php6
-rwxr-xr-xtests/PHPUnit/System/TwoVisitorsTwoWebsitesDifferentDaysTest.php4
-rwxr-xr-xtests/PHPUnit/System/TwoVisitsWithCustomVariablesSegmentContainsTest.php4
-rwxr-xr-xtests/PHPUnit/System/TwoVisitsWithCustomVariablesSegmentMatchALLNoGoalDataTest.php4
-rwxr-xr-xtests/PHPUnit/System/TwoVisitsWithCustomVariablesSegmentMatchNONETest.php6
-rwxr-xr-xtests/PHPUnit/System/TwoVisitsWithCustomVariablesSegmentMatchVisitorTypeTest.php4
-rwxr-xr-xtests/PHPUnit/System/TwoVisitsWithCustomVariablesTest.php4
-rw-r--r--tests/PHPUnit/System/UrlNormalizationTest.php4
-rw-r--r--tests/PHPUnit/System/UserIdAndVisitorIdTest.php4
-rw-r--r--tests/PHPUnit/System/VisitsInPastInvalidateOldReportsTest.php4
-rw-r--r--tests/PHPUnit/Unit/DeprecatedMethodsTest.php25
-rw-r--r--tests/PHPUnit/bootstrap.php7
-rw-r--r--tests/README.md26
124 files changed, 1268 insertions, 1120 deletions
diff --git a/tests/PHPUnit/BenchmarkTestCase.php b/tests/PHPUnit/BenchmarkTestCase.php
index e8ae09bded..40f5309527 100755
--- a/tests/PHPUnit/BenchmarkTestCase.php
+++ b/tests/PHPUnit/BenchmarkTestCase.php
@@ -8,9 +8,9 @@
use Piwik\Config;
use Piwik\Db;
use Piwik\Plugins\Goals\API;
-use Piwik\Tests\Fixture;
+use Piwik\Tests\Impl\Fixture;
-require_once PIWIK_INCLUDE_PATH . '/tests/PHPUnit/SystemTestCase.php';
+require_once PIWIK_INCLUDE_PATH . '/tests/PHPUnit/Impl/SystemTestCase.php';
require_once PIWIK_INCLUDE_PATH . '/tests/LocalTracker.php';
// require fixtures
@@ -21,7 +21,7 @@ foreach (glob(PIWIK_INCLUDE_PATH . '/tests/PHPUnit/Benchmarks/Fixtures/*.php') a
/**
* Base class for benchmarks.
*/
-abstract class BenchmarkTestCase extends \Piwik\Tests\SystemTestCase
+abstract class BenchmarkTestCase extends \Piwik\Tests\Impl\SystemTestCase
{
protected static $fixture;
diff --git a/tests/PHPUnit/Benchmarks/Fixtures/ManyThousandSitesOneVisitEach.php b/tests/PHPUnit/Benchmarks/Fixtures/ManyThousandSitesOneVisitEach.php
index 38e89928bd..4fbbef1bb9 100644
--- a/tests/PHPUnit/Benchmarks/Fixtures/ManyThousandSitesOneVisitEach.php
+++ b/tests/PHPUnit/Benchmarks/Fixtures/ManyThousandSitesOneVisitEach.php
@@ -7,7 +7,7 @@
*/
use Piwik\Date;
use Piwik\Plugins\Goals\API;
-use Piwik\Tests\Fixture;
+use Piwik\Tests\Impl\Fixture;
/**
* Reusable fixture. Adds 20,000 sites and tracks one pageview for each on one day.
diff --git a/tests/PHPUnit/Benchmarks/Fixtures/OneSiteThousandsOfDistinctUrlsOverMonth.php b/tests/PHPUnit/Benchmarks/Fixtures/OneSiteThousandsOfDistinctUrlsOverMonth.php
index 554b18a694..2a997554a3 100644
--- a/tests/PHPUnit/Benchmarks/Fixtures/OneSiteThousandsOfDistinctUrlsOverMonth.php
+++ b/tests/PHPUnit/Benchmarks/Fixtures/OneSiteThousandsOfDistinctUrlsOverMonth.php
@@ -7,7 +7,7 @@
*/
use Piwik\Date;
use Piwik\Plugins\Goals\API;
-use Piwik\Tests\Fixture;
+use Piwik\Tests\Impl\Fixture;
/**
* Adds one site and 1000 actions for every day of one month (January). Each
diff --git a/tests/PHPUnit/Benchmarks/Fixtures/OneSiteTwelveThousandVisitsOneYear.php b/tests/PHPUnit/Benchmarks/Fixtures/OneSiteTwelveThousandVisitsOneYear.php
index 9b12e79e9f..aed08bb332 100755
--- a/tests/PHPUnit/Benchmarks/Fixtures/OneSiteTwelveThousandVisitsOneYear.php
+++ b/tests/PHPUnit/Benchmarks/Fixtures/OneSiteTwelveThousandVisitsOneYear.php
@@ -7,7 +7,7 @@
*/
use Piwik\Date;
use Piwik\Plugins\Goals\API;
-use Piwik\Tests\Fixture;
+use Piwik\Tests\Impl\Fixture;
/**
* Reusable fixture. Tracks twelve thousand page views over a year for one site.
diff --git a/tests/PHPUnit/Benchmarks/Fixtures/ThousandSitesTwelveVisitsEachOneDay.php b/tests/PHPUnit/Benchmarks/Fixtures/ThousandSitesTwelveVisitsEachOneDay.php
index fad6fc311f..79dba76fe7 100755
--- a/tests/PHPUnit/Benchmarks/Fixtures/ThousandSitesTwelveVisitsEachOneDay.php
+++ b/tests/PHPUnit/Benchmarks/Fixtures/ThousandSitesTwelveVisitsEachOneDay.php
@@ -7,7 +7,7 @@
*/
use Piwik\Date;
use Piwik\Plugins\Goals\API as APIGoals;
-use Piwik\Tests\Fixture;
+use Piwik\Tests\Impl\Fixture;
/**
* Reusable fixture. Tracks twelve thousand page views for 1000 sites on one day.
diff --git a/tests/PHPUnit/ConsoleCommandTestCase.php b/tests/PHPUnit/ConsoleCommandTestCase.php
index 686cf26998..72b231f41f 100644
--- a/tests/PHPUnit/ConsoleCommandTestCase.php
+++ b/tests/PHPUnit/ConsoleCommandTestCase.php
@@ -10,6 +10,7 @@ namespace Piwik\Tests;
use Piwik\Config;
use Piwik\Console;
+use Piwik\Tests\Impl\SystemTestCase;
use Symfony\Component\Console\Tester\ApplicationTester;
/**
diff --git a/tests/PHPUnit/DatabaseTestCase.php b/tests/PHPUnit/DatabaseTestCase.php
new file mode 100755
index 0000000000..d1d0e06cdc
--- /dev/null
+++ b/tests/PHPUnit/DatabaseTestCase.php
@@ -0,0 +1,21 @@
+<?php
+/**
+ * Piwik - free/libre analytics platform
+ *
+ * @link http://piwik.org
+ * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
+ */
+
+/**
+ * @deprecated since 2.8.0 use \Piwik\Tests\Impl\IntegrationTestCase instead
+ */
+class DatabaseTestCase extends \Piwik\Tests\Impl\IntegrationTestCase
+{
+
+ public static function setUpBeforeClass()
+ {
+ \Piwik\Log::debug('\DatabaseTestCase is deprecated since 2.8.0 extend \Piwik\Tests\Impl\IntegrationTestCase instead');
+
+ parent::setUpBeforeClass();
+ }
+}
diff --git a/tests/PHPUnit/Fixture.php b/tests/PHPUnit/Fixture.php
index c899ef2824..ad13e7eb3c 100644
--- a/tests/PHPUnit/Fixture.php
+++ b/tests/PHPUnit/Fixture.php
@@ -6,856 +6,26 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
namespace Piwik\Tests;
-
-use Piwik\Access;
-use Piwik\Common;
-use Piwik\Config;
-use Piwik\DataAccess\ArchiveTableCreator;
-use Piwik\DataTable\Manager as DataTableManager;
-use Piwik\Date;
-use Piwik\Db;
-use Piwik\DbHelper;
use Piwik\Log;
-use Piwik\Option;
-use Piwik\Piwik;
-use Piwik\Plugins\LanguagesManager\API as APILanguageManager;
-use Piwik\Plugins\MobileMessaging\MobileMessaging;
-use Piwik\Plugins\ScheduledReports\API as APIScheduledReports;
-use Piwik\Plugins\ScheduledReports\ScheduledReports;
-use Piwik\Plugins\SitesManager\API as APISitesManager;
-use Piwik\Plugins\UserCountry\LocationProvider;
-use Piwik\Plugins\UsersManager\API as APIUsersManager;
-use Piwik\Plugins\UsersManager\UsersManager;
-use Piwik\ReportRenderer;
-use Piwik\Site;
-use Piwik\Tracker\Cache;
-use Piwik\Translate;
-use Piwik\Url;
-use PHPUnit_Framework_Assert;
-use Piwik_TestingEnvironment;
-use FakeAccess;
-use PiwikTracker;
-use Piwik_LocalTracker;
-use Piwik\Updater;
-use Piwik\Plugins\CoreUpdater\CoreUpdater;
-use Exception;
/**
- * Base type for all system test fixtures. System test fixtures
- * add visit and related data to the database before a test is run. Different
- * tests can use the same fixtures.
- *
- * This class defines a set of helper methods for fixture types. The helper
- * methods are public, but ideally they should only be used by fixture types.
- *
- * NOTE: YOU SHOULD NOT CREATE A NEW FIXTURE UNLESS THERE IS NO WAY TO MODIFY
- * AN EXISTING FIXTURE TO HANDLE YOUR USE CASE.
- *
- * Related TODO: we should try and reduce the amount of existing fixtures by
- * merging some together.
+ * @deprecated since 2.8.0 use \Piwik\Tests\Impl\Fixture instead
*/
-class Fixture extends PHPUnit_Framework_Assert
+class Fixture extends \Piwik\Tests\Impl\Fixture
{
- const IMAGES_GENERATED_ONLY_FOR_OS = 'linux';
- const IMAGES_GENERATED_FOR_PHP = '5.5';
- const IMAGES_GENERATED_FOR_GD = '2.1.1';
- const DEFAULT_SITE_NAME = 'Piwik test';
-
- const ADMIN_USER_LOGIN = 'superUserLogin';
- const ADMIN_USER_PASSWORD = 'superUserPass';
-
- public $dbName = false;
- public $createConfig = true;
- public $dropDatabaseInSetUp = true;
- public $dropDatabaseInTearDown = true;
- public $loadTranslations = true;
- public $createSuperUser = true;
- public $removeExistingSuperUser = true;
- public $overwriteExisting = true;
- public $configureComponents = true;
- public $persistFixtureData = false;
- public $resetPersistedFixture = false;
- public $printToScreen = false;
-
- public $testCaseClass = false;
- public $extraPluginsToLoad = array();
-
- public $testEnvironment = null;
-
- /**
- * @return string
- */
- protected static function getPythonBinary()
- {
- if(\Piwik\SettingsServer::isWindows()) {
- return "C:\Python27\python.exe";
- }
- if(SystemTestCase::isTravisCI()) {
- return 'python2.6';
- }
- return 'python';
- }
/** Adds data to Piwik. Creates sites, tracks visits, imports log files, etc. */
public function setUp()
{
- // empty
- }
-
- /** Does any clean up. Most of the time there will be no need to clean up. */
- public function tearDown()
- {
- // empty
- }
-
- public function getDbName()
- {
- if ($this->dbName !== false) {
- return $this->dbName;
- }
-
- if ($this->persistFixtureData) {
- return str_replace("\\", "_", get_class($this));
- }
-
- return Config::getInstance()->database_tests['dbname'];
- }
-
- public function performSetUp($setupEnvironmentOnly = false)
- {
- try {
- if ($this->createConfig) {
- Config::getInstance()->setTestEnvironment();
- }
-
- $this->dbName = $this->getDbName();
-
- if ($this->persistFixtureData) {
- $this->dropDatabaseInSetUp = false;
- $this->dropDatabaseInTearDown = false;
- $this->overwriteExisting = false;
- $this->removeExistingSuperUser = false;
-
- Config::getInstance()->database_tests['dbname'] = Config::getInstance()->database['dbname'] = $this->dbName;
-
- $this->getTestEnvironment()->dbName = $this->dbName;
- }
-
- if ($this->dbName === false) { // must be after test config is created
- $this->dbName = Config::getInstance()->database['dbname'];
- }
-
- static::connectWithoutDatabase();
-
- if ($this->dropDatabaseInSetUp
- || $this->resetPersistedFixture
- ) {
- $this->dropDatabase();
- }
-
- DbHelper::createDatabase($this->dbName);
- DbHelper::disconnectDatabase();
-
- // reconnect once we're sure the database exists
- Config::getInstance()->database['dbname'] = $this->dbName;
- Db::createDatabaseObject();
-
- Db::get()->query("SET wait_timeout=28800;");
-
- DbHelper::createTables();
-
- \Piwik\Plugin\Manager::getInstance()->unloadPlugins();
-
- } catch (Exception $e) {
- static::fail("TEST INITIALIZATION FAILED: " . $e->getMessage() . "\n" . $e->getTraceAsString());
- }
-
- include "DataFiles/SearchEngines.php";
- include "DataFiles/Socials.php";
- include "DataFiles/Languages.php";
- include "DataFiles/Countries.php";
- include "DataFiles/Currencies.php";
- include "DataFiles/LanguageToCountry.php";
- include "DataFiles/Providers.php";
-
- if (!$this->isFixtureSetUp()) {
- DbHelper::truncateAllTables();
- }
-
- static::createAccessInstance();
-
- // We need to be SU to create websites for tests
- Access::getInstance()->setSuperUserAccess();
-
- Cache::deleteTrackerCache();
-
- static::loadAllPlugins($this->getTestEnvironment(), $this->testCaseClass, $this->extraPluginsToLoad);
-
- self::updateDatabase();
-
- self::installAndActivatePlugins();
-
- $_GET = $_REQUEST = array();
- $_SERVER['HTTP_REFERER'] = '';
-
- // Make sure translations are loaded to check messages in English
- if ($this->loadTranslations) {
- Translate::reloadLanguage('en');
- APILanguageManager::getInstance()->setLanguageForUser('superUserLogin', 'en');
- }
-
- FakeAccess::$superUserLogin = 'superUserLogin';
-
- \Piwik\SettingsPiwik::$cachedKnownSegmentsToArchive = null;
- \Piwik\CacheFile::$invalidateOpCacheBeforeRead = true;
-
- if ($this->configureComponents) {
- \Piwik\Plugins\PrivacyManager\IPAnonymizer::deactivate();
- \Piwik\Plugins\PrivacyManager\DoNotTrackHeaderChecker::deactivate();
- }
-
- if ($this->createSuperUser) {
- self::createSuperUser($this->removeExistingSuperUser);
- }
-
- if ($setupEnvironmentOnly) {
- return;
- }
-
- $this->getTestEnvironment()->save();
- $this->getTestEnvironment()->executeSetupTestEnvHook();
- Piwik_TestingEnvironment::addSendMailHook();
-
- if ($this->overwriteExisting
- || !$this->isFixtureSetUp()
- ) {
- $this->setUp();
+ Log::warning('Piwik\Tests\Fixture is deprecated, use \Piwik\Tests\Impl\Fixture instead');
- $this->markFixtureSetUp();
- $this->log("Database {$this->dbName} marked as successfully set up.");
- } else {
- $this->log("Using existing database {$this->dbName}.");
- }
- }
-
- public function getTestEnvironment()
- {
- if ($this->testEnvironment === null) {
- $this->testEnvironment = new Piwik_TestingEnvironment();
- $this->testEnvironment->delete();
-
- if (getenv('PIWIK_USE_XHPROF') == 1) {
- $this->testEnvironment->useXhprof = true;
- }
- }
- return $this->testEnvironment;
- }
-
- public function isFixtureSetUp()
- {
- $optionName = get_class($this) . '.setUpFlag';
- return Option::get($optionName) !== false;
- }
-
- public function markFixtureSetUp()
- {
- $optionName = get_class($this) . '.setUpFlag';
- Option::set($optionName, 1);
- }
-
- public function performTearDown()
- {
- // Note: avoid run SQL in the *tearDown() metohds because it randomly fails on Travis CI
- // with error Error while sending QUERY packet. PID=XX
- $this->tearDown();
-
- self::unloadAllPlugins();
-
- if ($this->dropDatabaseInTearDown) {
- $this->dropDatabase();
- }
-
- $this->clearInMemoryCaches();
- }
-
- public function clearInMemoryCaches()
- {
- DataTableManager::getInstance()->deleteAll();
- Option::clearCache();
- Site::clearCache();
- Cache::deleteTrackerCache();
- Config::getInstance()->clear();
- ArchiveTableCreator::clear();
- \Piwik\Plugins\ScheduledReports\API::$cache = array();
- \Piwik\Registry::unsetInstance();
- \Piwik\EventDispatcher::getInstance()->clearAllObservers();
-
- $_GET = $_REQUEST = array();
- Translate::unloadEnglishTranslation();
-
- Config::unsetInstance();
-
- \Piwik\Config::getInstance()->Plugins; // make sure Plugins exists in a config object for next tests that use Plugin\Manager
- // since Plugin\Manager uses getFromGlobalConfig which doesn't init the config object
- }
-
- public static function loadAllPlugins($testEnvironment = null, $testCaseClass = false, $extraPluginsToLoad = array())
- {
- if (empty($testEnvironment)) {
- $testEnvironment = new Piwik_TestingEnvironment();
- }
-
- DbHelper::createTables();
- $pluginsManager = \Piwik\Plugin\Manager::getInstance();
-
- $plugins = $testEnvironment->getCoreAndSupportedPlugins();
-
- // make sure the plugin that executed this method is included in the plugins to load
- $extraPlugins = array_merge($extraPluginsToLoad, array(
- \Piwik\Plugin::getPluginNameFromBacktrace(debug_backtrace()),
- \Piwik\Plugin::getPluginNameFromNamespace($testCaseClass),
- \Piwik\Plugin::getPluginNameFromNamespace(get_called_class())
- ));
- foreach ($extraPlugins as $pluginName) {
- if (empty($pluginName)) {
- continue;
- }
-
- if (in_array($pluginName, $plugins)) {
- continue;
- }
-
- $plugins[] = $pluginName;
- if ($testEnvironment) {
- $testEnvironment->pluginsToLoad = array_merge($testEnvironment->pluginsToLoad ?: array(), array($pluginName));
- }
- }
-
- Log::debug("Plugins to load during tests: " . implode(', ', $plugins));
-
- $pluginsManager->loadPlugins($plugins);
- }
-
- public static function installAndActivatePlugins()
- {
- $pluginsManager = \Piwik\Plugin\Manager::getInstance();
-
- // Install plugins
- $messages = $pluginsManager->installLoadedPlugins();
- if(!empty($messages)) {
- Log::info("Plugin loading messages: %s", implode(" --- ", $messages));
- }
-
- // Activate them
- foreach($pluginsManager->getLoadedPlugins() as $plugin) {
- $name = $plugin->getPluginName();
- if (!$pluginsManager->isPluginActivated($name)) {
- $pluginsManager->activatePlugin($name);
- }
- }
- }
-
- public static function unloadAllPlugins()
- {
- try {
- $manager = \Piwik\Plugin\Manager::getInstance();
- $plugins = $manager->getLoadedPlugins();
- foreach ($plugins as $plugin) {
- $plugin->uninstall();
- }
- \Piwik\Plugin\Manager::getInstance()->unloadPlugins();
- } catch (Exception $e) {
- }
- }
-
- /**
- * Creates a website, then sets its creation date to a day earlier than specified dateTime
- * Useful to create a website now, but force data to be archived back in the past.
- *
- * @param string $dateTime eg '2010-01-01 12:34:56'
- * @param int $ecommerce
- * @param string $siteName
- *
- * @param bool|string $siteUrl
- * @param int $siteSearch
- * @param null|string $searchKeywordParameters
- * @param null|string $searchCategoryParameters
- * @return int idSite of website created
- */
- public static function createWebsite($dateTime, $ecommerce = 0, $siteName = false, $siteUrl = false,
- $siteSearch = 1, $searchKeywordParameters = null,
- $searchCategoryParameters = null, $timezone = null)
- {
- if($siteName === false) {
- $siteName = self::DEFAULT_SITE_NAME;
- }
- $idSite = APISitesManager::getInstance()->addSite(
- $siteName,
- $siteUrl === false ? "http://piwik.net/" : $siteUrl,
- $ecommerce,
- $siteSearch, $searchKeywordParameters, $searchCategoryParameters,
- $ips = null,
- $excludedQueryParameters = null,
- $timezone,
- $currency = null
- );
-
- // Manually set the website creation date to a day earlier than the earliest day we record stats for
- Db::get()->update(Common::prefixTable("site"),
- array('ts_created' => Date::factory($dateTime)->subDay(1)->getDatetime()),
- "idsite = $idSite"
- );
-
- // Clear the memory Website cache
- Site::clearCache();
-
- return $idSite;
- }
-
- /**
- * Returns URL to Piwik root.
- *
- * @return string
- */
- public static function getRootUrl()
- {
- $piwikUrl = Url::getCurrentUrlWithoutFileName();
-
- $pathBeforeRoot = 'tests';
- // Running from a plugin
- if (strpos($piwikUrl, 'plugins/') !== false) {
- $pathBeforeRoot = 'plugins';
- }
-
- $testsInPath = strpos($piwikUrl, $pathBeforeRoot . '/');
- if ($testsInPath !== false) {
- $piwikUrl = substr($piwikUrl, 0, $testsInPath);
- }
-
- // in case force_ssl=1, or assume_secure_protocol=1, is set in tests
- // we don't want to require Travis CI or devs to setup HTTPS on their local machine
- $piwikUrl = str_replace("https://", "http://", $piwikUrl);
-
- return $piwikUrl;
- }
-
- /**
- * Returns URL to the proxy script, used to ensure piwik.php
- * uses the test environment, and allows variable overwriting
- *
- * @return string
- */
- public static function getTrackerUrl()
- {
- return self::getRootUrl() . 'tests/PHPUnit/proxy/piwik.php';
- }
-
- /**
- * Returns a PiwikTracker object that you can then use to track pages or goals.
- *
- * @param int $idSite
- * @param string $dateTime
- * @param boolean $defaultInit If set to true, the tracker object will have default IP, user agent, time, resolution, etc.
- * @param bool $useLocal
- *
- * @return PiwikTracker
- */
- public static function getTracker($idSite, $dateTime, $defaultInit = true, $useLocal = false)
- {
- if ($useLocal) {
- require_once PIWIK_INCLUDE_PATH . '/tests/LocalTracker.php';
- $t = new Piwik_LocalTracker($idSite, self::getTrackerUrl());
- } else {
- $t = new PiwikTracker($idSite, self::getTrackerUrl());
- }
- $t->setForceVisitDateTime($dateTime);
-
- if ($defaultInit) {
- $t->setTokenAuth(self::getTokenAuth());
- $t->setIp('156.5.3.2');
-
- // Optional tracking
- $t->setUserAgent("Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.2.6) Gecko/20100625 Firefox/3.6.6 (.NET CLR 3.5.30729)");
- $t->setBrowserLanguage('fr');
- $t->setLocalTime('12:34:06');
- $t->setResolution(1024, 768);
- $t->setBrowserHasCookies(true);
- $t->setPlugins($flash = true, $java = true, $director = false);
- }
- return $t;
- }
-
- /**
- * Checks that the response is a GIF image as expected.
- * Will fail the test if the response is not the expected GIF
- *
- * @param $response
- */
- public static function checkResponse($response)
- {
- $trans_gif_64 = "R0lGODlhAQABAIAAAAAAAAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==";
- $expectedResponse = base64_decode($trans_gif_64);
-
- $url = "\n =========================== \n URL was: " . PiwikTracker::$DEBUG_LAST_REQUESTED_URL;
- self::assertEquals($expectedResponse, $response, "Expected GIF beacon, got: <br/>\n"
- . var_export($response, true)
- . "\n If you are stuck, you can enable [Tracker] debug=1; in config.ini.php to get more debug info."
- . base64_encode($response)
- . $url
- );
- }
-
- /**
- * Checks that the response from bulk tracking is a valid JSON
- * string. Will fail the test if JSON status is not success.
- *
- * @param $response
- */
- public static function checkBulkTrackingResponse($response) {
- $data = json_decode($response, true);
- if (!is_array($data) || empty($response)) {
- throw new Exception("Bulk tracking response (".$response.") is not an array: " . var_export($data, true) . "\n");
- }
- if(!isset($data['status'])) {
- throw new Exception("Returned data didn't have a status: " . var_export($data,true));
- }
-
- self::assertArrayHasKey('status', $data);
- self::assertEquals('success', $data['status'], "expected success, got: " . var_export($data, true));
- }
-
- public static function makeLocation($city, $region, $country, $lat = null, $long = null, $isp = null)
- {
- return array(LocationProvider::CITY_NAME_KEY => $city,
- LocationProvider::REGION_CODE_KEY => $region,
- LocationProvider::COUNTRY_CODE_KEY => $country,
- LocationProvider::LATITUDE_KEY => $lat,
- LocationProvider::LONGITUDE_KEY => $long,
- LocationProvider::ISP_KEY => $isp);
- }
-
- /**
- * Returns the Super User token auth that can be used in tests. Can be used to
- * do bulk tracking.
- *
- * @return string
- */
- public static function getTokenAuth()
- {
- return APIUsersManager::getInstance()->getTokenAuth(
- self::ADMIN_USER_LOGIN,
- UsersManager::getPasswordHash(self::ADMIN_USER_PASSWORD)
- );
- }
-
- public static function createSuperUser($removeExisting = true)
- {
- $login = self::ADMIN_USER_LOGIN;
- $password = UsersManager::getPasswordHash(self::ADMIN_USER_PASSWORD);
- $token = self::getTokenAuth();
-
- $model = new \Piwik\Plugins\UsersManager\Model();
- if ($removeExisting) {
- $model->deleteUserOnly($login);
- }
-
- $user = $model->getUser($login);
-
- if (empty($user)) {
- $model->addUser($login, $password, 'hello@example.org', $login, $token, Date::now()->getDatetime());
- } else {
- $model->updateUser($login, $password, 'hello@example.org', $login, $token);
- }
-
- if (empty($user['superuser_access'])) {
- $model->setSuperUserAccess($login, true);
- }
-
- return $model->getUserByTokenAuth($token);
- }
-
- /**
- * Create three MAIL and two MOBILE scheduled reports
- *
- * Reports sent by mail can contain PNG graphs when the user specifies it.
- * Depending on the system under test, generated images differ slightly.
- * Because of this discrepancy, PNG graphs are only tested if the system under test
- * has the characteristics described in 'canImagesBeIncludedInScheduledReports'.
- * See tests/README.md for more detail.
- *
- * @see canImagesBeIncludedInScheduledReports
- * @param int $idSite id of website created
- */
- public static function setUpScheduledReports($idSite)
- {
- // fake access is needed so API methods can call Piwik::getCurrentUserLogin(), e.g: 'ScheduledReports.addReport'
- $pseudoMockAccess = new FakeAccess;
- FakeAccess::$superUser = true;
- Access::setSingletonInstance($pseudoMockAccess);
-
- // retrieve available reports
- $availableReportMetadata = APIScheduledReports::getReportMetadata($idSite, ScheduledReports::EMAIL_TYPE);
-
- $availableReportIds = array();
- foreach ($availableReportMetadata as $reportMetadata) {
- $availableReportIds[] = $reportMetadata['uniqueId'];
- }
-
- //@review should we also test evolution graphs?
- // set-up mail report
- APIScheduledReports::getInstance()->addReport(
- $idSite,
- 'Mail Test report',
- 'day', // overridden in getApiForTestingScheduledReports()
- 0,
- ScheduledReports::EMAIL_TYPE,
- ReportRenderer::HTML_FORMAT, // overridden in getApiForTestingScheduledReports()
- $availableReportIds,
- array(ScheduledReports::DISPLAY_FORMAT_PARAMETER => ScheduledReports::DISPLAY_FORMAT_TABLES_ONLY)
- );
-
- // set-up sms report for one website
- APIScheduledReports::getInstance()->addReport(
- $idSite,
- 'SMS Test report, one website',
- 'day', // overridden in getApiForTestingScheduledReports()
- 0,
- MobileMessaging::MOBILE_TYPE,
- MobileMessaging::SMS_FORMAT,
- array("MultiSites_getOne"),
- array("phoneNumbers" => array())
- );
-
- // set-up sms report for all websites
- APIScheduledReports::getInstance()->addReport(
- $idSite,
- 'SMS Test report, all websites',
- 'day', // overridden in getApiForTestingScheduledReports()
- 0,
- MobileMessaging::MOBILE_TYPE,
- MobileMessaging::SMS_FORMAT,
- array("MultiSites_getAll"),
- array("phoneNumbers" => array())
- );
-
- if (self::canImagesBeIncludedInScheduledReports()) {
- // set-up mail report with images
- APIScheduledReports::getInstance()->addReport(
- $idSite,
- 'Mail Test report',
- 'day', // overridden in getApiForTestingScheduledReports()
- 0,
- ScheduledReports::EMAIL_TYPE,
- ReportRenderer::HTML_FORMAT, // overridden in getApiForTestingScheduledReports()
- $availableReportIds,
- array(ScheduledReports::DISPLAY_FORMAT_PARAMETER => ScheduledReports::DISPLAY_FORMAT_TABLES_AND_GRAPHS)
- );
-
- // set-up mail report with one row evolution based png graph
- APIScheduledReports::getInstance()->addReport(
- $idSite,
- 'Mail Test report',
- 'day',
- 0,
- ScheduledReports::EMAIL_TYPE,
- ReportRenderer::HTML_FORMAT,
- array('Actions_getPageTitles'),
- array(
- ScheduledReports::DISPLAY_FORMAT_PARAMETER => ScheduledReports::DISPLAY_FORMAT_GRAPHS_ONLY,
- ScheduledReports::EVOLUTION_GRAPH_PARAMETER => 'true',
- )
- );
- }
- }
-
- /**
- * Return true if system under test has Piwik core team's most common configuration
- */
- public static function canImagesBeIncludedInScheduledReports()
- {
- $gdInfo = gd_info();
- return
- stristr(php_uname(), self::IMAGES_GENERATED_ONLY_FOR_OS) &&
- strpos( phpversion(), self::IMAGES_GENERATED_FOR_PHP) !== false &&
- strpos( $gdInfo['GD Version'], self::IMAGES_GENERATED_FOR_GD) !== false;
- }
-
- public static $geoIpDbUrl = 'http://piwik-team.s3.amazonaws.com/GeoIP.dat.gz';
- public static $geoLiteCityDbUrl = 'http://piwik-team.s3.amazonaws.com/GeoLiteCity.dat.gz';
-
- public static function downloadGeoIpDbs()
- {
- $geoIpOutputDir = PIWIK_INCLUDE_PATH . '/tests/lib/geoip-files';
- self::downloadAndUnzip(self::$geoIpDbUrl, $geoIpOutputDir, 'GeoIP.dat');
- self::downloadAndUnzip(self::$geoLiteCityDbUrl, $geoIpOutputDir, 'GeoIPCity.dat');
- }
-
- public static function downloadAndUnzip($url, $outputDir, $filename)
- {
- $bufferSize = 1024 * 1024;
-
- if (!is_dir($outputDir)) {
- mkdir($outputDir);
- }
-
- $deflatedOut = $outputDir . '/' . $filename;
- $outfileName = $deflatedOut . '.gz';
-
- if (file_exists($deflatedOut)) {
- return;
- }
-
- $dump = fopen($url, 'rb');
- $outfile = fopen($outfileName, 'wb');
- while (!feof($dump)) {
- fwrite($outfile, fread($dump, $bufferSize), $bufferSize);
- }
- fclose($dump);
- fclose($outfile);
-
- // unzip the dump
- exec("gunzip -c \"" . $outfileName . "\" > \"$deflatedOut\"", $output, $return);
- if ($return !== 0) {
- Log::info("gunzip failed with file that has following contents:");
- Log::info(file_get_contents($outfile));
-
- throw new Exception("gunzip failed($return): " . implode("\n", $output));
- }
- }
-
- protected static function executeLogImporter($logFile, $options)
- {
- $python = self::getPythonBinary();
-
- // create the command
- $cmd = $python
- . ' "' . PIWIK_INCLUDE_PATH . '/misc/log-analytics/import_logs.py" ' # script loc
- . '-ddd ' // debug
- . '--url="' . self::getRootUrl() . 'tests/PHPUnit/proxy/" ' # proxy so that piwik uses test config files
- ;
-
- foreach ($options as $name => $value) {
- $cmd .= $name;
- if ($value !== false) {
- $cmd .= '="' . $value . '"';
- }
- $cmd .= ' ';
- }
-
- $cmd .= '"' . $logFile . '" 2>&1';
-
- // run the command
- exec($cmd, $output, $result);
- if ($result !== 0) {
- throw new Exception("log importer failed: " . implode("\n", $output) . "\n\ncommand used: $cmd");
- }
-
- return $output;
- }
-
- public static function siteCreated($idSite)
- {
- return Db::fetchOne("SELECT COUNT(*) FROM " . Common::prefixTable('site') . " WHERE idsite = ?", array($idSite)) != 0;
- }
-
- public static function goalExists($idSite, $idGoal)
- {
- return Db::fetchOne("SELECT COUNT(*) FROM " . Common::prefixTable('goal') . " WHERE idgoal = ? AND idsite = ?", array($idGoal, $idSite)) != 0;
- }
-
- /**
- * Connects to MySQL w/o specifying a database.
- */
- public static function connectWithoutDatabase()
- {
- $dbConfig = Config::getInstance()->database;
- $oldDbName = $dbConfig['dbname'];
- $dbConfig['dbname'] = null;
-
- Db::createDatabaseObject($dbConfig);
-
- $dbConfig['dbname'] = $oldDbName;
- }
-
- /**
- * Sets up access instance.
- */
- public static function createAccessInstance()
- {
- Access::setSingletonInstance(null);
- Access::getInstance();
- Piwik::postEvent('Request.initAuthenticationObject');
- }
-
- public function dropDatabase($dbName = null)
- {
- $dbName = $dbName ?: $this->dbName ?: Config::getInstance()->database_tests['dbname'];
-
- $this->log("Dropping database '$dbName'...");
-
- $config = _parse_ini_file(PIWIK_INCLUDE_PATH . '/config/config.ini.php', true);
- $originalDbName = $config['database']['dbname'];
- if ($dbName == $originalDbName
- && $dbName != 'piwik_tests'
- ) { // santity check
- throw new \Exception("Trying to drop original database '$originalDbName'. Something's wrong w/ the tests.");
- }
-
- DbHelper::dropDatabase($dbName);
- }
-
- public function log($message)
- {
- if ($this->printToScreen) {
- echo $message . "\n";
- }
- }
-
- // NOTE: since API_Request does sanitization, API methods do not. when calling them, we must
- // sometimes do sanitization ourselves.
- public static function makeXssContent($type, $sanitize = false)
- {
- $result = "<script>$('body').html('$type XSS!');</script>";
- if ($sanitize) {
- $result = Common::sanitizeInputValue($result);
- }
- return $result;
- }
-
- public static function updateDatabase($force = false)
- {
- Cache::deleteTrackerCache();
- Option::clearCache();
-
- if ($force) {
- // remove version options to force update
- Option::deleteLike('version%');
- Option::set('version_core', '0.0');
- }
-
- $updater = new Updater();
- $componentsWithUpdateFile = CoreUpdater::getComponentUpdates($updater);
- if (empty($componentsWithUpdateFile)) {
- return false;
- }
-
- $result = CoreUpdater::updateComponents($updater, $componentsWithUpdateFile);
- if (!empty($result['coreError'])
- || !empty($result['warnings'])
- || !empty($result['errors'])
- ) {
- throw new \Exception("Failed to update database (errors or warnings found): " . print_r($result, true));
- }
-
- return $result;
+ parent::setUp();
}
}
-// needed by tests that use stored segments w/ the proxy index.php
-class OverrideLogin extends Access
+/**
+ * @deprecated since 2.8.0 use \Piwik\Tests\Impl\OverrideLogin instead
+ */
+class OverrideLogin extends \Piwik\Tests\Impl\OverrideLogin
{
- public function getLogin()
- {
- return 'superUserLogin';
- }
} \ No newline at end of file
diff --git a/tests/PHPUnit/Fixtures/FewVisitsWithSetVisitorIdAndUserId.php b/tests/PHPUnit/Fixtures/FewVisitsWithSetVisitorIdAndUserId.php
index f039505460..7c4660f840 100644
--- a/tests/PHPUnit/Fixtures/FewVisitsWithSetVisitorIdAndUserId.php
+++ b/tests/PHPUnit/Fixtures/FewVisitsWithSetVisitorIdAndUserId.php
@@ -5,12 +5,12 @@
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
-namespace Piwik\Tests\Fixtures;
+namespace Piwik\Tests\Impl\Fixtures;
use Piwik\Date;
use Piwik\Plugins\Goals\API;
use Piwik\Tracker\Visit;
-use Piwik\Tests\Fixture;
+use Piwik\Tests\Impl\Fixture;
use PiwikTracker;
use Exception;
diff --git a/tests/PHPUnit/Fixtures/InvalidVisits.php b/tests/PHPUnit/Fixtures/InvalidVisits.php
index adf068d5d3..6fbeb05ebe 100644
--- a/tests/PHPUnit/Fixtures/InvalidVisits.php
+++ b/tests/PHPUnit/Fixtures/InvalidVisits.php
@@ -5,11 +5,11 @@
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
-namespace Piwik\Tests\Fixtures;
+namespace Piwik\Tests\Impl\Fixtures;
use Piwik\Http;
use Piwik\Plugins\SitesManager\API;
-use Piwik\Tests\Fixture;
+use Piwik\Tests\Impl\Fixture;
use Exception;
/**
diff --git a/tests/PHPUnit/Fixtures/ManySitesImportedLogs.php b/tests/PHPUnit/Fixtures/ManySitesImportedLogs.php
index 2ddc236f0c..949a750eb2 100644
--- a/tests/PHPUnit/Fixtures/ManySitesImportedLogs.php
+++ b/tests/PHPUnit/Fixtures/ManySitesImportedLogs.php
@@ -5,14 +5,14 @@
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
-namespace Piwik\Tests\Fixtures;
+namespace Piwik\Tests\Impl\Fixtures;
use Piwik\Access;
use Piwik\Plugins\Goals\API as APIGoals;
use Piwik\Plugins\SegmentEditor\API as APISegmentEditor;
use Piwik\Plugins\UserCountry\LocationProvider\GeoIp;
use Piwik\Plugins\UserCountry\LocationProvider;
-use Piwik\Tests\Fixture;
+use Piwik\Tests\Impl\Fixture;
use Piwik\Tests\OverrideLogin;
/**
diff --git a/tests/PHPUnit/Fixtures/ManySitesImportedLogsWithXssAttempts.php b/tests/PHPUnit/Fixtures/ManySitesImportedLogsWithXssAttempts.php
index 70f2d07ca5..97f8e4f8f8 100644
--- a/tests/PHPUnit/Fixtures/ManySitesImportedLogsWithXssAttempts.php
+++ b/tests/PHPUnit/Fixtures/ManySitesImportedLogsWithXssAttempts.php
@@ -5,13 +5,13 @@
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
-namespace Piwik\Tests\Fixtures;
+namespace Piwik\Tests\Impl\Fixtures;
use Piwik\Date;
use Piwik\Db;
use Piwik\Plugins\Annotations\API as APIAnnotations;
use Piwik\Plugins\Goals\API as APIGoals;
-use Piwik\Tests\Fixture;
+use Piwik\Tests\Impl\Fixture;
require_once PIWIK_INCLUDE_PATH . '/tests/PHPUnit/Fixtures/ManySitesImportedLogs.php';
diff --git a/tests/PHPUnit/Fixtures/ManyVisitsWithGeoIP.php b/tests/PHPUnit/Fixtures/ManyVisitsWithGeoIP.php
index 2d7620f4fe..2c4e989edc 100644
--- a/tests/PHPUnit/Fixtures/ManyVisitsWithGeoIP.php
+++ b/tests/PHPUnit/Fixtures/ManyVisitsWithGeoIP.php
@@ -5,13 +5,13 @@
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
-namespace Piwik\Tests\Fixtures;
+namespace Piwik\Tests\Impl\Fixtures;
use Piwik\Date;
use Piwik\Plugins\Goals\API;
use Piwik\Plugins\UserCountry\LocationProvider\GeoIp;
use Piwik\Plugins\UserCountry\LocationProvider;
-use Piwik\Tests\Fixture;
+use Piwik\Tests\Impl\Fixture;
use Exception;
require_once PIWIK_INCLUDE_PATH . '/tests/PHPUnit/MockLocationProvider.php';
diff --git a/tests/PHPUnit/Fixtures/ManyVisitsWithMockLocationProvider.php b/tests/PHPUnit/Fixtures/ManyVisitsWithMockLocationProvider.php
index aee0adbba9..e251781bff 100644
--- a/tests/PHPUnit/Fixtures/ManyVisitsWithMockLocationProvider.php
+++ b/tests/PHPUnit/Fixtures/ManyVisitsWithMockLocationProvider.php
@@ -5,11 +5,11 @@
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
-namespace Piwik\Tests\Fixtures;
+namespace Piwik\Tests\Impl\Fixtures;
use Piwik\Date;
use Piwik\Plugins\UserCountry\LocationProvider;
-use Piwik\Tests\Fixture;
+use Piwik\Tests\Impl\Fixture;
require_once PIWIK_INCLUDE_PATH . '/tests/PHPUnit/MockLocationProvider.php';
diff --git a/tests/PHPUnit/Fixtures/ManyVisitsWithSubDirReferrersAndCustomVars.php b/tests/PHPUnit/Fixtures/ManyVisitsWithSubDirReferrersAndCustomVars.php
index 88f673831c..f64deeff61 100644
--- a/tests/PHPUnit/Fixtures/ManyVisitsWithSubDirReferrersAndCustomVars.php
+++ b/tests/PHPUnit/Fixtures/ManyVisitsWithSubDirReferrersAndCustomVars.php
@@ -5,10 +5,10 @@
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
-namespace Piwik\Tests\Fixtures;
+namespace Piwik\Tests\Impl\Fixtures;
use Piwik\Date;
-use Piwik\Tests\Fixture;
+use Piwik\Tests\Impl\Fixture;
/**
* Adds one site and tracks 13 visits all with custom variables and referrer URLs
diff --git a/tests/PHPUnit/Fixtures/OmniFixture.php b/tests/PHPUnit/Fixtures/OmniFixture.php
index a826e13e36..82e8f09ce7 100644
--- a/tests/PHPUnit/Fixtures/OmniFixture.php
+++ b/tests/PHPUnit/Fixtures/OmniFixture.php
@@ -5,14 +5,14 @@
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
-namespace Piwik\Tests\Fixtures;
+namespace Piwik\Tests\Impl\Fixtures;
use Piwik\Date;
use Piwik\Access;
use Piwik\Option;
use ReflectionClass;
use Piwik\Plugins\VisitsSummary\API as VisitsSummaryAPI;
-use Piwik\Tests\Fixture;
+use Piwik\Tests\Impl\Fixture;
use Piwik\Tests\OverrideLogin;
/**
diff --git a/tests/PHPUnit/Fixtures/OneVisitSeveralPageViews.php b/tests/PHPUnit/Fixtures/OneVisitSeveralPageViews.php
index c4ed1564a0..e08c610800 100644
--- a/tests/PHPUnit/Fixtures/OneVisitSeveralPageViews.php
+++ b/tests/PHPUnit/Fixtures/OneVisitSeveralPageViews.php
@@ -5,10 +5,10 @@
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
-namespace Piwik\Tests\Fixtures;
+namespace Piwik\Tests\Impl\Fixtures;
use Piwik\Date;
-use Piwik\Tests\Fixture;
+use Piwik\Tests\Impl\Fixture;
/**
* Adds one site and tracks one visit with several pageviews.
diff --git a/tests/PHPUnit/Fixtures/OneVisitWithAbnormalPageviewUrls.php b/tests/PHPUnit/Fixtures/OneVisitWithAbnormalPageviewUrls.php
index 7a316bcc78..213f663eba 100644
--- a/tests/PHPUnit/Fixtures/OneVisitWithAbnormalPageviewUrls.php
+++ b/tests/PHPUnit/Fixtures/OneVisitWithAbnormalPageviewUrls.php
@@ -5,10 +5,10 @@
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
-namespace Piwik\Tests\Fixtures;
+namespace Piwik\Tests\Impl\Fixtures;
use Piwik\Date;
-use Piwik\Tests\Fixture;
+use Piwik\Tests\Impl\Fixture;
/**
* Adds one site and tracks one visit w/ pageview URLs that are not normalized.
diff --git a/tests/PHPUnit/Fixtures/OneVisitorTwoVisits.php b/tests/PHPUnit/Fixtures/OneVisitorTwoVisits.php
index 50f576b33f..60572afb27 100644
--- a/tests/PHPUnit/Fixtures/OneVisitorTwoVisits.php
+++ b/tests/PHPUnit/Fixtures/OneVisitorTwoVisits.php
@@ -5,12 +5,12 @@
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
-namespace Piwik\Tests\Fixtures;
+namespace Piwik\Tests\Impl\Fixtures;
use Piwik\Date;
use Piwik\Plugins\Goals\API as APIGoals;
use Piwik\Plugins\SitesManager\API as APISitesManager;
-use Piwik\Tests\Fixture;
+use Piwik\Tests\Impl\Fixture;
/**
* This fixture adds one website and tracks two visits by one visitor.
diff --git a/tests/PHPUnit/Fixtures/SomeVisitsAllConversions.php b/tests/PHPUnit/Fixtures/SomeVisitsAllConversions.php
index 663b3e748a..2f7192b651 100644
--- a/tests/PHPUnit/Fixtures/SomeVisitsAllConversions.php
+++ b/tests/PHPUnit/Fixtures/SomeVisitsAllConversions.php
@@ -5,11 +5,11 @@
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
-namespace Piwik\Tests\Fixtures;
+namespace Piwik\Tests\Impl\Fixtures;
use Piwik\Date;
use Piwik\Plugins\Goals\API;
-use Piwik\Tests\Fixture;
+use Piwik\Tests\Impl\Fixture;
/**
* Adds one site and tracks a couple conversions.
diff --git a/tests/PHPUnit/Fixtures/SomeVisitsCustomVariablesCampaignsNotHeuristics.php b/tests/PHPUnit/Fixtures/SomeVisitsCustomVariablesCampaignsNotHeuristics.php
index 4896e6fe2a..2cb2010788 100644
--- a/tests/PHPUnit/Fixtures/SomeVisitsCustomVariablesCampaignsNotHeuristics.php
+++ b/tests/PHPUnit/Fixtures/SomeVisitsCustomVariablesCampaignsNotHeuristics.php
@@ -5,11 +5,11 @@
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
-namespace Piwik\Tests\Fixtures;
+namespace Piwik\Tests\Impl\Fixtures;
use Piwik\Date;
use Piwik\Plugins\Goals\API;
-use Piwik\Tests\Fixture;
+use Piwik\Tests\Impl\Fixture;
use PiwikTracker;
/**
diff --git a/tests/PHPUnit/Fixtures/SomeVisitsManyPageviewsWithTransitions.php b/tests/PHPUnit/Fixtures/SomeVisitsManyPageviewsWithTransitions.php
index 52845bc0b8..f96529747c 100644
--- a/tests/PHPUnit/Fixtures/SomeVisitsManyPageviewsWithTransitions.php
+++ b/tests/PHPUnit/Fixtures/SomeVisitsManyPageviewsWithTransitions.php
@@ -5,10 +5,10 @@
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
-namespace Piwik\Tests\Fixtures;
+namespace Piwik\Tests\Impl\Fixtures;
use Piwik\Date;
-use Piwik\Tests\Fixture;
+use Piwik\Tests\Impl\Fixture;
/**
* Adds one site and tracks a couple visits with many pageviews. The
diff --git a/tests/PHPUnit/Fixtures/SomeVisitsWithLongUrls.php b/tests/PHPUnit/Fixtures/SomeVisitsWithLongUrls.php
index 6d5e2556b3..bc3304a337 100644
--- a/tests/PHPUnit/Fixtures/SomeVisitsWithLongUrls.php
+++ b/tests/PHPUnit/Fixtures/SomeVisitsWithLongUrls.php
@@ -5,10 +5,10 @@
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
-namespace Piwik\Tests\Fixtures;
+namespace Piwik\Tests\Impl\Fixtures;
use Piwik\Date;
-use Piwik\Tests\Fixture;
+use Piwik\Tests\Impl\Fixture;
/**
* Adds one site and tracks 7 visits w/ some long-ish urls (as page urls and
diff --git a/tests/PHPUnit/Fixtures/SomeVisitsWithNonUnicodePageTitles.php b/tests/PHPUnit/Fixtures/SomeVisitsWithNonUnicodePageTitles.php
index 08b4962a6f..512f807bae 100644
--- a/tests/PHPUnit/Fixtures/SomeVisitsWithNonUnicodePageTitles.php
+++ b/tests/PHPUnit/Fixtures/SomeVisitsWithNonUnicodePageTitles.php
@@ -5,11 +5,11 @@
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
-namespace Piwik\Tests\Fixtures;
+namespace Piwik\Tests\Impl\Fixtures;
use Piwik\Date;
use Piwik\Plugins\SitesManager\API;
-use Piwik\Tests\Fixture;
+use Piwik\Tests\Impl\Fixture;
/**
* Adds one website and some visits with non unicode page titles.
diff --git a/tests/PHPUnit/Fixtures/SqlDump.php b/tests/PHPUnit/Fixtures/SqlDump.php
index 06c094de03..07a867784a 100644
--- a/tests/PHPUnit/Fixtures/SqlDump.php
+++ b/tests/PHPUnit/Fixtures/SqlDump.php
@@ -5,14 +5,14 @@
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
-namespace Piwik\Tests\Fixtures;
+namespace Piwik\Tests\Impl\Fixtures;
use Piwik\Access;
use Piwik\ArchiveProcessor\Rules;
use Piwik\Config;
use Piwik\Db;
use Piwik\Piwik;
-use Piwik\Tests\Fixture;
+use Piwik\Tests\Impl\Fixture;
use Exception;
/**
diff --git a/tests/PHPUnit/Fixtures/ThreeGoalsOnePageview.php b/tests/PHPUnit/Fixtures/ThreeGoalsOnePageview.php
index ac7abb6a4f..c992072611 100644
--- a/tests/PHPUnit/Fixtures/ThreeGoalsOnePageview.php
+++ b/tests/PHPUnit/Fixtures/ThreeGoalsOnePageview.php
@@ -5,11 +5,11 @@
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
-namespace Piwik\Tests\Fixtures;
+namespace Piwik\Tests\Impl\Fixtures;
use Piwik\Date;
use Piwik\Plugins\Goals\API;
-use Piwik\Tests\Fixture;
+use Piwik\Tests\Impl\Fixture;
/**
* Fixture that adds one site with three goals and tracks one pageview & one manual
diff --git a/tests/PHPUnit/Fixtures/ThreeSitesWithManyVisitsWithSiteSearch.php b/tests/PHPUnit/Fixtures/ThreeSitesWithManyVisitsWithSiteSearch.php
index 1c12adc3f3..bc1825e5ec 100644
--- a/tests/PHPUnit/Fixtures/ThreeSitesWithManyVisitsWithSiteSearch.php
+++ b/tests/PHPUnit/Fixtures/ThreeSitesWithManyVisitsWithSiteSearch.php
@@ -5,11 +5,11 @@
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
-namespace Piwik\Tests\Fixtures;
+namespace Piwik\Tests\Impl\Fixtures;
use Piwik\Date;
use Piwik\Plugins\SitesManager\API;
-use Piwik\Tests\Fixture;
+use Piwik\Tests\Impl\Fixture;
/**
* Adds three websites with different site search configurations and adds
diff --git a/tests/PHPUnit/Fixtures/ThreeSitesWithSharedVisitors.php b/tests/PHPUnit/Fixtures/ThreeSitesWithSharedVisitors.php
index 267e848fde..3c11c29a96 100644
--- a/tests/PHPUnit/Fixtures/ThreeSitesWithSharedVisitors.php
+++ b/tests/PHPUnit/Fixtures/ThreeSitesWithSharedVisitors.php
@@ -5,12 +5,12 @@
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
-namespace Piwik\Tests\Fixtures;
+namespace Piwik\Tests\Impl\Fixtures;
use Piwik\Common;
use Piwik\Date;
use Piwik\Db;
-use Piwik\Tests\Fixture;
+use Piwik\Tests\Impl\Fixture;
/**
* Adds three sites and tracks some visits w/ visitors that visit each site.
diff --git a/tests/PHPUnit/Fixtures/TwoSitesEcommerceOrderWithItems.php b/tests/PHPUnit/Fixtures/TwoSitesEcommerceOrderWithItems.php
index 938fe28c86..4eb6919230 100644
--- a/tests/PHPUnit/Fixtures/TwoSitesEcommerceOrderWithItems.php
+++ b/tests/PHPUnit/Fixtures/TwoSitesEcommerceOrderWithItems.php
@@ -5,11 +5,11 @@
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
-namespace Piwik\Tests\Fixtures;
+namespace Piwik\Tests\Impl\Fixtures;
use Piwik\Date;
use Piwik\Plugins\Goals\API;
-use Piwik\Tests\Fixture;
+use Piwik\Tests\Impl\Fixture;
/**
* Adds two sites and tracks some visits with ecommerce orders.
diff --git a/tests/PHPUnit/Fixtures/TwoSitesManyVisitsOverSeveralDaysWithSearchEngineReferrers.php b/tests/PHPUnit/Fixtures/TwoSitesManyVisitsOverSeveralDaysWithSearchEngineReferrers.php
index 3ff7b56fa4..87c92d64a5 100644
--- a/tests/PHPUnit/Fixtures/TwoSitesManyVisitsOverSeveralDaysWithSearchEngineReferrers.php
+++ b/tests/PHPUnit/Fixtures/TwoSitesManyVisitsOverSeveralDaysWithSearchEngineReferrers.php
@@ -5,11 +5,11 @@
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
-namespace Piwik\Tests\Fixtures;
+namespace Piwik\Tests\Impl\Fixtures;
use Piwik\Date;
use Piwik\Plugins\Goals\API;
-use Piwik\Tests\Fixture;
+use Piwik\Tests\Impl\Fixture;
/**
* Adds one website and tracks visits on different days over a month
diff --git a/tests/PHPUnit/Fixtures/TwoSitesTwoVisitorsDifferentDays.php b/tests/PHPUnit/Fixtures/TwoSitesTwoVisitorsDifferentDays.php
index 6e913930fd..5d2ccaca15 100644
--- a/tests/PHPUnit/Fixtures/TwoSitesTwoVisitorsDifferentDays.php
+++ b/tests/PHPUnit/Fixtures/TwoSitesTwoVisitorsDifferentDays.php
@@ -5,12 +5,12 @@
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
-namespace Piwik\Tests\Fixtures;
+namespace Piwik\Tests\Impl\Fixtures;
use Piwik\Date;
use Piwik\Plugins\Goals\API as APIGoals;
use Piwik\Plugins\SitesManager\API as APISitesManager;
-use Piwik\Tests\Fixture;
+use Piwik\Tests\Impl\Fixture;
/**
* Adds two websites and tracks visits from two visitors on different days.
diff --git a/tests/PHPUnit/Fixtures/TwoSitesVisitsInPast.php b/tests/PHPUnit/Fixtures/TwoSitesVisitsInPast.php
index 0d47c97815..59e7cd0070 100644
--- a/tests/PHPUnit/Fixtures/TwoSitesVisitsInPast.php
+++ b/tests/PHPUnit/Fixtures/TwoSitesVisitsInPast.php
@@ -5,10 +5,10 @@
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
-namespace Piwik\Tests\Fixtures;
+namespace Piwik\Tests\Impl\Fixtures;
use Piwik\Date;
-use Piwik\Tests\Fixture;
+use Piwik\Tests\Impl\Fixture;
/**
* Adds two sites and tracks several visits all in the past.
diff --git a/tests/PHPUnit/Fixtures/TwoSitesWithAnnotations.php b/tests/PHPUnit/Fixtures/TwoSitesWithAnnotations.php
index 370c5a864e..5f822282c2 100644
--- a/tests/PHPUnit/Fixtures/TwoSitesWithAnnotations.php
+++ b/tests/PHPUnit/Fixtures/TwoSitesWithAnnotations.php
@@ -5,12 +5,12 @@
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
-namespace Piwik\Tests\Fixtures;
+namespace Piwik\Tests\Impl\Fixtures;
use Piwik\Access;
use Piwik\Date;
use Piwik\Plugins\Annotations\API;
-use Piwik\Tests\Fixture;
+use Piwik\Tests\Impl\Fixture;
use FakeAccess;
/**
diff --git a/tests/PHPUnit/Fixtures/TwoVisitsNoKeywordWithBot.php b/tests/PHPUnit/Fixtures/TwoVisitsNoKeywordWithBot.php
index fcbb864bfb..a657c837c7 100644
--- a/tests/PHPUnit/Fixtures/TwoVisitsNoKeywordWithBot.php
+++ b/tests/PHPUnit/Fixtures/TwoVisitsNoKeywordWithBot.php
@@ -5,11 +5,11 @@
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
-namespace Piwik\Tests\Fixtures;
+namespace Piwik\Tests\Impl\Fixtures;
use Piwik\Date;
use Piwik\Plugins\Goals\API;
-use Piwik\Tests\Fixture;
+use Piwik\Tests\Impl\Fixture;
/**
* Adds one site and tracks two visits. One visit is a bot and one has no keyword
diff --git a/tests/PHPUnit/Fixtures/TwoVisitsWithCustomEvents.php b/tests/PHPUnit/Fixtures/TwoVisitsWithCustomEvents.php
index b2777b408f..e0a02f915d 100644
--- a/tests/PHPUnit/Fixtures/TwoVisitsWithCustomEvents.php
+++ b/tests/PHPUnit/Fixtures/TwoVisitsWithCustomEvents.php
@@ -5,11 +5,11 @@
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
-namespace Piwik\Tests\Fixtures;
+namespace Piwik\Tests\Impl\Fixtures;
use Piwik\Date;
use Piwik\Plugins\Goals\API as APIGoals;
-use Piwik\Tests\Fixture;
+use Piwik\Tests\Impl\Fixture;
use PiwikTracker;
/**
diff --git a/tests/PHPUnit/Fixtures/TwoVisitsWithCustomVariables.php b/tests/PHPUnit/Fixtures/TwoVisitsWithCustomVariables.php
index 5ed8c06b85..ac7d4170cf 100644
--- a/tests/PHPUnit/Fixtures/TwoVisitsWithCustomVariables.php
+++ b/tests/PHPUnit/Fixtures/TwoVisitsWithCustomVariables.php
@@ -5,11 +5,11 @@
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
-namespace Piwik\Tests\Fixtures;
+namespace Piwik\Tests\Impl\Fixtures;
use Piwik\Date;
use Piwik\Plugins\Goals\API;
-use Piwik\Tests\Fixture;
+use Piwik\Tests\Impl\Fixture;
/**
* Adds one site with two goals and tracks two visits with custom variables.
diff --git a/tests/PHPUnit/Fixtures/UITestFixture.php b/tests/PHPUnit/Fixtures/UITestFixture.php
index 6f404adefd..b2c9c85f18 100644
--- a/tests/PHPUnit/Fixtures/UITestFixture.php
+++ b/tests/PHPUnit/Fixtures/UITestFixture.php
@@ -5,7 +5,7 @@
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
-namespace Piwik\Tests\Fixtures;
+namespace Piwik\Tests\Impl\Fixtures;
use Exception;
use Piwik\AssetManager;
diff --git a/tests/PHPUnit/Fixtures/VisitOverSeveralDaysImportedLogs.php b/tests/PHPUnit/Fixtures/VisitOverSeveralDaysImportedLogs.php
index 98cc3b50aa..c07548d160 100644
--- a/tests/PHPUnit/Fixtures/VisitOverSeveralDaysImportedLogs.php
+++ b/tests/PHPUnit/Fixtures/VisitOverSeveralDaysImportedLogs.php
@@ -5,9 +5,9 @@
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
-namespace Piwik\Tests\Fixtures;
+namespace Piwik\Tests\Impl\Fixtures;
-use Piwik\Tests\Fixture;
+use Piwik\Tests\Impl\Fixture;
/**
* Import a same visitor, over three different days, in reverse chronological order
diff --git a/tests/PHPUnit/Fixtures/VisitsInDifferentTimezones.php b/tests/PHPUnit/Fixtures/VisitsInDifferentTimezones.php
index 19c7fcc062..201c7a1353 100644
--- a/tests/PHPUnit/Fixtures/VisitsInDifferentTimezones.php
+++ b/tests/PHPUnit/Fixtures/VisitsInDifferentTimezones.php
@@ -5,10 +5,10 @@
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
-namespace Piwik\Tests\Fixtures;
+namespace Piwik\Tests\Impl\Fixtures;
use Piwik\Date;
-use Piwik\Tests\Fixture;
+use Piwik\Tests\Impl\Fixture;
/**
* Adds one site with a non UTC timezone and tracks a couple visits near the end of the day.
diff --git a/tests/PHPUnit/Fixtures/VisitsOverSeveralDays.php b/tests/PHPUnit/Fixtures/VisitsOverSeveralDays.php
index caf67e00aa..01dfd2a4de 100644
--- a/tests/PHPUnit/Fixtures/VisitsOverSeveralDays.php
+++ b/tests/PHPUnit/Fixtures/VisitsOverSeveralDays.php
@@ -5,10 +5,10 @@
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
-namespace Piwik\Tests\Fixtures;
+namespace Piwik\Tests\Impl\Fixtures;
use Piwik\Date;
-use Piwik\Tests\Fixture;
+use Piwik\Tests\Impl\Fixture;
/**
* Adds one website and tracks several visits from one visitor on
diff --git a/tests/PHPUnit/Fixtures/VisitsTwoWebsitesWithAdditionalVisits.php b/tests/PHPUnit/Fixtures/VisitsTwoWebsitesWithAdditionalVisits.php
index 01963cb8ee..93ac8b7c59 100644
--- a/tests/PHPUnit/Fixtures/VisitsTwoWebsitesWithAdditionalVisits.php
+++ b/tests/PHPUnit/Fixtures/VisitsTwoWebsitesWithAdditionalVisits.php
@@ -5,10 +5,10 @@
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
-namespace Piwik\Tests\Fixtures;
+namespace Piwik\Tests\Impl\Fixtures;
use Piwik\Date;
-use Piwik\Tests\Fixture;
+use Piwik\Tests\Impl\Fixture;
/**
* Adds two sites and tracks several visits with possibility to add new visits to the same days
diff --git a/tests/PHPUnit/Impl/Fixture.php b/tests/PHPUnit/Impl/Fixture.php
new file mode 100644
index 0000000000..bfb212107f
--- /dev/null
+++ b/tests/PHPUnit/Impl/Fixture.php
@@ -0,0 +1,861 @@
+<?php
+/**
+ * Piwik - free/libre analytics platform
+ *
+ * @link http://piwik.org
+ * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
+ */
+namespace Piwik\Tests\Impl;
+
+use Piwik\Access;
+use Piwik\Common;
+use Piwik\Config;
+use Piwik\DataAccess\ArchiveTableCreator;
+use Piwik\DataTable\Manager as DataTableManager;
+use Piwik\Date;
+use Piwik\Db;
+use Piwik\DbHelper;
+use Piwik\Log;
+use Piwik\Option;
+use Piwik\Piwik;
+use Piwik\Plugins\LanguagesManager\API as APILanguageManager;
+use Piwik\Plugins\MobileMessaging\MobileMessaging;
+use Piwik\Plugins\ScheduledReports\API as APIScheduledReports;
+use Piwik\Plugins\ScheduledReports\ScheduledReports;
+use Piwik\Plugins\SitesManager\API as APISitesManager;
+use Piwik\Plugins\UserCountry\LocationProvider;
+use Piwik\Plugins\UsersManager\API as APIUsersManager;
+use Piwik\Plugins\UsersManager\UsersManager;
+use Piwik\ReportRenderer;
+use Piwik\Site;
+use Piwik\Tracker\Cache;
+use Piwik\Translate;
+use Piwik\Url;
+use PHPUnit_Framework_Assert;
+use Piwik_TestingEnvironment;
+use FakeAccess;
+use PiwikTracker;
+use Piwik_LocalTracker;
+use Piwik\Updater;
+use Piwik\Plugins\CoreUpdater\CoreUpdater;
+use Exception;
+
+/**
+ * Base type for all system test fixtures. System test fixtures
+ * add visit and related data to the database before a test is run. Different
+ * tests can use the same fixtures.
+ *
+ * This class defines a set of helper methods for fixture types. The helper
+ * methods are public, but ideally they should only be used by fixture types.
+ *
+ * NOTE: YOU SHOULD NOT CREATE A NEW FIXTURE UNLESS THERE IS NO WAY TO MODIFY
+ * AN EXISTING FIXTURE TO HANDLE YOUR USE CASE.
+ *
+ * Related TODO: we should try and reduce the amount of existing fixtures by
+ * merging some together.
+ */
+class Fixture extends PHPUnit_Framework_Assert
+{
+ const IMAGES_GENERATED_ONLY_FOR_OS = 'linux';
+ const IMAGES_GENERATED_FOR_PHP = '5.5';
+ const IMAGES_GENERATED_FOR_GD = '2.1.1';
+ const DEFAULT_SITE_NAME = 'Piwik test';
+
+ const ADMIN_USER_LOGIN = 'superUserLogin';
+ const ADMIN_USER_PASSWORD = 'superUserPass';
+
+ public $dbName = false;
+ public $createConfig = true;
+ public $dropDatabaseInSetUp = true;
+ public $dropDatabaseInTearDown = true;
+ public $loadTranslations = true;
+ public $createSuperUser = true;
+ public $removeExistingSuperUser = true;
+ public $overwriteExisting = true;
+ public $configureComponents = true;
+ public $persistFixtureData = false;
+ public $resetPersistedFixture = false;
+ public $printToScreen = false;
+
+ public $testCaseClass = false;
+ public $extraPluginsToLoad = array();
+
+ public $testEnvironment = null;
+
+ /**
+ * @return string
+ */
+ protected static function getPythonBinary()
+ {
+ if(\Piwik\SettingsServer::isWindows()) {
+ return "C:\Python27\python.exe";
+ }
+ if(SystemTestCase::isTravisCI()) {
+ return 'python2.6';
+ }
+ return 'python';
+ }
+
+ /** Adds data to Piwik. Creates sites, tracks visits, imports log files, etc. */
+ public function setUp()
+ {
+ // empty
+ }
+
+ /** Does any clean up. Most of the time there will be no need to clean up. */
+ public function tearDown()
+ {
+ // empty
+ }
+
+ public function getDbName()
+ {
+ if ($this->dbName !== false) {
+ return $this->dbName;
+ }
+
+ if ($this->persistFixtureData) {
+ return str_replace("\\", "_", get_class($this));
+ }
+
+ return Config::getInstance()->database_tests['dbname'];
+ }
+
+ public function performSetUp($setupEnvironmentOnly = false)
+ {
+ try {
+ if ($this->createConfig) {
+ Config::getInstance()->setTestEnvironment();
+ }
+
+ $this->dbName = $this->getDbName();
+
+ if ($this->persistFixtureData) {
+ $this->dropDatabaseInSetUp = false;
+ $this->dropDatabaseInTearDown = false;
+ $this->overwriteExisting = false;
+ $this->removeExistingSuperUser = false;
+
+ Config::getInstance()->database_tests['dbname'] = Config::getInstance()->database['dbname'] = $this->dbName;
+
+ $this->getTestEnvironment()->dbName = $this->dbName;
+ }
+
+ if ($this->dbName === false) { // must be after test config is created
+ $this->dbName = Config::getInstance()->database['dbname'];
+ }
+
+ static::connectWithoutDatabase();
+
+ if ($this->dropDatabaseInSetUp
+ || $this->resetPersistedFixture
+ ) {
+ $this->dropDatabase();
+ }
+
+ DbHelper::createDatabase($this->dbName);
+ DbHelper::disconnectDatabase();
+
+ // reconnect once we're sure the database exists
+ Config::getInstance()->database['dbname'] = $this->dbName;
+ Db::createDatabaseObject();
+
+ Db::get()->query("SET wait_timeout=28800;");
+
+ DbHelper::createTables();
+
+ \Piwik\Plugin\Manager::getInstance()->unloadPlugins();
+
+ } catch (Exception $e) {
+ static::fail("TEST INITIALIZATION FAILED: " . $e->getMessage() . "\n" . $e->getTraceAsString());
+ }
+
+ include "DataFiles/SearchEngines.php";
+ include "DataFiles/Socials.php";
+ include "DataFiles/Languages.php";
+ include "DataFiles/Countries.php";
+ include "DataFiles/Currencies.php";
+ include "DataFiles/LanguageToCountry.php";
+ include "DataFiles/Providers.php";
+
+ if (!$this->isFixtureSetUp()) {
+ DbHelper::truncateAllTables();
+ }
+
+ static::createAccessInstance();
+
+ // We need to be SU to create websites for tests
+ Access::getInstance()->setSuperUserAccess();
+
+ Cache::deleteTrackerCache();
+
+ static::loadAllPlugins($this->getTestEnvironment(), $this->testCaseClass, $this->extraPluginsToLoad);
+
+ self::updateDatabase();
+
+ self::installAndActivatePlugins();
+
+ $_GET = $_REQUEST = array();
+ $_SERVER['HTTP_REFERER'] = '';
+
+ // Make sure translations are loaded to check messages in English
+ if ($this->loadTranslations) {
+ Translate::reloadLanguage('en');
+ APILanguageManager::getInstance()->setLanguageForUser('superUserLogin', 'en');
+ }
+
+ FakeAccess::$superUserLogin = 'superUserLogin';
+
+ \Piwik\SettingsPiwik::$cachedKnownSegmentsToArchive = null;
+ \Piwik\CacheFile::$invalidateOpCacheBeforeRead = true;
+
+ if ($this->configureComponents) {
+ \Piwik\Plugins\PrivacyManager\IPAnonymizer::deactivate();
+ \Piwik\Plugins\PrivacyManager\DoNotTrackHeaderChecker::deactivate();
+ }
+
+ if ($this->createSuperUser) {
+ self::createSuperUser($this->removeExistingSuperUser);
+ }
+
+ if ($setupEnvironmentOnly) {
+ return;
+ }
+
+ $this->getTestEnvironment()->save();
+ $this->getTestEnvironment()->executeSetupTestEnvHook();
+ Piwik_TestingEnvironment::addSendMailHook();
+
+ if ($this->overwriteExisting
+ || !$this->isFixtureSetUp()
+ ) {
+ $this->setUp();
+
+ $this->markFixtureSetUp();
+ $this->log("Database {$this->dbName} marked as successfully set up.");
+ } else {
+ $this->log("Using existing database {$this->dbName}.");
+ }
+ }
+
+ public function getTestEnvironment()
+ {
+ if ($this->testEnvironment === null) {
+ $this->testEnvironment = new Piwik_TestingEnvironment();
+ $this->testEnvironment->delete();
+
+ if (getenv('PIWIK_USE_XHPROF') == 1) {
+ $this->testEnvironment->useXhprof = true;
+ }
+ }
+ return $this->testEnvironment;
+ }
+
+ public function isFixtureSetUp()
+ {
+ $optionName = get_class($this) . '.setUpFlag';
+ return Option::get($optionName) !== false;
+ }
+
+ public function markFixtureSetUp()
+ {
+ $optionName = get_class($this) . '.setUpFlag';
+ Option::set($optionName, 1);
+ }
+
+ public function performTearDown()
+ {
+ // Note: avoid run SQL in the *tearDown() metohds because it randomly fails on Travis CI
+ // with error Error while sending QUERY packet. PID=XX
+ $this->tearDown();
+
+ self::unloadAllPlugins();
+
+ if ($this->dropDatabaseInTearDown) {
+ $this->dropDatabase();
+ }
+
+ $this->clearInMemoryCaches();
+ }
+
+ public function clearInMemoryCaches()
+ {
+ DataTableManager::getInstance()->deleteAll();
+ Option::clearCache();
+ Site::clearCache();
+ Cache::deleteTrackerCache();
+ Config::getInstance()->clear();
+ ArchiveTableCreator::clear();
+ \Piwik\Plugins\ScheduledReports\API::$cache = array();
+ \Piwik\Registry::unsetInstance();
+ \Piwik\EventDispatcher::getInstance()->clearAllObservers();
+
+ $_GET = $_REQUEST = array();
+ Translate::unloadEnglishTranslation();
+
+ Config::unsetInstance();
+
+ \Piwik\Config::getInstance()->Plugins; // make sure Plugins exists in a config object for next tests that use Plugin\Manager
+ // since Plugin\Manager uses getFromGlobalConfig which doesn't init the config object
+ }
+
+ public static function loadAllPlugins($testEnvironment = null, $testCaseClass = false, $extraPluginsToLoad = array())
+ {
+ if (empty($testEnvironment)) {
+ $testEnvironment = new Piwik_TestingEnvironment();
+ }
+
+ DbHelper::createTables();
+ $pluginsManager = \Piwik\Plugin\Manager::getInstance();
+
+ $plugins = $testEnvironment->getCoreAndSupportedPlugins();
+
+ // make sure the plugin that executed this method is included in the plugins to load
+ $extraPlugins = array_merge($extraPluginsToLoad, array(
+ \Piwik\Plugin::getPluginNameFromBacktrace(debug_backtrace()),
+ \Piwik\Plugin::getPluginNameFromNamespace($testCaseClass),
+ \Piwik\Plugin::getPluginNameFromNamespace(get_called_class())
+ ));
+ foreach ($extraPlugins as $pluginName) {
+ if (empty($pluginName)) {
+ continue;
+ }
+
+ if (in_array($pluginName, $plugins)) {
+ continue;
+ }
+
+ $plugins[] = $pluginName;
+ if ($testEnvironment) {
+ $testEnvironment->pluginsToLoad = array_merge($testEnvironment->pluginsToLoad ?: array(), array($pluginName));
+ }
+ }
+
+ Log::debug("Plugins to load during tests: " . implode(', ', $plugins));
+
+ $pluginsManager->loadPlugins($plugins);
+ }
+
+ public static function installAndActivatePlugins()
+ {
+ $pluginsManager = \Piwik\Plugin\Manager::getInstance();
+
+ // Install plugins
+ $messages = $pluginsManager->installLoadedPlugins();
+ if(!empty($messages)) {
+ Log::info("Plugin loading messages: %s", implode(" --- ", $messages));
+ }
+
+ // Activate them
+ foreach($pluginsManager->getLoadedPlugins() as $plugin) {
+ $name = $plugin->getPluginName();
+ if (!$pluginsManager->isPluginActivated($name)) {
+ $pluginsManager->activatePlugin($name);
+ }
+ }
+ }
+
+ public static function unloadAllPlugins()
+ {
+ try {
+ $manager = \Piwik\Plugin\Manager::getInstance();
+ $plugins = $manager->getLoadedPlugins();
+ foreach ($plugins as $plugin) {
+ $plugin->uninstall();
+ }
+ \Piwik\Plugin\Manager::getInstance()->unloadPlugins();
+ } catch (Exception $e) {
+ }
+ }
+
+ /**
+ * Creates a website, then sets its creation date to a day earlier than specified dateTime
+ * Useful to create a website now, but force data to be archived back in the past.
+ *
+ * @param string $dateTime eg '2010-01-01 12:34:56'
+ * @param int $ecommerce
+ * @param string $siteName
+ *
+ * @param bool|string $siteUrl
+ * @param int $siteSearch
+ * @param null|string $searchKeywordParameters
+ * @param null|string $searchCategoryParameters
+ * @return int idSite of website created
+ */
+ public static function createWebsite($dateTime, $ecommerce = 0, $siteName = false, $siteUrl = false,
+ $siteSearch = 1, $searchKeywordParameters = null,
+ $searchCategoryParameters = null, $timezone = null)
+ {
+ if($siteName === false) {
+ $siteName = self::DEFAULT_SITE_NAME;
+ }
+ $idSite = APISitesManager::getInstance()->addSite(
+ $siteName,
+ $siteUrl === false ? "http://piwik.net/" : $siteUrl,
+ $ecommerce,
+ $siteSearch, $searchKeywordParameters, $searchCategoryParameters,
+ $ips = null,
+ $excludedQueryParameters = null,
+ $timezone,
+ $currency = null
+ );
+
+ // Manually set the website creation date to a day earlier than the earliest day we record stats for
+ Db::get()->update(Common::prefixTable("site"),
+ array('ts_created' => Date::factory($dateTime)->subDay(1)->getDatetime()),
+ "idsite = $idSite"
+ );
+
+ // Clear the memory Website cache
+ Site::clearCache();
+
+ return $idSite;
+ }
+
+ /**
+ * Returns URL to Piwik root.
+ *
+ * @return string
+ */
+ public static function getRootUrl()
+ {
+ $piwikUrl = Url::getCurrentUrlWithoutFileName();
+
+ $pathBeforeRoot = 'tests';
+ // Running from a plugin
+ if (strpos($piwikUrl, 'plugins/') !== false) {
+ $pathBeforeRoot = 'plugins';
+ }
+
+ $testsInPath = strpos($piwikUrl, $pathBeforeRoot . '/');
+ if ($testsInPath !== false) {
+ $piwikUrl = substr($piwikUrl, 0, $testsInPath);
+ }
+
+ // in case force_ssl=1, or assume_secure_protocol=1, is set in tests
+ // we don't want to require Travis CI or devs to setup HTTPS on their local machine
+ $piwikUrl = str_replace("https://", "http://", $piwikUrl);
+
+ return $piwikUrl;
+ }
+
+ /**
+ * Returns URL to the proxy script, used to ensure piwik.php
+ * uses the test environment, and allows variable overwriting
+ *
+ * @return string
+ */
+ public static function getTrackerUrl()
+ {
+ return self::getRootUrl() . 'tests/PHPUnit/proxy/piwik.php';
+ }
+
+ /**
+ * Returns a PiwikTracker object that you can then use to track pages or goals.
+ *
+ * @param int $idSite
+ * @param string $dateTime
+ * @param boolean $defaultInit If set to true, the tracker object will have default IP, user agent, time, resolution, etc.
+ * @param bool $useLocal
+ *
+ * @return PiwikTracker
+ */
+ public static function getTracker($idSite, $dateTime, $defaultInit = true, $useLocal = false)
+ {
+ if ($useLocal) {
+ require_once PIWIK_INCLUDE_PATH . '/tests/LocalTracker.php';
+ $t = new Piwik_LocalTracker($idSite, self::getTrackerUrl());
+ } else {
+ $t = new PiwikTracker($idSite, self::getTrackerUrl());
+ }
+ $t->setForceVisitDateTime($dateTime);
+
+ if ($defaultInit) {
+ $t->setTokenAuth(self::getTokenAuth());
+ $t->setIp('156.5.3.2');
+
+ // Optional tracking
+ $t->setUserAgent("Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.2.6) Gecko/20100625 Firefox/3.6.6 (.NET CLR 3.5.30729)");
+ $t->setBrowserLanguage('fr');
+ $t->setLocalTime('12:34:06');
+ $t->setResolution(1024, 768);
+ $t->setBrowserHasCookies(true);
+ $t->setPlugins($flash = true, $java = true, $director = false);
+ }
+ return $t;
+ }
+
+ /**
+ * Checks that the response is a GIF image as expected.
+ * Will fail the test if the response is not the expected GIF
+ *
+ * @param $response
+ */
+ public static function checkResponse($response)
+ {
+ $trans_gif_64 = "R0lGODlhAQABAIAAAAAAAAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==";
+ $expectedResponse = base64_decode($trans_gif_64);
+
+ $url = "\n =========================== \n URL was: " . PiwikTracker::$DEBUG_LAST_REQUESTED_URL;
+ self::assertEquals($expectedResponse, $response, "Expected GIF beacon, got: <br/>\n"
+ . var_export($response, true)
+ . "\n If you are stuck, you can enable [Tracker] debug=1; in config.ini.php to get more debug info."
+ . base64_encode($response)
+ . $url
+ );
+ }
+
+ /**
+ * Checks that the response from bulk tracking is a valid JSON
+ * string. Will fail the test if JSON status is not success.
+ *
+ * @param $response
+ */
+ public static function checkBulkTrackingResponse($response) {
+ $data = json_decode($response, true);
+ if (!is_array($data) || empty($response)) {
+ throw new Exception("Bulk tracking response (".$response.") is not an array: " . var_export($data, true) . "\n");
+ }
+ if(!isset($data['status'])) {
+ throw new Exception("Returned data didn't have a status: " . var_export($data,true));
+ }
+
+ self::assertArrayHasKey('status', $data);
+ self::assertEquals('success', $data['status'], "expected success, got: " . var_export($data, true));
+ }
+
+ public static function makeLocation($city, $region, $country, $lat = null, $long = null, $isp = null)
+ {
+ return array(LocationProvider::CITY_NAME_KEY => $city,
+ LocationProvider::REGION_CODE_KEY => $region,
+ LocationProvider::COUNTRY_CODE_KEY => $country,
+ LocationProvider::LATITUDE_KEY => $lat,
+ LocationProvider::LONGITUDE_KEY => $long,
+ LocationProvider::ISP_KEY => $isp);
+ }
+
+ /**
+ * Returns the Super User token auth that can be used in tests. Can be used to
+ * do bulk tracking.
+ *
+ * @return string
+ */
+ public static function getTokenAuth()
+ {
+ return APIUsersManager::getInstance()->getTokenAuth(
+ self::ADMIN_USER_LOGIN,
+ UsersManager::getPasswordHash(self::ADMIN_USER_PASSWORD)
+ );
+ }
+
+ public static function createSuperUser($removeExisting = true)
+ {
+ $login = self::ADMIN_USER_LOGIN;
+ $password = UsersManager::getPasswordHash(self::ADMIN_USER_PASSWORD);
+ $token = self::getTokenAuth();
+
+ $model = new \Piwik\Plugins\UsersManager\Model();
+ if ($removeExisting) {
+ $model->deleteUserOnly($login);
+ }
+
+ $user = $model->getUser($login);
+
+ if (empty($user)) {
+ $model->addUser($login, $password, 'hello@example.org', $login, $token, Date::now()->getDatetime());
+ } else {
+ $model->updateUser($login, $password, 'hello@example.org', $login, $token);
+ }
+
+ if (empty($user['superuser_access'])) {
+ $model->setSuperUserAccess($login, true);
+ }
+
+ return $model->getUserByTokenAuth($token);
+ }
+
+ /**
+ * Create three MAIL and two MOBILE scheduled reports
+ *
+ * Reports sent by mail can contain PNG graphs when the user specifies it.
+ * Depending on the system under test, generated images differ slightly.
+ * Because of this discrepancy, PNG graphs are only tested if the system under test
+ * has the characteristics described in 'canImagesBeIncludedInScheduledReports'.
+ * See tests/README.md for more detail.
+ *
+ * @see canImagesBeIncludedInScheduledReports
+ * @param int $idSite id of website created
+ */
+ public static function setUpScheduledReports($idSite)
+ {
+ // fake access is needed so API methods can call Piwik::getCurrentUserLogin(), e.g: 'ScheduledReports.addReport'
+ $pseudoMockAccess = new FakeAccess;
+ FakeAccess::$superUser = true;
+ Access::setSingletonInstance($pseudoMockAccess);
+
+ // retrieve available reports
+ $availableReportMetadata = APIScheduledReports::getReportMetadata($idSite, ScheduledReports::EMAIL_TYPE);
+
+ $availableReportIds = array();
+ foreach ($availableReportMetadata as $reportMetadata) {
+ $availableReportIds[] = $reportMetadata['uniqueId'];
+ }
+
+ //@review should we also test evolution graphs?
+ // set-up mail report
+ APIScheduledReports::getInstance()->addReport(
+ $idSite,
+ 'Mail Test report',
+ 'day', // overridden in getApiForTestingScheduledReports()
+ 0,
+ ScheduledReports::EMAIL_TYPE,
+ ReportRenderer::HTML_FORMAT, // overridden in getApiForTestingScheduledReports()
+ $availableReportIds,
+ array(ScheduledReports::DISPLAY_FORMAT_PARAMETER => ScheduledReports::DISPLAY_FORMAT_TABLES_ONLY)
+ );
+
+ // set-up sms report for one website
+ APIScheduledReports::getInstance()->addReport(
+ $idSite,
+ 'SMS Test report, one website',
+ 'day', // overridden in getApiForTestingScheduledReports()
+ 0,
+ MobileMessaging::MOBILE_TYPE,
+ MobileMessaging::SMS_FORMAT,
+ array("MultiSites_getOne"),
+ array("phoneNumbers" => array())
+ );
+
+ // set-up sms report for all websites
+ APIScheduledReports::getInstance()->addReport(
+ $idSite,
+ 'SMS Test report, all websites',
+ 'day', // overridden in getApiForTestingScheduledReports()
+ 0,
+ MobileMessaging::MOBILE_TYPE,
+ MobileMessaging::SMS_FORMAT,
+ array("MultiSites_getAll"),
+ array("phoneNumbers" => array())
+ );
+
+ if (self::canImagesBeIncludedInScheduledReports()) {
+ // set-up mail report with images
+ APIScheduledReports::getInstance()->addReport(
+ $idSite,
+ 'Mail Test report',
+ 'day', // overridden in getApiForTestingScheduledReports()
+ 0,
+ ScheduledReports::EMAIL_TYPE,
+ ReportRenderer::HTML_FORMAT, // overridden in getApiForTestingScheduledReports()
+ $availableReportIds,
+ array(ScheduledReports::DISPLAY_FORMAT_PARAMETER => ScheduledReports::DISPLAY_FORMAT_TABLES_AND_GRAPHS)
+ );
+
+ // set-up mail report with one row evolution based png graph
+ APIScheduledReports::getInstance()->addReport(
+ $idSite,
+ 'Mail Test report',
+ 'day',
+ 0,
+ ScheduledReports::EMAIL_TYPE,
+ ReportRenderer::HTML_FORMAT,
+ array('Actions_getPageTitles'),
+ array(
+ ScheduledReports::DISPLAY_FORMAT_PARAMETER => ScheduledReports::DISPLAY_FORMAT_GRAPHS_ONLY,
+ ScheduledReports::EVOLUTION_GRAPH_PARAMETER => 'true',
+ )
+ );
+ }
+ }
+
+ /**
+ * Return true if system under test has Piwik core team's most common configuration
+ */
+ public static function canImagesBeIncludedInScheduledReports()
+ {
+ $gdInfo = gd_info();
+ return
+ stristr(php_uname(), self::IMAGES_GENERATED_ONLY_FOR_OS) &&
+ strpos( phpversion(), self::IMAGES_GENERATED_FOR_PHP) !== false &&
+ strpos( $gdInfo['GD Version'], self::IMAGES_GENERATED_FOR_GD) !== false;
+ }
+
+ public static $geoIpDbUrl = 'http://piwik-team.s3.amazonaws.com/GeoIP.dat.gz';
+ public static $geoLiteCityDbUrl = 'http://piwik-team.s3.amazonaws.com/GeoLiteCity.dat.gz';
+
+ public static function downloadGeoIpDbs()
+ {
+ $geoIpOutputDir = PIWIK_INCLUDE_PATH . '/tests/lib/geoip-files';
+ self::downloadAndUnzip(self::$geoIpDbUrl, $geoIpOutputDir, 'GeoIP.dat');
+ self::downloadAndUnzip(self::$geoLiteCityDbUrl, $geoIpOutputDir, 'GeoIPCity.dat');
+ }
+
+ public static function downloadAndUnzip($url, $outputDir, $filename)
+ {
+ $bufferSize = 1024 * 1024;
+
+ if (!is_dir($outputDir)) {
+ mkdir($outputDir);
+ }
+
+ $deflatedOut = $outputDir . '/' . $filename;
+ $outfileName = $deflatedOut . '.gz';
+
+ if (file_exists($deflatedOut)) {
+ return;
+ }
+
+ $dump = fopen($url, 'rb');
+ $outfile = fopen($outfileName, 'wb');
+ while (!feof($dump)) {
+ fwrite($outfile, fread($dump, $bufferSize), $bufferSize);
+ }
+ fclose($dump);
+ fclose($outfile);
+
+ // unzip the dump
+ exec("gunzip -c \"" . $outfileName . "\" > \"$deflatedOut\"", $output, $return);
+ if ($return !== 0) {
+ Log::info("gunzip failed with file that has following contents:");
+ Log::info(file_get_contents($outfile));
+
+ throw new Exception("gunzip failed($return): " . implode("\n", $output));
+ }
+ }
+
+ protected static function executeLogImporter($logFile, $options)
+ {
+ $python = self::getPythonBinary();
+
+ // create the command
+ $cmd = $python
+ . ' "' . PIWIK_INCLUDE_PATH . '/misc/log-analytics/import_logs.py" ' # script loc
+ . '-ddd ' // debug
+ . '--url="' . self::getRootUrl() . 'tests/PHPUnit/proxy/" ' # proxy so that piwik uses test config files
+ ;
+
+ foreach ($options as $name => $value) {
+ $cmd .= $name;
+ if ($value !== false) {
+ $cmd .= '="' . $value . '"';
+ }
+ $cmd .= ' ';
+ }
+
+ $cmd .= '"' . $logFile . '" 2>&1';
+
+ // run the command
+ exec($cmd, $output, $result);
+ if ($result !== 0) {
+ throw new Exception("log importer failed: " . implode("\n", $output) . "\n\ncommand used: $cmd");
+ }
+
+ return $output;
+ }
+
+ public static function siteCreated($idSite)
+ {
+ return Db::fetchOne("SELECT COUNT(*) FROM " . Common::prefixTable('site') . " WHERE idsite = ?", array($idSite)) != 0;
+ }
+
+ public static function goalExists($idSite, $idGoal)
+ {
+ return Db::fetchOne("SELECT COUNT(*) FROM " . Common::prefixTable('goal') . " WHERE idgoal = ? AND idsite = ?", array($idGoal, $idSite)) != 0;
+ }
+
+ /**
+ * Connects to MySQL w/o specifying a database.
+ */
+ public static function connectWithoutDatabase()
+ {
+ $dbConfig = Config::getInstance()->database;
+ $oldDbName = $dbConfig['dbname'];
+ $dbConfig['dbname'] = null;
+
+ Db::createDatabaseObject($dbConfig);
+
+ $dbConfig['dbname'] = $oldDbName;
+ }
+
+ /**
+ * Sets up access instance.
+ */
+ public static function createAccessInstance()
+ {
+ Access::setSingletonInstance(null);
+ Access::getInstance();
+ Piwik::postEvent('Request.initAuthenticationObject');
+ }
+
+ public function dropDatabase($dbName = null)
+ {
+ $dbName = $dbName ?: $this->dbName ?: Config::getInstance()->database_tests['dbname'];
+
+ $this->log("Dropping database '$dbName'...");
+
+ $config = _parse_ini_file(PIWIK_INCLUDE_PATH . '/config/config.ini.php', true);
+ $originalDbName = $config['database']['dbname'];
+ if ($dbName == $originalDbName
+ && $dbName != 'piwik_tests'
+ ) { // santity check
+ throw new \Exception("Trying to drop original database '$originalDbName'. Something's wrong w/ the tests.");
+ }
+
+ DbHelper::dropDatabase($dbName);
+ }
+
+ public function log($message)
+ {
+ if ($this->printToScreen) {
+ echo $message . "\n";
+ }
+ }
+
+ // NOTE: since API_Request does sanitization, API methods do not. when calling them, we must
+ // sometimes do sanitization ourselves.
+ public static function makeXssContent($type, $sanitize = false)
+ {
+ $result = "<script>$('body').html('$type XSS!');</script>";
+ if ($sanitize) {
+ $result = Common::sanitizeInputValue($result);
+ }
+ return $result;
+ }
+
+ public static function updateDatabase($force = false)
+ {
+ Cache::deleteTrackerCache();
+ Option::clearCache();
+
+ if ($force) {
+ // remove version options to force update
+ Option::deleteLike('version%');
+ Option::set('version_core', '0.0');
+ }
+
+ $updater = new Updater();
+ $componentsWithUpdateFile = CoreUpdater::getComponentUpdates($updater);
+ if (empty($componentsWithUpdateFile)) {
+ return false;
+ }
+
+ $result = CoreUpdater::updateComponents($updater, $componentsWithUpdateFile);
+ if (!empty($result['coreError'])
+ || !empty($result['warnings'])
+ || !empty($result['errors'])
+ ) {
+ throw new \Exception("Failed to update database (errors or warnings found): " . print_r($result, true));
+ }
+
+ return $result;
+ }
+}
+
+// needed by tests that use stored segments w/ the proxy index.php
+class OverrideLogin extends Access
+{
+ public function getLogin()
+ {
+ return 'superUserLogin';
+ }
+} \ No newline at end of file
diff --git a/tests/PHPUnit/Impl/IntegrationTestCase.php b/tests/PHPUnit/Impl/IntegrationTestCase.php
new file mode 100644
index 0000000000..7036993eb0
--- /dev/null
+++ b/tests/PHPUnit/Impl/IntegrationTestCase.php
@@ -0,0 +1,97 @@
+<?php
+/**
+ * Piwik - free/libre analytics platform
+ *
+ * @link http://piwik.org
+ * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
+ */
+
+namespace Piwik\Tests\Impl;
+
+use Piwik\Config;
+use Piwik\Db;
+
+/**
+ * Tests extending IntegrationTestCase are much slower to run: the setUp will
+ * create all Piwik tables in a freshly empty test database.
+ *
+ * This allows each test method to start from a clean DB and setup initial state to
+ * then test it.
+ *
+ */
+class IntegrationTestCase extends SystemTestCase
+{
+ /**
+ * @var Fixture
+ */
+ public static $fixture;
+ public static $tableData;
+
+ /**
+ * Implementation details:
+ *
+ * To increase speed of tests, database setup is done once in setUpBeforeClass.
+ * Afterwards, the content of the tables is stored in a static class variable,
+ * self::$tableData. Before each individual test, the database tables are
+ * truncated and the data in self::$tableData is restored.
+ *
+ * If your test modifies table columns, you will need to recreate the database
+ * completely. This can be accomplished by:
+ *
+ * public function setUp()
+ * {
+ * self::$fixture->performSetUp();
+ * }
+ *
+ * public function tearDown()
+ * {
+ * parent::tearDown();
+ * self::$fixture->performTearDown();
+ * }
+ */
+ public static function setUpBeforeClass()
+ {
+ static::configureFixture(static::$fixture);
+ parent::setUpBeforeClass();
+
+ self::$tableData = self::getDbTablesWithData();
+ }
+
+ public static function tearDownAfterClass()
+ {
+ self::$tableData = array();
+ }
+
+ /**
+ * Setup the database and create the base tables for all tests
+ */
+ public function setUp()
+ {
+ parent::setUp();
+
+ Config::getInstance()->setTestEnvironment();
+
+ if (!empty(self::$tableData)) {
+ self::restoreDbTables(self::$tableData);
+ }
+ }
+
+ /**
+ * Resets all caches and drops the database
+ */
+ public function tearDown()
+ {
+ self::$fixture->clearInMemoryCaches();
+
+ parent::tearDown();
+ }
+
+ protected static function configureFixture($fixture)
+ {
+ $fixture->loadTranslations = false;
+ $fixture->createSuperUser = false;
+ $fixture->configureComponents = false;
+ }
+}
+
+IntegrationTestCase::$fixture = new Fixture(); \ No newline at end of file
diff --git a/tests/PHPUnit/SystemTestCase.php b/tests/PHPUnit/Impl/SystemTestCase.php
index 90e7da4725..ad7845efd4 100755
--- a/tests/PHPUnit/SystemTestCase.php
+++ b/tests/PHPUnit/Impl/SystemTestCase.php
@@ -5,7 +5,8 @@
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
-namespace Piwik\Tests;
+
+namespace Piwik\Tests\Impl;
use Exception;
use Piwik\ArchiveProcessor\Rules;
@@ -16,9 +17,7 @@ use Piwik\Db;
use Piwik\DbHelper;
use Piwik\ReportRenderer;
use Piwik\Translate;
-use Piwik\Tests\Impl\TestRequestCollection;
-use Piwik\Tests\Impl\TestRequestResponse;
-use Piwik\Tests\Impl\ApiTestConfig;
+use Piwik\Tests\Impl\Fixture;
use Piwik\Log;
use PHPUnit_Framework_TestCase;
@@ -42,6 +41,8 @@ abstract class SystemTestCase extends PHPUnit_Framework_TestCase
protected $missingExpectedFiles = array();
protected $comparisonFailures = array();
+ public static $fixture;
+
public static function setUpBeforeClass()
{
Log::debug("Setting up " . get_called_class());
@@ -489,7 +490,7 @@ abstract class SystemTestCase extends PHPUnit_Framework_TestCase
*/
public static function getPathToTestDirectory()
{
- return dirname(__FILE__) . DIRECTORY_SEPARATOR . 'System';
+ return dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'System';
}
/**
diff --git a/tests/PHPUnit/Impl/TestRequestCollection.php b/tests/PHPUnit/Impl/TestRequestCollection.php
index 20208765e3..556ab1bb24 100644
--- a/tests/PHPUnit/Impl/TestRequestCollection.php
+++ b/tests/PHPUnit/Impl/TestRequestCollection.php
@@ -12,7 +12,6 @@ use Piwik\API\DocumentationGenerator;
use Piwik\API\Proxy;
use Piwik\API\Request;
use Piwik\UrlHelper;
-use Piwik\Tests\SystemTestCase;
use \Exception;
use \PHPUnit_Framework_Assert;
diff --git a/tests/PHPUnit/Impl/TestRequestResponse.php b/tests/PHPUnit/Impl/TestRequestResponse.php
index 6ceeb564f2..f71a430aa6 100644
--- a/tests/PHPUnit/Impl/TestRequestResponse.php
+++ b/tests/PHPUnit/Impl/TestRequestResponse.php
@@ -9,7 +9,6 @@
namespace Piwik\Tests\Impl;
use Piwik\API\Request;
-use Piwik\Tests\SystemTestCase;
use PHPUnit_Framework_Assert as Asserts;
use Exception;
diff --git a/tests/PHPUnit/Integration/AccessTest.php b/tests/PHPUnit/Integration/AccessTest.php
index 12cd119d8c..aad0e22766 100644
--- a/tests/PHPUnit/Integration/AccessTest.php
+++ b/tests/PHPUnit/Integration/AccessTest.php
@@ -7,6 +7,7 @@
*/
use Piwik\Access;
use Piwik\AuthResult;
+use Piwik\Tests\Impl\IntegrationTestCase;
/**
* Class Core_AccessTest
diff --git a/tests/PHPUnit/Integration/ArchiveProcessingTest.php b/tests/PHPUnit/Integration/ArchiveProcessingTest.php
index 65f1dd0c7f..88ec83bea6 100644
--- a/tests/PHPUnit/Integration/ArchiveProcessingTest.php
+++ b/tests/PHPUnit/Integration/ArchiveProcessingTest.php
@@ -20,6 +20,7 @@ use Piwik\Plugins\SitesManager\API;
use Piwik\Segment;
use Piwik\SettingsServer;
use Piwik\Site;
+use Piwik\Tests\Impl\IntegrationTestCase;
class Core_ArchiveProcessorTest extends ArchiveProcessor\Loader {
diff --git a/tests/PHPUnit/Unit/AssetManager/UIAssetMinifierTest.php b/tests/PHPUnit/Integration/AssetManager/UIAssetMinifierTest.php
index df62e5c86b..1ece0ca556 100644
--- a/tests/PHPUnit/Unit/AssetManager/UIAssetMinifierTest.php
+++ b/tests/PHPUnit/Integration/AssetManager/UIAssetMinifierTest.php
@@ -10,7 +10,7 @@
use Piwik\AssetManager\UIAsset\OnDiskUIAsset;
use Piwik\AssetManager\UIAssetMinifier;
-class UIAssetMinifierTest extends PHPUnit_Framework_TestCase
+class Piwik_Test_UIAssetMinifierTest extends PHPUnit_Framework_TestCase
{
/**
diff --git a/tests/PHPUnit/Integration/CliMultiTest.php b/tests/PHPUnit/Integration/CliMultiTest.php
index 6ae07f2318..89555d4d01 100644
--- a/tests/PHPUnit/Integration/CliMultiTest.php
+++ b/tests/PHPUnit/Integration/CliMultiTest.php
@@ -8,8 +8,8 @@
use Piwik\CliMulti;
use Piwik\Version;
-use Piwik\Tests\SystemTestCase;
-use Piwik\Tests\Fixture;
+use Piwik\Tests\Impl\SystemTestCase;
+use Piwik\Tests\Impl\Fixture;
/**
* Class Core_CliMultiTest
diff --git a/tests/PHPUnit/Integration/CronArchive/SharedSiteIdsTest.php b/tests/PHPUnit/Integration/CronArchive/SharedSiteIdsTest.php
index b9826dc676..4fcba84352 100644
--- a/tests/PHPUnit/Integration/CronArchive/SharedSiteIdsTest.php
+++ b/tests/PHPUnit/Integration/CronArchive/SharedSiteIdsTest.php
@@ -7,6 +7,7 @@
*/
use Piwik\CronArchive\SharedSiteIds;
+use Piwik\Tests\Impl\IntegrationTestCase;
/**
* @group Core
diff --git a/tests/PHPUnit/Integration/DbTest.php b/tests/PHPUnit/Integration/DbTest.php
index aacef131e9..562e8f9a35 100644
--- a/tests/PHPUnit/Integration/DbTest.php
+++ b/tests/PHPUnit/Integration/DbTest.php
@@ -7,6 +7,7 @@
*/
use Piwik\Common;
use Piwik\Db;
+use Piwik\Tests\Impl\IntegrationTestCase;
/**
* Class Core_DbTest
diff --git a/tests/PHPUnit/Unit/HttpTest.php b/tests/PHPUnit/Integration/HttpTest.php
index 71f03aa528..9d197a61a5 100644
--- a/tests/PHPUnit/Unit/HttpTest.php
+++ b/tests/PHPUnit/Integration/HttpTest.php
@@ -6,12 +6,12 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
use Piwik\Http;
-use Piwik\Tests\Fixture;
+use Piwik\Tests\Impl\Fixture;
/**
* @group HttpTest
*/
-class HttpTest extends PHPUnit_Framework_TestCase
+class Piwik_Test_HttpTest extends PHPUnit_Framework_TestCase
{
/**
* Dataprovider for testFetchRemoteFile
diff --git a/tests/PHPUnit/Integration/JsProxyTest.php b/tests/PHPUnit/Integration/JsProxyTest.php
index cd4c84a763..d3991fb6a9 100644
--- a/tests/PHPUnit/Integration/JsProxyTest.php
+++ b/tests/PHPUnit/Integration/JsProxyTest.php
@@ -6,7 +6,7 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
-use Piwik\Tests\Fixture;
+use Piwik\Tests\Impl\Fixture;
class Test_Piwik_JsProxy extends PHPUnit_Framework_TestCase
{
diff --git a/tests/PHPUnit/Integration/LogTest.php b/tests/PHPUnit/Integration/LogTest.php
index b7271dc866..6e453fa858 100644
--- a/tests/PHPUnit/Integration/LogTest.php
+++ b/tests/PHPUnit/Integration/LogTest.php
@@ -12,6 +12,7 @@ use Piwik\Error;
use Piwik\ExceptionHandler;
use Piwik\Log;
use Piwik\Plugins\TestPlugin\TestLoggingUtility;
+use Piwik\Tests\Impl\IntegrationTestCase;
require_once PIWIK_INCLUDE_PATH . '/tests/resources/TestPluginLogClass.php';
@@ -31,9 +32,9 @@ class Core_LogTest extends IntegrationTestCase
'screen' => 'dummy error message<br />
<br />
--&gt; To temporarily debug this error further, set const PIWIK_PRINT_ERROR_BACKTRACE=true; in index.php',
- 'file' => '[Core_LogTest] LogTest.php(165): dummy error message
+ 'file' => '[Core_LogTest] LogTest.php(166): dummy error message
dummy backtrace',
- 'database' => '[Core_LogTest] LogTest.php(165): dummy error message
+ 'database' => '[Core_LogTest] LogTest.php(166): dummy error message
dummy backtrace'
);
diff --git a/tests/PHPUnit/Integration/OptionTest.php b/tests/PHPUnit/Integration/OptionTest.php
index 6bab1cf65b..42c8418e12 100644
--- a/tests/PHPUnit/Integration/OptionTest.php
+++ b/tests/PHPUnit/Integration/OptionTest.php
@@ -8,6 +8,7 @@
use Piwik\Common;
use Piwik\Db;
use Piwik\Option;
+use Piwik\Tests\Impl\IntegrationTestCase;
/**
* Class Core_OptionTest
diff --git a/tests/PHPUnit/Integration/PiwikTest.php b/tests/PHPUnit/Integration/PiwikTest.php
index fc04c81398..99262e56ba 100644
--- a/tests/PHPUnit/Integration/PiwikTest.php
+++ b/tests/PHPUnit/Integration/PiwikTest.php
@@ -11,6 +11,7 @@ use Piwik\MetricsFormatter;
use Piwik\Piwik;
use Piwik\Plugins\SitesManager\API;
use Piwik\Translate;
+use Piwik\Tests\Impl\IntegrationTestCase;
/**
* Class Core_PiwikTest
diff --git a/tests/PHPUnit/Integration/Plugin/SettingsTest.php b/tests/PHPUnit/Integration/Plugin/SettingsTest.php
index 3846f4cd15..5c9b16909b 100644
--- a/tests/PHPUnit/Integration/Plugin/SettingsTest.php
+++ b/tests/PHPUnit/Integration/Plugin/SettingsTest.php
@@ -9,6 +9,7 @@
use Piwik\Access;
use Piwik\Plugin\Settings as PluginSettings;
use Piwik\Settings\Setting;
+use Piwik\Tests\Impl\IntegrationTestCase;
class CorePluginSettingsTest extends \Piwik\Plugins\ExampleSettingsPlugin\Settings {
@@ -416,7 +417,7 @@ class Core_Plugin_SettingsTest extends IntegrationTestCase
public function test_getSettingsForCurrentUser_shouldReturnAllSettingsIfEnoughPermissionsAndSortThemBySettingOrder()
{
- if(\Piwik\Tests\SystemTestCase::isPhpVersion53()) {
+ if(\Piwik\Tests\Impl\SystemTestCase::isPhpVersion53()) {
$this->markTestSkipped('does not pass on PHP 5.3.3');
}
$this->setSuperUser();
diff --git a/tests/PHPUnit/Unit/ReleaseCheckListTest.php b/tests/PHPUnit/Integration/ReleaseCheckListTest.php
index 255c03fb79..947b06a537 100644
--- a/tests/PHPUnit/Unit/ReleaseCheckListTest.php
+++ b/tests/PHPUnit/Integration/ReleaseCheckListTest.php
@@ -6,13 +6,11 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
use Piwik\Filesystem;
-use Piwik\Plugin\Manager;
-use Piwik\SettingsServer;
/**
* @group ReleaseCheckListTest
*/
-class ReleaseCheckListTest extends PHPUnit_Framework_TestCase
+class Test_Piwik_ReleaseCheckListTest extends PHPUnit_Framework_TestCase
{
public function setUp()
{
diff --git a/tests/PHPUnit/Integration/ReportTest.php b/tests/PHPUnit/Integration/ReportTest.php
index a7dc7509c4..ce3d87d38f 100644
--- a/tests/PHPUnit/Integration/ReportTest.php
+++ b/tests/PHPUnit/Integration/ReportTest.php
@@ -18,7 +18,8 @@ use Piwik\WidgetsList;
use Piwik\Translate;
use Piwik\Menu\MenuReporting;
use Piwik\Plugin\Manager as PluginManager;
-use Piwik\Tests\Fixture;
+use Piwik\Tests\Impl\Fixture;
+use Piwik\Tests\Impl\IntegrationTestCase;
class GetBasicReport extends Report
{
diff --git a/tests/PHPUnit/Integration/SegmentTest.php b/tests/PHPUnit/Integration/SegmentTest.php
index 00312063c0..15277e379d 100644
--- a/tests/PHPUnit/Integration/SegmentTest.php
+++ b/tests/PHPUnit/Integration/SegmentTest.php
@@ -8,6 +8,7 @@
use Piwik\Access;
use Piwik\Common;
use Piwik\Segment;
+use Piwik\Tests\Impl\IntegrationTestCase;
/**
* @group SegmentTest
diff --git a/tests/PHPUnit/Unit/ServeStaticFileTest.php b/tests/PHPUnit/Integration/ServeStaticFileTest.php
index a3ec57a7af..c8ff7f9c69 100644
--- a/tests/PHPUnit/Unit/ServeStaticFileTest.php
+++ b/tests/PHPUnit/Integration/ServeStaticFileTest.php
@@ -17,7 +17,7 @@
use Piwik\ProxyHttp;
use Piwik\SettingsServer;
-use Piwik\Tests\Fixture;
+use Piwik\Tests\Impl\Fixture;
define("TEST_FILE_LOCATION", realpath(dirname(__FILE__) . "/../../resources/lipsum.txt"));
define("TEST_FILE_CONTENT_TYPE", "text/plain");
diff --git a/tests/PHPUnit/Integration/SqlTest.php b/tests/PHPUnit/Integration/SqlTest.php
index 843e4e950a..3d6fbac9e3 100755
--- a/tests/PHPUnit/Integration/SqlTest.php
+++ b/tests/PHPUnit/Integration/SqlTest.php
@@ -1,5 +1,6 @@
<?php
use Piwik\Db;
+use Piwik\Tests\Impl\IntegrationTestCase;
/**
* Piwik - free/libre analytics platform
diff --git a/tests/PHPUnit/Integration/Tracker/ActionTest.php b/tests/PHPUnit/Integration/Tracker/ActionTest.php
index 2b7ea04ac0..1246fb15f6 100644
--- a/tests/PHPUnit/Integration/Tracker/ActionTest.php
+++ b/tests/PHPUnit/Integration/Tracker/ActionTest.php
@@ -13,6 +13,8 @@ use Piwik\Tracker\PageUrl;
use Piwik\Tracker\Request;
use Piwik\Translate;
use Piwik\Plugin\Manager as PluginManager;
+use Piwik\Tests\Impl\IntegrationTestCase;
+
/**
* Piwik - free/libre analytics platform
*
diff --git a/tests/PHPUnit/Integration/Tracker/DbTest.php b/tests/PHPUnit/Integration/Tracker/DbTest.php
index 71fd3a97fd..91d01d0cfe 100644
--- a/tests/PHPUnit/Integration/Tracker/DbTest.php
+++ b/tests/PHPUnit/Integration/Tracker/DbTest.php
@@ -7,6 +7,7 @@
*/
use Piwik\Common;
use Piwik\Db;
+use Piwik\Tests\Impl\IntegrationTestCase;
/**
* Tracker DB test
diff --git a/tests/PHPUnit/Integration/Tracker/Visit2Test.php b/tests/PHPUnit/Integration/Tracker/Visit2Test.php
index 9910d7f51d..e28c3ba410 100644
--- a/tests/PHPUnit/Integration/Tracker/Visit2Test.php
+++ b/tests/PHPUnit/Integration/Tracker/Visit2Test.php
@@ -14,7 +14,8 @@ use Piwik\Tracker\Request;
use Piwik\Tracker\Visitor;
use Piwik\Piwik;
use Piwik\EventDispatcher;
-use Piwik\Tests\Fixture;
+use Piwik\Tests\Impl\Fixture;
+use Piwik\Tests\Impl\IntegrationTestCase;
class FakeTrackerVisitDimension1 extends VisitDimension
{
diff --git a/tests/PHPUnit/Integration/Tracker/VisitTest.php b/tests/PHPUnit/Integration/Tracker/VisitTest.php
index 69c1569251..cdc69110d4 100644
--- a/tests/PHPUnit/Integration/Tracker/VisitTest.php
+++ b/tests/PHPUnit/Integration/Tracker/VisitTest.php
@@ -10,6 +10,7 @@ use Piwik\IP;
use Piwik\Plugins\SitesManager\API;
use Piwik\Tracker\Request;
use Piwik\Tracker\VisitExcluded;
+use Piwik\Tests\Impl\IntegrationTestCase;
/**
* Class Core_Tracker_VisitTest
diff --git a/tests/PHPUnit/Integration/TrackerTest.php b/tests/PHPUnit/Integration/TrackerTest.php
index c8176a1a89..53865b0993 100644
--- a/tests/PHPUnit/Integration/TrackerTest.php
+++ b/tests/PHPUnit/Integration/TrackerTest.php
@@ -6,7 +6,8 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
-use Piwik\Tests\Fixture;
+use Piwik\Tests\Impl\Fixture;
+use Piwik\Tests\Impl\IntegrationTestCase;
/**
* @group Core
diff --git a/tests/PHPUnit/Integration/TravisEnvironmentTest.php b/tests/PHPUnit/Integration/TravisEnvironmentTest.php
index a8b6dfc27a..c8fce30ba2 100644
--- a/tests/PHPUnit/Integration/TravisEnvironmentTest.php
+++ b/tests/PHPUnit/Integration/TravisEnvironmentTest.php
@@ -1,6 +1,7 @@
<?php
use Piwik\Translate;
+use Piwik\Tests\Impl\IntegrationTestCase;
/**
* Class TravisEnvironmentTest
diff --git a/tests/PHPUnit/Integration/UpdaterTest.php b/tests/PHPUnit/Integration/UpdaterTest.php
index a3070a6950..a0b7662b63 100644
--- a/tests/PHPUnit/Integration/UpdaterTest.php
+++ b/tests/PHPUnit/Integration/UpdaterTest.php
@@ -7,9 +7,9 @@
*/
namespace Piwik\Tests\Integration\Core;
-use IntegrationTestCase;
+use Piwik\Tests\Impl\IntegrationTestCase;
use Piwik\Updater;
-use Piwik\Tests\Fixture;
+use Piwik\Tests\Impl\Fixture;
/**
* Class Core_UpdaterTest
diff --git a/tests/PHPUnit/Integration/ViewDataTable/ManagerTest.php b/tests/PHPUnit/Integration/ViewDataTable/ManagerTest.php
index 394bfe4039..6f73818801 100644
--- a/tests/PHPUnit/Integration/ViewDataTable/ManagerTest.php
+++ b/tests/PHPUnit/Integration/ViewDataTable/ManagerTest.php
@@ -8,6 +8,7 @@
use Piwik\Access;
use Piwik\ViewDataTable\Manager as ViewDataTableManager;
+use Piwik\Tests\Impl\IntegrationTestCase;
/**
* Class Core_Plugin_SettingsTest
diff --git a/tests/PHPUnit/Integration/WidgetsListTest.php b/tests/PHPUnit/Integration/WidgetsListTest.php
index a616bdd5bf..865dd5a72a 100644
--- a/tests/PHPUnit/Integration/WidgetsListTest.php
+++ b/tests/PHPUnit/Integration/WidgetsListTest.php
@@ -9,7 +9,8 @@
use Piwik\Access;
use Piwik\Plugins\Goals\API;
use Piwik\WidgetsList;
-use Piwik\Tests\Fixture;
+use Piwik\Tests\Impl\Fixture;
+use Piwik\Tests\Impl\IntegrationTestCase;
/**
* Class Core_WidgetsListTest
diff --git a/tests/PHPUnit/IntegrationTestCase.php b/tests/PHPUnit/IntegrationTestCase.php
index 6d63779e9c..8cd33978dc 100644
--- a/tests/PHPUnit/IntegrationTestCase.php
+++ b/tests/PHPUnit/IntegrationTestCase.php
@@ -5,92 +5,19 @@
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
-use Piwik\Config;
-use Piwik\Db;
-use Piwik\Tests\Fixture;
-use Piwik\Tests\SystemTestCase;
/**
- * Tests extending IntegrationTestCase are much slower to run: the setUp will
- * create all Piwik tables in a freshly empty test database.
- *
- * This allows each test method to start from a clean DB and setup initial state to
- * then test it.
- *
+ * @deprecated since 2.8.0 extend \Piwik\Tests\Impl\SystemTestCase instead
*/
-class IntegrationTestCase extends SystemTestCase
+class IntegrationTestCase extends \Piwik\Tests\Impl\SystemTestCase
{
- /**
- * @var Fixture
- */
- public static $fixture;
- public static $tableData;
- /**
- * Implementation details:
- *
- * To increase speed of tests, database setup is done once in setUpBeforeClass.
- * Afterwards, the content of the tables is stored in a static class variable,
- * self::$tableData. Before each individual test, the database tables are
- * truncated and the data in self::$tableData is restored.
- *
- * If your test modifies table columns, you will need to recreate the database
- * completely. This can be accomplished by:
- *
- * public function setUp()
- * {
- * self::$fixture->performSetUp();
- * }
- *
- * public function tearDown()
- * {
- * parent::tearDown();
- * self::$fixture->performTearDown();
- * }
- */
public static function setUpBeforeClass()
{
- static::configureFixture(static::$fixture);
- parent::setUpBeforeClass();
-
- self::$tableData = self::getDbTablesWithData();
- }
-
- public static function tearDownAfterClass()
- {
- self::$tableData = array();
- }
-
- /**
- * Setup the database and create the base tables for all tests
- */
- public function setUp()
- {
- parent::setUp();
+ \Piwik\Log::debug('\IntegrationTestCase is deprecated since 2.8.0 extend \Piwik\Tests\Impl\SystemTestCase instead');
- Config::getInstance()->setTestEnvironment();
-
- if (!empty(self::$tableData)) {
- self::restoreDbTables(self::$tableData);
- }
- }
-
- /**
- * Resets all caches and drops the database
- */
- public function tearDown()
- {
- self::$fixture->clearInMemoryCaches();
-
- parent::tearDown();
- }
-
- protected static function configureFixture($fixture)
- {
- $fixture->loadTranslations = false;
- $fixture->createSuperUser = false;
- $fixture->configureComponents = false;
+ parent::setUpBeforeClass();
}
}
-IntegrationTestCase::$fixture = new Fixture(); \ No newline at end of file
+IntegrationTestCase::$fixture = new \Piwik\Tests\Impl\Fixture(); \ No newline at end of file
diff --git a/tests/PHPUnit/System/AnnotationsTest.php b/tests/PHPUnit/System/AnnotationsTest.php
index 9acf8c7e27..f73587f3ce 100755
--- a/tests/PHPUnit/System/AnnotationsTest.php
+++ b/tests/PHPUnit/System/AnnotationsTest.php
@@ -10,8 +10,8 @@ namespace Piwik\Tests\System;
use Piwik\Access;
use Piwik\API\Request;
use Piwik\Plugins\Annotations\API;
-use Piwik\Tests\SystemTestCase;
-use Piwik\Tests\Fixtures\TwoSitesWithAnnotations;
+use Piwik\Tests\Impl\SystemTestCase;
+use Piwik\Tests\Impl\Fixtures\TwoSitesWithAnnotations;
use FakeAccess;
use Exception;
diff --git a/tests/PHPUnit/System/ApiGetReportMetadataTest.php b/tests/PHPUnit/System/ApiGetReportMetadataTest.php
index be86b7f3ab..fd9b2b308c 100755
--- a/tests/PHPUnit/System/ApiGetReportMetadataTest.php
+++ b/tests/PHPUnit/System/ApiGetReportMetadataTest.php
@@ -8,8 +8,8 @@
namespace Piwik\Tests\System;
use Piwik\API\Proxy;
-use Piwik\Tests\SystemTestCase;
-use Piwik\Tests\Fixtures\ThreeGoalsOnePageview;
+use Piwik\Tests\Impl\SystemTestCase;
+use Piwik\Tests\Impl\Fixtures\ThreeGoalsOnePageview;
/**
* This tests the output of the API plugin API
diff --git a/tests/PHPUnit/System/ApiGetReportMetadataYearTest.php b/tests/PHPUnit/System/ApiGetReportMetadataYearTest.php
index d3df009834..988419f717 100755
--- a/tests/PHPUnit/System/ApiGetReportMetadataYearTest.php
+++ b/tests/PHPUnit/System/ApiGetReportMetadataYearTest.php
@@ -7,8 +7,8 @@
*/
namespace Piwik\Tests\System;
-use Piwik\Tests\SystemTestCase;
-use Piwik\Tests\Fixtures\InvalidVisits;
+use Piwik\Tests\Impl\SystemTestCase;
+use Piwik\Tests\Impl\Fixtures\InvalidVisits;
/**
* test the Yearly metadata API response,
diff --git a/tests/PHPUnit/System/ArchiveCronTest.php b/tests/PHPUnit/System/ArchiveCronTest.php
index 75b7fcb2af..768ded9892 100644
--- a/tests/PHPUnit/System/ArchiveCronTest.php
+++ b/tests/PHPUnit/System/ArchiveCronTest.php
@@ -9,9 +9,9 @@ namespace Piwik\Tests\System;
use Piwik\Date;
use Piwik\Plugins\SitesManager\API;
-use Piwik\Tests\SystemTestCase;
-use Piwik\Tests\Fixtures\ManySitesImportedLogs;
-use Piwik\Tests\Fixture;
+use Piwik\Tests\Impl\SystemTestCase;
+use Piwik\Tests\Impl\Fixtures\ManySitesImportedLogs;
+use Piwik\Tests\Impl\Fixture;
use Exception;
/**
diff --git a/tests/PHPUnit/System/ArchiveInvalidationTest.php b/tests/PHPUnit/System/ArchiveInvalidationTest.php
index 6d8d22a2c3..3715014525 100644
--- a/tests/PHPUnit/System/ArchiveInvalidationTest.php
+++ b/tests/PHPUnit/System/ArchiveInvalidationTest.php
@@ -9,8 +9,8 @@ namespace Piwik\Tests\System;
use Piwik\API\Request;
use Piwik\Config;
-use Piwik\Tests\Fixtures\VisitsTwoWebsitesWithAdditionalVisits;
-use Piwik\Tests\SystemTestCase;
+use Piwik\Tests\Impl\Fixtures\VisitsTwoWebsitesWithAdditionalVisits;
+use Piwik\Tests\Impl\SystemTestCase;
/**
* Track visits before website creation date and test that Piwik handles them correctly.
diff --git a/tests/PHPUnit/System/ArchiveWebTest.php b/tests/PHPUnit/System/ArchiveWebTest.php
index 53f262df1a..8d47fb7204 100644
--- a/tests/PHPUnit/System/ArchiveWebTest.php
+++ b/tests/PHPUnit/System/ArchiveWebTest.php
@@ -9,9 +9,9 @@ namespace Piwik\Tests\System;
use Piwik\Option;
use Piwik\Http;
-use Piwik\Tests\SystemTestCase;
-use Piwik\Tests\Fixtures\ManySitesImportedLogs;
-use Piwik\Tests\Fixture;
+use Piwik\Tests\Impl\SystemTestCase;
+use Piwik\Tests\Impl\Fixtures\ManySitesImportedLogs;
+use Piwik\Tests\Impl\Fixture;
use Exception;
/**
diff --git a/tests/PHPUnit/System/AutoSuggestAPITest.php b/tests/PHPUnit/System/AutoSuggestAPITest.php
index 535e1d4250..d35a273da8 100644
--- a/tests/PHPUnit/System/AutoSuggestAPITest.php
+++ b/tests/PHPUnit/System/AutoSuggestAPITest.php
@@ -9,9 +9,9 @@ namespace Piwik\Tests\System;
use Piwik\API\Request;
use Piwik\Date;
-use Piwik\Tests\SystemTestCase;
-use Piwik\Tests\Fixtures\ManyVisitsWithGeoIP;
-use Piwik\Tests\Fixture;
+use Piwik\Tests\Impl\SystemTestCase;
+use Piwik\Tests\Impl\Fixtures\ManyVisitsWithGeoIP;
+use Piwik\Tests\Impl\Fixture;
/**
* testing a the auto suggest API for all known segments
diff --git a/tests/PHPUnit/System/BackwardsCompatibility1XTest.php b/tests/PHPUnit/System/BackwardsCompatibility1XTest.php
index 5d20fa81a9..2b2a616ada 100644
--- a/tests/PHPUnit/System/BackwardsCompatibility1XTest.php
+++ b/tests/PHPUnit/System/BackwardsCompatibility1XTest.php
@@ -10,9 +10,9 @@ namespace Piwik\Tests\System;
use Piwik\Common;
use Piwik\Db;
use Piwik\Plugins\VisitFrequency\API as VisitFrequencyApi;
-use Piwik\Tests\SystemTestCase;
-use Piwik\Tests\Fixtures\SqlDump;
-use Piwik\Tests\Fixture;
+use Piwik\Tests\Impl\SystemTestCase;
+use Piwik\Tests\Impl\Fixtures\SqlDump;
+use Piwik\Tests\Impl\Fixture;
/**
* Tests that Piwik 2.0 works w/ data from Piwik 1.12.
diff --git a/tests/PHPUnit/System/BlobReportLimitingTest.php b/tests/PHPUnit/System/BlobReportLimitingTest.php
index 431709d3cf..56a3a0126d 100755
--- a/tests/PHPUnit/System/BlobReportLimitingTest.php
+++ b/tests/PHPUnit/System/BlobReportLimitingTest.php
@@ -9,8 +9,8 @@ namespace Piwik\Tests\System;
use Piwik\Config;
use Piwik\Plugins\Actions\ArchivingHelper;
-use Piwik\Tests\SystemTestCase;
-use Piwik\Tests\Fixtures\ManyVisitsWithMockLocationProvider;
+use Piwik\Tests\Impl\SystemTestCase;
+use Piwik\Tests\Impl\Fixtures\ManyVisitsWithMockLocationProvider;
require_once PIWIK_INCLUDE_PATH . '/tests/PHPUnit/MockLocationProvider.php';
diff --git a/tests/PHPUnit/System/CsvExportTest.php b/tests/PHPUnit/System/CsvExportTest.php
index 48c9342f8e..4533afc943 100755
--- a/tests/PHPUnit/System/CsvExportTest.php
+++ b/tests/PHPUnit/System/CsvExportTest.php
@@ -7,8 +7,8 @@
*/
namespace Piwik\Tests\System;
-use Piwik\Tests\SystemTestCase;
-use Piwik\Tests\Fixtures\TwoVisitsWithCustomVariables;
+use Piwik\Tests\Impl\SystemTestCase;
+use Piwik\Tests\Impl\Fixtures\TwoVisitsWithCustomVariables;
/**
* Test CSV export with Expanded rows, Translated labels, Different languages
diff --git a/tests/PHPUnit/System/CustomEventsTest.php b/tests/PHPUnit/System/CustomEventsTest.php
index b2e92b30a9..6df0f5a642 100644
--- a/tests/PHPUnit/System/CustomEventsTest.php
+++ b/tests/PHPUnit/System/CustomEventsTest.php
@@ -7,8 +7,8 @@
*/
namespace Piwik\Tests\System;
-use Piwik\Tests\SystemTestCase;
-use Piwik\Tests\Fixtures\TwoVisitsWithCustomEvents;
+use Piwik\Tests\Impl\SystemTestCase;
+use Piwik\Tests\Impl\Fixtures\TwoVisitsWithCustomEvents;
/**
* Testing Custom Events
diff --git a/tests/PHPUnit/System/EcommerceOrderWithItemsTest.php b/tests/PHPUnit/System/EcommerceOrderWithItemsTest.php
index e2ab0ffd44..1dbf092166 100755
--- a/tests/PHPUnit/System/EcommerceOrderWithItemsTest.php
+++ b/tests/PHPUnit/System/EcommerceOrderWithItemsTest.php
@@ -9,8 +9,8 @@ namespace Piwik\Tests\System;
use Piwik\Date;
use Piwik\Piwik;
-use Piwik\Tests\SystemTestCase;
-use Piwik\Tests\Fixtures\TwoSitesEcommerceOrderWithItems;
+use Piwik\Tests\Impl\SystemTestCase;
+use Piwik\Tests\Impl\Fixtures\TwoSitesEcommerceOrderWithItems;
/**
* Tests API methods after ecommerce orders are tracked.
diff --git a/tests/PHPUnit/System/FlattenReportsTest.php b/tests/PHPUnit/System/FlattenReportsTest.php
index e38e10cf7f..46787d1da9 100644
--- a/tests/PHPUnit/System/FlattenReportsTest.php
+++ b/tests/PHPUnit/System/FlattenReportsTest.php
@@ -7,8 +7,8 @@
*/
namespace Piwik\Tests\System;
-use Piwik\Tests\SystemTestCase;
-use Piwik\Tests\Fixtures\ManyVisitsWithSubDirReferrersAndCustomVars;
+use Piwik\Tests\Impl\SystemTestCase;
+use Piwik\Tests\Impl\Fixtures\ManyVisitsWithSubDirReferrersAndCustomVars;
/**
* Tests the flattening of reports.
diff --git a/tests/PHPUnit/System/ImportLogsTest.php b/tests/PHPUnit/System/ImportLogsTest.php
index abf7d6a42a..9d52c6a112 100755
--- a/tests/PHPUnit/System/ImportLogsTest.php
+++ b/tests/PHPUnit/System/ImportLogsTest.php
@@ -9,8 +9,8 @@ namespace Piwik\Tests\System;
use Piwik\Access;
use Piwik\Plugins\SitesManager\API;
-use Piwik\Tests\SystemTestCase;
-use Piwik\Tests\Fixtures\ManySitesImportedLogs;
+use Piwik\Tests\Impl\SystemTestCase;
+use Piwik\Tests\Impl\Fixtures\ManySitesImportedLogs;
/**
* Tests the log importer.
diff --git a/tests/PHPUnit/System/LabelFilterTest.php b/tests/PHPUnit/System/LabelFilterTest.php
index 487e09c07f..5493a05e29 100644
--- a/tests/PHPUnit/System/LabelFilterTest.php
+++ b/tests/PHPUnit/System/LabelFilterTest.php
@@ -7,8 +7,8 @@
*/
namespace Piwik\Tests\System;
-use Piwik\Tests\SystemTestCase;
-use Piwik\Tests\Fixtures\OneVisitSeveralPageViews;
+use Piwik\Tests\Impl\SystemTestCase;
+use Piwik\Tests\Impl\Fixtures\OneVisitSeveralPageViews;
/**
* Tests the class LabelFilter.
diff --git a/tests/PHPUnit/System/ManyVisitorsOneWebsiteTest.php b/tests/PHPUnit/System/ManyVisitorsOneWebsiteTest.php
index ec1a0f4f16..2cf094b92f 100755
--- a/tests/PHPUnit/System/ManyVisitorsOneWebsiteTest.php
+++ b/tests/PHPUnit/System/ManyVisitorsOneWebsiteTest.php
@@ -10,8 +10,8 @@ namespace Piwik\Tests\System;
require_once PIWIK_INCLUDE_PATH . '/tests/PHPUnit/MockLocationProvider.php';
use Piwik\Date;
-use Piwik\Tests\SystemTestCase;
-use Piwik\Tests\Fixtures\ManyVisitsWithGeoIP;
+use Piwik\Tests\Impl\SystemTestCase;
+use Piwik\Tests\Impl\Fixtures\ManyVisitsWithGeoIP;
/**
* Tests w/ 14 visitors w/ 2 visits each.
diff --git a/tests/PHPUnit/System/MultipleSitesArchivingTest.php b/tests/PHPUnit/System/MultipleSitesArchivingTest.php
index 6d447abb2f..436ceaa50e 100644
--- a/tests/PHPUnit/System/MultipleSitesArchivingTest.php
+++ b/tests/PHPUnit/System/MultipleSitesArchivingTest.php
@@ -9,9 +9,9 @@ namespace Piwik\Tests\System;
use Piwik\Config;
use Piwik\Piwik;
-use Piwik\Tests\Fixture;
-use Piwik\Tests\Fixtures\ThreeSitesWithSharedVisitors;
-use Piwik\Tests\SystemTestCase;
+use Piwik\Tests\Impl\Fixture;
+use Piwik\Tests\Impl\Fixtures\ThreeSitesWithSharedVisitors;
+use Piwik\Tests\Impl\SystemTestCase;
/**
* @group Core
diff --git a/tests/PHPUnit/System/NoVisitTest.php b/tests/PHPUnit/System/NoVisitTest.php
index 4a81736073..45f2b6ed06 100755
--- a/tests/PHPUnit/System/NoVisitTest.php
+++ b/tests/PHPUnit/System/NoVisitTest.php
@@ -7,8 +7,8 @@
*/
namespace Piwik\Tests\System;
-use Piwik\Tests\SystemTestCase;
-use Piwik\Tests\Fixtures\InvalidVisits;
+use Piwik\Tests\Impl\SystemTestCase;
+use Piwik\Tests\Impl\Fixtures\InvalidVisits;
/**
* testing various wrong Tracker requests and check that they behave as expected:
diff --git a/tests/PHPUnit/System/NonUnicodeTest.php b/tests/PHPUnit/System/NonUnicodeTest.php
index 370c4acf16..943940ac43 100755
--- a/tests/PHPUnit/System/NonUnicodeTest.php
+++ b/tests/PHPUnit/System/NonUnicodeTest.php
@@ -7,8 +7,8 @@
*/
namespace Piwik\Tests\System;
-use Piwik\Tests\SystemTestCase;
-use Piwik\Tests\Fixtures\SomeVisitsWithNonUnicodePageTitles;
+use Piwik\Tests\Impl\SystemTestCase;
+use Piwik\Tests\Impl\Fixtures\SomeVisitsWithNonUnicodePageTitles;
/**
* Tests that visits track & reports display correctly when non-unicode text is
diff --git a/tests/PHPUnit/System/OneVisitorLongUrlsTruncatedTest.php b/tests/PHPUnit/System/OneVisitorLongUrlsTruncatedTest.php
index 83a17e0f11..4d72a31c8a 100644
--- a/tests/PHPUnit/System/OneVisitorLongUrlsTruncatedTest.php
+++ b/tests/PHPUnit/System/OneVisitorLongUrlsTruncatedTest.php
@@ -7,8 +7,8 @@
*/
namespace Piwik\Tests\System;
-use Piwik\Tests\SystemTestCase;
-use Piwik\Tests\Fixtures\SomeVisitsWithLongUrls;
+use Piwik\Tests\Impl\SystemTestCase;
+use Piwik\Tests\Impl\Fixtures\SomeVisitsWithLongUrls;
/**
* Tests that filter_truncate works recursively in Page URLs report AND in the case there are 2 different data Keywords -> search engine
diff --git a/tests/PHPUnit/System/OneVisitorNoKeywordSpecifiedTest.php b/tests/PHPUnit/System/OneVisitorNoKeywordSpecifiedTest.php
index 4bd244f663..eb5bec6de3 100755
--- a/tests/PHPUnit/System/OneVisitorNoKeywordSpecifiedTest.php
+++ b/tests/PHPUnit/System/OneVisitorNoKeywordSpecifiedTest.php
@@ -7,8 +7,8 @@
*/
namespace Piwik\Tests\System;
-use Piwik\Tests\SystemTestCase;
-use Piwik\Tests\Fixtures\TwoVisitsNoKeywordWithBot;
+use Piwik\Tests\Impl\SystemTestCase;
+use Piwik\Tests\Impl\Fixtures\TwoVisitsNoKeywordWithBot;
/**
* 1) Tests empty google kwd works nicely in Live! output and Top keywords
diff --git a/tests/PHPUnit/System/OneVisitorOneWebsiteSeveralDaysDateRangeArchivingTestsTest.php b/tests/PHPUnit/System/OneVisitorOneWebsiteSeveralDaysDateRangeArchivingTestsTest.php
index 9441f39318..7cd7b9f632 100755
--- a/tests/PHPUnit/System/OneVisitorOneWebsiteSeveralDaysDateRangeArchivingTestsTest.php
+++ b/tests/PHPUnit/System/OneVisitorOneWebsiteSeveralDaysDateRangeArchivingTestsTest.php
@@ -10,8 +10,8 @@ namespace Piwik\Tests\System;
use Piwik\Common;
use Piwik\Db;
use Piwik\Piwik;
-use Piwik\Tests\SystemTestCase;
-use Piwik\Tests\Fixtures\VisitsOverSeveralDays;
+use Piwik\Tests\Impl\SystemTestCase;
+use Piwik\Tests\Impl\Fixtures\VisitsOverSeveralDays;
/**
* Tests some API using range periods & makes sure the correct amount of blob/numeric
diff --git a/tests/PHPUnit/System/OneVisitorOneWebsiteSeveralDaysDateRangeTest.php b/tests/PHPUnit/System/OneVisitorOneWebsiteSeveralDaysDateRangeTest.php
index e744859b70..f7ea478466 100755
--- a/tests/PHPUnit/System/OneVisitorOneWebsiteSeveralDaysDateRangeTest.php
+++ b/tests/PHPUnit/System/OneVisitorOneWebsiteSeveralDaysDateRangeTest.php
@@ -7,8 +7,8 @@
*/
namespace Piwik\Tests\System;
-use Piwik\Tests\SystemTestCase;
-use Piwik\Tests\Fixtures\VisitsOverSeveralDays;
+use Piwik\Tests\Impl\SystemTestCase;
+use Piwik\Tests\Impl\Fixtures\VisitsOverSeveralDays;
/**
* Use case testing various important features:
diff --git a/tests/PHPUnit/System/OneVisitorSeveralDaysImportedInRandomOrderTest.php b/tests/PHPUnit/System/OneVisitorSeveralDaysImportedInRandomOrderTest.php
index 9ad8791c4c..0d13a6a246 100644
--- a/tests/PHPUnit/System/OneVisitorSeveralDaysImportedInRandomOrderTest.php
+++ b/tests/PHPUnit/System/OneVisitorSeveralDaysImportedInRandomOrderTest.php
@@ -7,8 +7,8 @@
*/
namespace Piwik\Tests\System;
-use Piwik\Tests\SystemTestCase;
-use Piwik\Tests\Fixtures\VisitOverSeveralDaysImportedLogs;
+use Piwik\Tests\Impl\SystemTestCase;
+use Piwik\Tests\Impl\Fixtures\VisitOverSeveralDaysImportedLogs;
/**
* @group Core
diff --git a/tests/PHPUnit/System/OneVisitorTwoVisitsTest.php b/tests/PHPUnit/System/OneVisitorTwoVisitsTest.php
index 6c1b3d69ca..94a7a3e307 100755
--- a/tests/PHPUnit/System/OneVisitorTwoVisitsTest.php
+++ b/tests/PHPUnit/System/OneVisitorTwoVisitsTest.php
@@ -9,8 +9,8 @@ namespace Piwik\Tests\System;
use Piwik\API\Proxy;
use Piwik\Archive;
-use Piwik\Tests\SystemTestCase;
-use Piwik\Tests\Fixtures\OneVisitorTwoVisits;
+use Piwik\Tests\Impl\SystemTestCase;
+use Piwik\Tests\Impl\Fixtures\OneVisitorTwoVisits;
use Exception;
/**
diff --git a/tests/PHPUnit/System/OneVisitorTwoVisitsWithCookieSupportTest.php b/tests/PHPUnit/System/OneVisitorTwoVisitsWithCookieSupportTest.php
index 856e10efad..206ee08276 100755
--- a/tests/PHPUnit/System/OneVisitorTwoVisitsWithCookieSupportTest.php
+++ b/tests/PHPUnit/System/OneVisitorTwoVisitsWithCookieSupportTest.php
@@ -7,8 +7,8 @@
*/
namespace Piwik\Tests\System;
-use Piwik\Tests\SystemTestCase;
-use Piwik\Tests\Fixtures\OneVisitorTwoVisits;
+use Piwik\Tests\Impl\SystemTestCase;
+use Piwik\Tests\Impl\Fixtures\OneVisitorTwoVisits;
/**
* Same as OneVisitorTwoVisits.test.php, but with cookie support, which incurs some slight changes
diff --git a/tests/PHPUnit/System/PeriodIsRangeDateIsLastNMetadataAndNormalAPITest.php b/tests/PHPUnit/System/PeriodIsRangeDateIsLastNMetadataAndNormalAPITest.php
index 52739d310b..92da5acaa6 100755
--- a/tests/PHPUnit/System/PeriodIsRangeDateIsLastNMetadataAndNormalAPITest.php
+++ b/tests/PHPUnit/System/PeriodIsRangeDateIsLastNMetadataAndNormalAPITest.php
@@ -8,8 +8,8 @@
namespace Piwik\Tests\System;
use Piwik\Date;
-use Piwik\Tests\SystemTestCase;
-use Piwik\Tests\Fixtures\TwoVisitsWithCustomVariables;
+use Piwik\Tests\Impl\SystemTestCase;
+use Piwik\Tests\Impl\Fixtures\TwoVisitsWithCustomVariables;
/**
* test Metadata API + period=range&date=lastN
diff --git a/tests/PHPUnit/System/PivotByQueryParamTest.php b/tests/PHPUnit/System/PivotByQueryParamTest.php
index 358b9b03c0..88829fec0a 100644
--- a/tests/PHPUnit/System/PivotByQueryParamTest.php
+++ b/tests/PHPUnit/System/PivotByQueryParamTest.php
@@ -9,8 +9,8 @@ namespace Piwik\Tests\System;
use Piwik\Config;
use Piwik\Date;
-use Piwik\Tests\Fixtures\ManyVisitsWithMockLocationProvider;
-use Piwik\Tests\SystemTestCase;
+use Piwik\Tests\Impl\Fixtures\ManyVisitsWithMockLocationProvider;
+use Piwik\Tests\Impl\SystemTestCase;
/**
* @group Core
diff --git a/tests/PHPUnit/System/PrivacyManagerTest.php b/tests/PHPUnit/System/PrivacyManagerTest.php
index 7ba93e7cd2..79fcd1bccd 100644
--- a/tests/PHPUnit/System/PrivacyManagerTest.php
+++ b/tests/PHPUnit/System/PrivacyManagerTest.php
@@ -25,10 +25,10 @@ use Piwik\Plugins\VisitorInterest\API as APIVisitorInterest;
use Piwik\Site;
use Piwik\Tracker\Cache;
use Piwik\Tracker\GoalManager;
-use Piwik\Tests\SystemTestCase;
-use Piwik\Tests\Fixture;
+use Piwik\Tests\Impl\SystemTestCase;
+use Piwik\Tests\Impl\Fixture;
-require_once 'PrivacyManager/PrivacyManager.php';
+require_once PIWIK_INCLUDE_PATH . '/plugins/PrivacyManager/PrivacyManager.php';
/**
* @group PrivacyManagerTest
diff --git a/tests/PHPUnit/System/PurgeDataTest.php b/tests/PHPUnit/System/PurgeDataTest.php
index 30bf2244ff..c8715cd93e 100755
--- a/tests/PHPUnit/System/PurgeDataTest.php
+++ b/tests/PHPUnit/System/PurgeDataTest.php
@@ -12,8 +12,8 @@ require_once PIWIK_INCLUDE_PATH . '/tests/PHPUnit/MockLocationProvider.php';
use Piwik\API\Request;
use Piwik\Plugins\PrivacyManager\PrivacyManager;
use Piwik\Plugins\PrivacyManager\ReportsPurger;
-use Piwik\Tests\SystemTestCase;
-use Piwik\Tests\Fixtures\OneVisitorTwoVisits;
+use Piwik\Tests\Impl\SystemTestCase;
+use Piwik\Tests\Impl\Fixtures\OneVisitorTwoVisits;
/**
* TODO: shouldn't this be merged w/ PrivacyManagerTest? the original data purging tests are there
diff --git a/tests/PHPUnit/System/RowEvolutionTest.php b/tests/PHPUnit/System/RowEvolutionTest.php
index 9eb55e282b..3fa1d9596b 100755
--- a/tests/PHPUnit/System/RowEvolutionTest.php
+++ b/tests/PHPUnit/System/RowEvolutionTest.php
@@ -7,8 +7,8 @@
*/
namespace Piwik\Tests\System;
-use Piwik\Tests\SystemTestCase;
-use Piwik\Tests\Fixtures\TwoSitesManyVisitsOverSeveralDaysWithSearchEngineReferrers;
+use Piwik\Tests\Impl\SystemTestCase;
+use Piwik\Tests\Impl\Fixtures\TwoSitesManyVisitsOverSeveralDaysWithSearchEngineReferrers;
/**
* Tests the method API.getRowEvolution
diff --git a/tests/PHPUnit/System/SiteSearchTest.php b/tests/PHPUnit/System/SiteSearchTest.php
index bb5b5c3bb0..4d6867ed53 100755
--- a/tests/PHPUnit/System/SiteSearchTest.php
+++ b/tests/PHPUnit/System/SiteSearchTest.php
@@ -7,8 +7,8 @@
*/
namespace Piwik\Tests\System;
-use Piwik\Tests\SystemTestCase;
-use Piwik\Tests\Fixtures\ThreeSitesWithManyVisitsWithSiteSearch;
+use Piwik\Tests\Impl\SystemTestCase;
+use Piwik\Tests\Impl\Fixtures\ThreeSitesWithManyVisitsWithSiteSearch;
/**
* Testing the various use cases w/ internal Site Search tracking
diff --git a/tests/PHPUnit/System/TimezonesTest.php b/tests/PHPUnit/System/TimezonesTest.php
index d9b11c9ae2..a071ded41b 100644
--- a/tests/PHPUnit/System/TimezonesTest.php
+++ b/tests/PHPUnit/System/TimezonesTest.php
@@ -8,8 +8,8 @@
namespace Piwik\Tests\System;
use Piwik\Date;
-use Piwik\Tests\SystemTestCase;
-use Piwik\Tests\Fixtures\VisitsInDifferentTimezones;
+use Piwik\Tests\Impl\SystemTestCase;
+use Piwik\Tests\Impl\Fixtures\VisitsInDifferentTimezones;
/**
* Test reports using visits for a site with a non-UTC timezone.
diff --git a/tests/PHPUnit/System/TrackCustomVariablesAndCampaignsForceUsingVisitIdNotHeuristicsTest.php b/tests/PHPUnit/System/TrackCustomVariablesAndCampaignsForceUsingVisitIdNotHeuristicsTest.php
index efb4cf4554..30b205d9eb 100755
--- a/tests/PHPUnit/System/TrackCustomVariablesAndCampaignsForceUsingVisitIdNotHeuristicsTest.php
+++ b/tests/PHPUnit/System/TrackCustomVariablesAndCampaignsForceUsingVisitIdNotHeuristicsTest.php
@@ -7,8 +7,8 @@
*/
namespace Piwik\Tests\System;
-use Piwik\Tests\SystemTestCase;
-use Piwik\Tests\Fixtures\SomeVisitsCustomVariablesCampaignsNotHeuristics;
+use Piwik\Tests\Impl\SystemTestCase;
+use Piwik\Tests\Impl\Fixtures\SomeVisitsCustomVariablesCampaignsNotHeuristics;
/**
* Test tracker & API when forcing the use of visit ID instead of heuristics. Also
diff --git a/tests/PHPUnit/System/TrackGoalsAllowMultipleConversionsPerVisitTest.php b/tests/PHPUnit/System/TrackGoalsAllowMultipleConversionsPerVisitTest.php
index af2469670b..151db2bfa2 100755
--- a/tests/PHPUnit/System/TrackGoalsAllowMultipleConversionsPerVisitTest.php
+++ b/tests/PHPUnit/System/TrackGoalsAllowMultipleConversionsPerVisitTest.php
@@ -8,8 +8,8 @@
namespace Piwik\Tests\System;
use Piwik\Plugins\Goals\API;
-use Piwik\Tests\SystemTestCase;
-use Piwik\Tests\Fixtures\SomeVisitsAllConversions;
+use Piwik\Tests\Impl\SystemTestCase;
+use Piwik\Tests\Impl\Fixtures\SomeVisitsAllConversions;
/**
* Tests API methods with goals that do and don't allow multiple
diff --git a/tests/PHPUnit/System/TrackerWindowLookBackTest.php b/tests/PHPUnit/System/TrackerWindowLookBackTest.php
index 433e6baf43..7e84f1c30a 100644
--- a/tests/PHPUnit/System/TrackerWindowLookBackTest.php
+++ b/tests/PHPUnit/System/TrackerWindowLookBackTest.php
@@ -7,8 +7,8 @@
*/
namespace Piwik\Tests\System;
-use Piwik\Tests\SystemTestCase;
-use Piwik\Tests\Fixtures\VisitsOverSeveralDays;
+use Piwik\Tests\Impl\SystemTestCase;
+use Piwik\Tests\Impl\Fixtures\VisitsOverSeveralDays;
/**
* Testing that, when using window_look_back_for_visitor with a high value,
diff --git a/tests/PHPUnit/System/TransitionsTest.php b/tests/PHPUnit/System/TransitionsTest.php
index e3ca1c4863..d3c456f478 100644
--- a/tests/PHPUnit/System/TransitionsTest.php
+++ b/tests/PHPUnit/System/TransitionsTest.php
@@ -7,8 +7,8 @@
*/
namespace Piwik\Tests\System;
-use Piwik\Tests\SystemTestCase;
-use Piwik\Tests\Fixtures\SomeVisitsManyPageviewsWithTransitions;
+use Piwik\Tests\Impl\SystemTestCase;
+use Piwik\Tests\Impl\Fixtures\SomeVisitsManyPageviewsWithTransitions;
/**
* Tests the transitions plugin.
diff --git a/tests/PHPUnit/System/TwoVisitorsTwoWebsitesDifferentDaysArchivingDisabledTest.php b/tests/PHPUnit/System/TwoVisitorsTwoWebsitesDifferentDaysArchivingDisabledTest.php
index 3eb2d2456c..4797cf15fe 100755
--- a/tests/PHPUnit/System/TwoVisitorsTwoWebsitesDifferentDaysArchivingDisabledTest.php
+++ b/tests/PHPUnit/System/TwoVisitorsTwoWebsitesDifferentDaysArchivingDisabledTest.php
@@ -7,8 +7,8 @@
*/
namespace Piwik\Tests\System;
-use Piwik\Tests\SystemTestCase;
-use Piwik\Tests\Fixtures\TwoSitesTwoVisitorsDifferentDays;
+use Piwik\Tests\Impl\SystemTestCase;
+use Piwik\Tests\Impl\Fixtures\TwoSitesTwoVisitorsDifferentDays;
/**
* Tests IndexedBySite optimizations when archiving is disabled.
diff --git a/tests/PHPUnit/System/TwoVisitorsTwoWebsitesDifferentDaysConversionsTest.php b/tests/PHPUnit/System/TwoVisitorsTwoWebsitesDifferentDaysConversionsTest.php
index 243e9761c5..c65ca94c7d 100755
--- a/tests/PHPUnit/System/TwoVisitorsTwoWebsitesDifferentDaysConversionsTest.php
+++ b/tests/PHPUnit/System/TwoVisitorsTwoWebsitesDifferentDaysConversionsTest.php
@@ -8,10 +8,10 @@
namespace Piwik\Tests\System;
use Piwik\Plugins\Goals\Archiver;
-use Piwik\Tests\SystemTestCase;
-use Piwik\Tests\Fixtures\TwoSitesTwoVisitorsDifferentDays;
+use Piwik\Tests\Impl\SystemTestCase;
+use Piwik\Tests\Impl\Fixtures\TwoSitesTwoVisitorsDifferentDays;
-require_once 'Goals/Goals.php';
+require_once PIWIK_INCLUDE_PATH . '/plugins/Goals/Goals.php';
/**
* Same as TwoVisitors_twoWebsites_differentDays but with goals that convert
diff --git a/tests/PHPUnit/System/TwoVisitorsTwoWebsitesDifferentDaysTest.php b/tests/PHPUnit/System/TwoVisitorsTwoWebsitesDifferentDaysTest.php
index 668924b4d8..cbde5332e8 100755
--- a/tests/PHPUnit/System/TwoVisitorsTwoWebsitesDifferentDaysTest.php
+++ b/tests/PHPUnit/System/TwoVisitorsTwoWebsitesDifferentDaysTest.php
@@ -7,8 +7,8 @@
*/
namespace Piwik\Tests\System;
-use Piwik\Tests\SystemTestCase;
-use Piwik\Tests\Fixtures\TwoSitesTwoVisitorsDifferentDays;
+use Piwik\Tests\Impl\SystemTestCase;
+use Piwik\Tests\Impl\Fixtures\TwoSitesTwoVisitorsDifferentDays;
/**
* tests Tracker several websites, different days.
diff --git a/tests/PHPUnit/System/TwoVisitsWithCustomVariablesSegmentContainsTest.php b/tests/PHPUnit/System/TwoVisitsWithCustomVariablesSegmentContainsTest.php
index a8bbdcc092..1fc3f60e6d 100755
--- a/tests/PHPUnit/System/TwoVisitsWithCustomVariablesSegmentContainsTest.php
+++ b/tests/PHPUnit/System/TwoVisitsWithCustomVariablesSegmentContainsTest.php
@@ -7,8 +7,8 @@
*/
namespace Piwik\Tests\System;
-use Piwik\Tests\SystemTestCase;
-use Piwik\Tests\Fixtures\TwoVisitsWithCustomVariables;
+use Piwik\Tests\Impl\SystemTestCase;
+use Piwik\Tests\Impl\Fixtures\TwoVisitsWithCustomVariables;
/**
* Tests use of custom variable segments.
diff --git a/tests/PHPUnit/System/TwoVisitsWithCustomVariablesSegmentMatchALLNoGoalDataTest.php b/tests/PHPUnit/System/TwoVisitsWithCustomVariablesSegmentMatchALLNoGoalDataTest.php
index 1a16bc627f..f273d84fa7 100755
--- a/tests/PHPUnit/System/TwoVisitsWithCustomVariablesSegmentMatchALLNoGoalDataTest.php
+++ b/tests/PHPUnit/System/TwoVisitsWithCustomVariablesSegmentMatchALLNoGoalDataTest.php
@@ -7,8 +7,8 @@
*/
namespace Piwik\Tests\System;
-use Piwik\Tests\SystemTestCase;
-use Piwik\Tests\Fixtures\TwoVisitsWithCustomVariables;
+use Piwik\Tests\Impl\SystemTestCase;
+use Piwik\Tests\Impl\Fixtures\TwoVisitsWithCustomVariables;
/**
* @group Plugins
diff --git a/tests/PHPUnit/System/TwoVisitsWithCustomVariablesSegmentMatchNONETest.php b/tests/PHPUnit/System/TwoVisitsWithCustomVariablesSegmentMatchNONETest.php
index 27fdbd8167..42eba9b348 100755
--- a/tests/PHPUnit/System/TwoVisitsWithCustomVariablesSegmentMatchNONETest.php
+++ b/tests/PHPUnit/System/TwoVisitsWithCustomVariablesSegmentMatchNONETest.php
@@ -8,9 +8,9 @@
namespace Piwik\Tests\System;
use Piwik\Plugins\API\API;
-use Piwik\Tests\SystemTestCase;
-use Piwik\Tests\Fixtures\TwoVisitsWithCustomVariables;
-use Piwik\Tests\Fixture;
+use Piwik\Tests\Impl\SystemTestCase;
+use Piwik\Tests\Impl\Fixtures\TwoVisitsWithCustomVariables;
+use Piwik\Tests\Impl\Fixture;
/**
* testing a segment containing all supported fields
diff --git a/tests/PHPUnit/System/TwoVisitsWithCustomVariablesSegmentMatchVisitorTypeTest.php b/tests/PHPUnit/System/TwoVisitsWithCustomVariablesSegmentMatchVisitorTypeTest.php
index 5f1db60602..7a2e98a320 100755
--- a/tests/PHPUnit/System/TwoVisitsWithCustomVariablesSegmentMatchVisitorTypeTest.php
+++ b/tests/PHPUnit/System/TwoVisitsWithCustomVariablesSegmentMatchVisitorTypeTest.php
@@ -9,8 +9,8 @@ namespace Piwik\Tests\System;
use Piwik\Common;
use Piwik\Db;
-use Piwik\Tests\SystemTestCase;
-use Piwik\Tests\Fixtures\TwoVisitsWithCustomVariables;
+use Piwik\Tests\Impl\SystemTestCase;
+use Piwik\Tests\Impl\Fixtures\TwoVisitsWithCustomVariables;
/**
* Tests use of custom variable segments.
diff --git a/tests/PHPUnit/System/TwoVisitsWithCustomVariablesTest.php b/tests/PHPUnit/System/TwoVisitsWithCustomVariablesTest.php
index a7b65b18fb..77b7f97caf 100755
--- a/tests/PHPUnit/System/TwoVisitsWithCustomVariablesTest.php
+++ b/tests/PHPUnit/System/TwoVisitsWithCustomVariablesTest.php
@@ -7,8 +7,8 @@
*/
namespace Piwik\Tests\System;
-use Piwik\Tests\SystemTestCase;
-use Piwik\Tests\Fixtures\TwoVisitsWithCustomVariables;
+use Piwik\Tests\Impl\SystemTestCase;
+use Piwik\Tests\Impl\Fixtures\TwoVisitsWithCustomVariables;
/**
* Tests w/ two visits & custom variables.
diff --git a/tests/PHPUnit/System/UrlNormalizationTest.php b/tests/PHPUnit/System/UrlNormalizationTest.php
index 07011200ee..f8b3a71ce3 100644
--- a/tests/PHPUnit/System/UrlNormalizationTest.php
+++ b/tests/PHPUnit/System/UrlNormalizationTest.php
@@ -10,8 +10,8 @@ namespace Piwik\Tests\System;
use Piwik\Common;
use Piwik\Db;
use Piwik\Tracker\Action;
-use Piwik\Tests\SystemTestCase;
-use Piwik\Tests\Fixtures\OneVisitWithAbnormalPageviewUrls;
+use Piwik\Tests\Impl\SystemTestCase;
+use Piwik\Tests\Impl\Fixtures\OneVisitWithAbnormalPageviewUrls;
/**
* Tests the URL normalization.
diff --git a/tests/PHPUnit/System/UserIdAndVisitorIdTest.php b/tests/PHPUnit/System/UserIdAndVisitorIdTest.php
index ca5b2475a9..64979af52c 100644
--- a/tests/PHPUnit/System/UserIdAndVisitorIdTest.php
+++ b/tests/PHPUnit/System/UserIdAndVisitorIdTest.php
@@ -8,8 +8,8 @@
namespace Piwik\Tests\System;
use Piwik\API\Proxy;
-use Piwik\Tests\SystemTestCase;
-use Piwik\Tests\Fixtures\FewVisitsWithSetVisitorId;
+use Piwik\Tests\Impl\SystemTestCase;
+use Piwik\Tests\Impl\Fixtures\FewVisitsWithSetVisitorId;
/**
* This test tests that when using &cid=, the visitor ID is enforced
diff --git a/tests/PHPUnit/System/VisitsInPastInvalidateOldReportsTest.php b/tests/PHPUnit/System/VisitsInPastInvalidateOldReportsTest.php
index 35f9b8ab57..bb609d6bee 100644
--- a/tests/PHPUnit/System/VisitsInPastInvalidateOldReportsTest.php
+++ b/tests/PHPUnit/System/VisitsInPastInvalidateOldReportsTest.php
@@ -8,8 +8,8 @@
namespace Piwik\Tests\System;
use Piwik\API\Request;
-use Piwik\Tests\SystemTestCase;
-use Piwik\Tests\Fixtures\TwoSitesVisitsInPast;
+use Piwik\Tests\Impl\SystemTestCase;
+use Piwik\Tests\Impl\Fixtures\TwoSitesVisitsInPast;
use Exception;
/**
diff --git a/tests/PHPUnit/Unit/DeprecatedMethodsTest.php b/tests/PHPUnit/Unit/DeprecatedMethodsTest.php
index 6bbcc64110..2516dca051 100644
--- a/tests/PHPUnit/Unit/DeprecatedMethodsTest.php
+++ b/tests/PHPUnit/Unit/DeprecatedMethodsTest.php
@@ -30,6 +30,12 @@ class DeprecatedMethodsTest extends PHPUnit_Framework_TestCase
$validTill = '2014-10-20';
$this->assertDeprecatedMethodIsRemoved('\Piwik\SettingsPiwik', 'rewriteTmpPathWithHostname', $validTill);
+ $validTill = '2014-12-06';
+ $this->assertDeprecatedClassIsRemoved('\IntegrationTestCase', $validTill);
+ $this->assertDeprecatedClassIsRemoved('\DatabaseTestCase', $validTill);
+ $this->assertDeprecatedClassIsRemoved('\Piwik\Tests\Fixture', $validTill);
+ $this->assertDeprecatedClassIsRemoved('\Piwik\Tests\OverrideLogin', $validTill);
+
$this->assertDeprecatedMethodIsRemovedInPiwik3('\Piwik\Menu\MenuAbstract', 'add');
}
@@ -52,6 +58,25 @@ class DeprecatedMethodsTest extends PHPUnit_Framework_TestCase
$this->assertFalse($methodExists, $errorMessage);
}
+
+ private function assertDeprecatedClassIsRemoved($className, $removalDate)
+ {
+ $now = \Piwik\Date::now();
+ $removalDate = \Piwik\Date::factory($removalDate);
+
+ $classExists = class_exists($className);
+
+ if (!$now->isLater($removalDate)) {
+
+ $errorMessage = $className . 'should still exists until ' . $removalDate . ' although it is deprecated.';
+ $this->assertTrue($classExists, $errorMessage);
+ return;
+ }
+
+ $errorMessage = $className . ' should be removed as the method is deprecated but it is not.';
+ $this->assertFalse($classExists, $errorMessage);
+ }
+
private function assertDeprecatedMethodIsRemovedInPiwik3($className, $method)
{
$version = \Piwik\Version::VERSION;
diff --git a/tests/PHPUnit/bootstrap.php b/tests/PHPUnit/bootstrap.php
index ac81f691c8..8335346c6b 100644
--- a/tests/PHPUnit/bootstrap.php
+++ b/tests/PHPUnit/bootstrap.php
@@ -34,8 +34,11 @@ require_once file_exists(PIWIK_INCLUDE_PATH . '/vendor/autoload.php')
require_once PIWIK_INCLUDE_PATH . '/libs/upgradephp/upgrade.php';
require_once PIWIK_INCLUDE_PATH . '/core/testMinimumPhpVersion.php';
require_once PIWIK_INCLUDE_PATH . '/core/FrontController.php';
+require_once PIWIK_INCLUDE_PATH . '/tests/PHPUnit/Impl/Fixture.php';
require_once PIWIK_INCLUDE_PATH . '/tests/PHPUnit/Fixture.php';
-require_once PIWIK_INCLUDE_PATH . '/tests/PHPUnit/SystemTestCase.php';
+require_once PIWIK_INCLUDE_PATH . '/tests/PHPUnit/Impl/SystemTestCase.php';
+require_once PIWIK_INCLUDE_PATH . '/tests/PHPUnit/Impl/IntegrationTestCase.php';
+require_once PIWIK_INCLUDE_PATH . '/tests/PHPUnit/DatabaseTestCase.php';
require_once PIWIK_INCLUDE_PATH . '/tests/PHPUnit/IntegrationTestCase.php';
require_once PIWIK_INCLUDE_PATH . '/tests/PHPUnit/ConsoleCommandTestCase.php';
require_once PIWIK_INCLUDE_PATH . '/tests/PHPUnit/FakeAccess.php';
@@ -81,7 +84,7 @@ Try again.
-> If you still get this message, you can work around it by specifying Host + Request_Uri at the top of this file tests/PHPUnit/bootstrap.php. <-";
exit(1);
}
- $baseUrl = \Piwik\Tests\Fixture::getRootUrl();
+ $baseUrl = \Piwik\Tests\Impl\Fixture::getRootUrl();
\Piwik\SettingsPiwik::checkPiwikServerWorking($baseUrl, $acceptInvalidSSLCertificates = true);
}
diff --git a/tests/README.md b/tests/README.md
index bce6f554ea..2cc2c3180c 100644
--- a/tests/README.md
+++ b/tests/README.md
@@ -82,6 +82,32 @@ To execute the tests:
5. Write more tests :)
See ["Writing Unit tests with PHPUnit"](http://www.phpunit.de/manual/current/en/writing-tests-for-phpunit.html)
+## How to differentiate between unit, integration or system tests?
+This can be sometimes hard to decide and often leads to discussions. We consider a test as a unit test when
+it tests only a single method or class. Sometimes two or three classes can still be considered as a Unit for instance if
+ you have to pass a dummy class or something similar but it should actually only test one class or method.
+ If it has a dependency to the filesystem, web, config, database or to other plugins it is not a unit test but an
+ integration test. If the test is slow it is most likely not a unit test but an integration test as well.
+ "Slow" is of course very objective and also depends on the server but if your test does not have any dependencies
+your test will be really fast.
+
+It is an integration test if you have a dependency to a loaded plugin, to the filesystem, web, config, database or something
+similar. It is an integration test if you test multiple classes in one test.
+
+It is a system test if you - for instance - make a call to your Piwik via HTTP and the whole system is being tested.
+
+### Why do we split tests in unit, integration, system and ui folders?
+Because they fail for different reasons and the duration of the test execution is different. This allows us to execute
+all unit tests and get a result very quick. Unit tests should not fail on different systems and just run everywhere for
+ example no matter whether you are using NFS or not. Once the unit tests are green one would usually execute all integration
+ tests to see whether the next stage works. They take a bit longer as they have depenencies to the database and filesystem.
+ The system and ui tests take the most time to run as they always run through the whole code.
+
+Another advantage of running the tests separately is that we are getting a more accurate code coverage. For instance when
+running the unit tests we will get the true code coverage as they always only test one class or method. Integration tests
+usually run through a lot of code but often actually only one method is supposed to be tested. Although many methods are
+not tested they would be still marked as tested when running integration tests.
+
## System Tests
System tests files are in `tests/PHPUnit/System/*Test.php`