diff options
author | diosmosis <benaka@piwik.pro> | 2015-05-26 22:12:47 +0300 |
---|---|---|
committer | diosmosis <benaka@piwik.pro> | 2015-06-02 01:05:27 +0300 |
commit | 86738409ae2ad93675fbdd6741ca82f4ec6212b6 (patch) | |
tree | f66f2bfce0fe5fe33d2a4adbb063503328f6af52 /tests | |
parent | 17f61e3137ff7e420d75e283b705121e4731cce7 (diff) |
Rename Piwik_TestingEnvironment to TestingEnvironment and move the class to Piwik\Tests\Framework namespace. Remove manual require statements.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/PHPUnit/Framework/Fixture.php | 6 | ||||
-rw-r--r-- | tests/PHPUnit/Framework/Mock/TestConfig.php | 4 | ||||
-rw-r--r-- | tests/PHPUnit/Framework/TestCase/IntegrationTestCase.php | 2 | ||||
-rw-r--r-- | tests/PHPUnit/Framework/TestingEnvironment.php (renamed from tests/PHPUnit/TestingEnvironment.php) | 38 | ||||
-rw-r--r-- | tests/PHPUnit/Framework/TestingEnvironment/MakeGlobalSettingsWithFile.php | 2 | ||||
-rw-r--r-- | tests/PHPUnit/System/EnvironmentValidationTest.php | 8 | ||||
-rwxr-xr-x | tests/PHPUnit/System/ImportLogsTest.php | 4 | ||||
-rw-r--r-- | tests/PHPUnit/System/TrackerTest.php | 8 | ||||
-rw-r--r-- | tests/PHPUnit/bootstrap.php | 1 | ||||
-rw-r--r-- | tests/PHPUnit/proxy/archive.php | 2 | ||||
-rw-r--r-- | tests/PHPUnit/proxy/console | 2 | ||||
-rw-r--r-- | tests/PHPUnit/proxy/includes.php | 2 | ||||
-rw-r--r-- | tests/PHPUnit/proxy/index.php | 2 | ||||
-rwxr-xr-x | tests/PHPUnit/proxy/piwik.php | 2 |
14 files changed, 42 insertions, 41 deletions
diff --git a/tests/PHPUnit/Framework/Fixture.php b/tests/PHPUnit/Framework/Fixture.php index e91a9e40bf..930d5b222d 100644 --- a/tests/PHPUnit/Framework/Fixture.php +++ b/tests/PHPUnit/Framework/Fixture.php @@ -46,7 +46,7 @@ use Piwik\Tracker\Cache; use Piwik\Translate; use Piwik\Url; use PHPUnit_Framework_Assert; -use Piwik_TestingEnvironment; +use Piwik\Tests\Framework\TestingEnvironment; use PiwikTracker; use Piwik_LocalTracker; use Piwik\Updater; @@ -275,7 +275,7 @@ class Fixture extends \PHPUnit_Framework_Assert public function getTestEnvironment() { if ($this->testEnvironment === null) { - $this->testEnvironment = new Piwik_TestingEnvironment(); + $this->testEnvironment = new TestingEnvironment(); $this->testEnvironment->delete(); if (getenv('PIWIK_USE_XHPROF') == 1) { @@ -336,7 +336,7 @@ class Fixture extends \PHPUnit_Framework_Assert public static function loadAllPlugins($testEnvironment = null, $testCaseClass = false, $extraPluginsToLoad = array()) { if (empty($testEnvironment)) { - $testEnvironment = new Piwik_TestingEnvironment(); + $testEnvironment = new TestingEnvironment(); } DbHelper::createTables(); diff --git a/tests/PHPUnit/Framework/Mock/TestConfig.php b/tests/PHPUnit/Framework/Mock/TestConfig.php index d7a1f72488..fce172a7fd 100644 --- a/tests/PHPUnit/Framework/Mock/TestConfig.php +++ b/tests/PHPUnit/Framework/Mock/TestConfig.php @@ -25,7 +25,7 @@ class TestConfig extends Config $this->reload(); - $testingEnvironment = new \Piwik_TestingEnvironment(); + $testingEnvironment = new \Piwik\Tests\Framework\TestingEnvironment(); $this->setFromTestEnvironment($testingEnvironment); } @@ -73,7 +73,7 @@ class TestConfig extends Config $chain->set('PluginsInstalled', array('PluginsInstalled' => array())); } - private function setFromTestEnvironment(\Piwik_TestingEnvironment $testingEnvironment) + private function setFromTestEnvironment(\Piwik\Tests\Framework\TestingEnvironment $testingEnvironment) { $pluginsToLoad = $testingEnvironment->getCoreAndSupportedPlugins(); if (!empty($testingEnvironment->pluginsToLoad)) { diff --git a/tests/PHPUnit/Framework/TestCase/IntegrationTestCase.php b/tests/PHPUnit/Framework/TestCase/IntegrationTestCase.php index 492f9fc968..2224bd45f5 100644 --- a/tests/PHPUnit/Framework/TestCase/IntegrationTestCase.php +++ b/tests/PHPUnit/Framework/TestCase/IntegrationTestCase.php @@ -77,7 +77,7 @@ abstract class IntegrationTestCase extends SystemTestCase self::$fixture->extraDefinitions = array_merge(static::provideContainerConfigBeforeClass(), $this->provideContainerConfig()); self::$fixture->createEnvironmentInstance(); - Fixture::loadAllPlugins(new \Piwik_TestingEnvironment(), get_class($this), self::$fixture->extraPluginsToLoad); + Fixture::loadAllPlugins(new \Piwik\Tests\Framework\TestingEnvironment(), get_class($this), self::$fixture->extraPluginsToLoad); if (!empty(self::$tableData)) { self::restoreDbTables(self::$tableData); diff --git a/tests/PHPUnit/TestingEnvironment.php b/tests/PHPUnit/Framework/TestingEnvironment.php index c698d69440..94b85e012c 100644 --- a/tests/PHPUnit/TestingEnvironment.php +++ b/tests/PHPUnit/Framework/TestingEnvironment.php @@ -1,17 +1,22 @@ <?php +/** + * Piwik - free/libre analytics platform + * + * @link http://piwik.org + * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later + */ -use Piwik\Application\Environment; -use Piwik\Common; -use Piwik\Config; +namespace Piwik\Tests\Framework; + +use Piwik\Plugin\Manager as PluginManager; +use Exception; use Piwik\Container\StaticContainer; -use Piwik\Piwik; +use Piwik\Tests\Framework\TestingEnvironment\MakeGlobalSettingsWithFile; +use Piwik\Common; use Piwik\Option; -use Piwik\Plugin\Manager as PluginManager; use Piwik\DbHelper; -use Piwik\Tests\Framework\Fixture; -use Piwik\Tests\Framework\TestingEnvironment\MakeGlobalSettingsWithFile; - -require_once PIWIK_INCLUDE_PATH . "/core/Config.php"; +use Piwik\Piwik; +use Piwik\Application\Environment; if (!defined('PIWIK_TEST_MODE')) { define('PIWIK_TEST_MODE', true); @@ -46,7 +51,7 @@ class Piwik_MockAccess /** * Sets the test environment. */ -class Piwik_TestingEnvironment +class TestingEnvironment { private $behaviorOverrideProperties = array(); @@ -119,7 +124,7 @@ class Piwik_TestingEnvironment } return $pluginManager->isPluginBundledWithCore($pluginName) - || $pluginManager->isPluginOfficialAndNotBundledWithCore($pluginName); + || $pluginManager->isPluginOfficialAndNotBundledWithCore($pluginName); }); sort($plugins); @@ -129,7 +134,7 @@ class Piwik_TestingEnvironment public static function addHooks($globalObservers = array()) { - $testingEnvironment = new Piwik_TestingEnvironment(); + $testingEnvironment = new TestingEnvironment(); if ($testingEnvironment->queryParamOverride) { foreach ($testingEnvironment->queryParamOverride as $key => $value) { @@ -185,7 +190,7 @@ class Piwik_TestingEnvironment $diConfig['Piwik\Config'] = \DI\object('Piwik\Tests\Framework\Mock\TestConfig'); } - $globalObservers[] = array('Access.createAccessSingleton', function($access) use ($testingEnvironment) { + $globalObservers[] = array('Access.createAccessSingleton', function ($access) use ($testingEnvironment) { if (!$testingEnvironment->testUseRegularAuth) { $access = new Piwik_MockAccess($access); \Piwik\Access::setSingletonInstance($access); @@ -271,9 +276,8 @@ class Piwik_TestingEnvironment foreach ($array2 as $key => $value) { if (is_array($value)) { $result[$key] = isset($result[$key]) && is_array($result[$key]) - ? $this->arrayMergeRecursiveDistinct($result[$key], $value) - : $value - ; + ? $this->arrayMergeRecursiveDistinct($result[$key], $value) + : $value; } else { $result[$key] = $value; } @@ -289,4 +293,4 @@ class Piwik_TestingEnvironment { Piwik::postEvent("TestingEnvironment.addHooks", array($this), $pending = true); } -} +}
\ No newline at end of file diff --git a/tests/PHPUnit/Framework/TestingEnvironment/MakeGlobalSettingsWithFile.php b/tests/PHPUnit/Framework/TestingEnvironment/MakeGlobalSettingsWithFile.php index cd03b8bb21..2c2ead227d 100644 --- a/tests/PHPUnit/Framework/TestingEnvironment/MakeGlobalSettingsWithFile.php +++ b/tests/PHPUnit/Framework/TestingEnvironment/MakeGlobalSettingsWithFile.php @@ -17,7 +17,7 @@ class MakeGlobalSettingsWithFile implements EnvironmentManipulator private $configFileLocal; private $configFileCommon; - public function __construct(\Piwik_TestingEnvironment $testingEnvironment) + public function __construct(\Piwik\Tests\Framework\TestingEnvironment $testingEnvironment) { $this->configFileGlobal = $testingEnvironment->configFileGlobal; $this->configFileLocal = $testingEnvironment->configFileLocal; diff --git a/tests/PHPUnit/System/EnvironmentValidationTest.php b/tests/PHPUnit/System/EnvironmentValidationTest.php index 37d631a5a4..aea7dabe2f 100644 --- a/tests/PHPUnit/System/EnvironmentValidationTest.php +++ b/tests/PHPUnit/System/EnvironmentValidationTest.php @@ -30,7 +30,7 @@ class EnvironmentValidationTest extends SystemTestCase { parent::setUp(); - $testingEnvironment = new \Piwik_TestingEnvironment(); + $testingEnvironment = new \Piwik\Tests\Framework\TestingEnvironment(); $testingEnvironment->configFileGlobal = null; $testingEnvironment->configFileLocal = null; $testingEnvironment->configFileCommon = null; @@ -138,7 +138,7 @@ class EnvironmentValidationTest extends SystemTestCase private function simulateAbsentConfigFile($fileName) { - $testingEnvironment = new \Piwik_TestingEnvironment(); + $testingEnvironment = new \Piwik\Tests\Framework\TestingEnvironment(); if ($fileName == 'global.ini.php') { $testingEnvironment->configFileGlobal = PIWIK_INCLUDE_PATH . '/tmp/nonexistant/global.ini.php'; @@ -153,7 +153,7 @@ class EnvironmentValidationTest extends SystemTestCase private function simulateBadConfigFile($fileName) { - $testingEnvironment = new \Piwik_TestingEnvironment(); + $testingEnvironment = new \Piwik\Tests\Framework\TestingEnvironment(); if ($fileName == 'global.ini.php') { $testingEnvironment->configFileGlobal = PIWIK_INCLUDE_PATH . '/piwik.php'; @@ -168,7 +168,7 @@ class EnvironmentValidationTest extends SystemTestCase private function simulateHost($host) { - $testingEnvironment = new \Piwik_TestingEnvironment(); + $testingEnvironment = new \Piwik\Tests\Framework\TestingEnvironment(); $testingEnvironment->hostOverride = $host; $testingEnvironment->save(); } diff --git a/tests/PHPUnit/System/ImportLogsTest.php b/tests/PHPUnit/System/ImportLogsTest.php index e622265dff..f4c941adb5 100755 --- a/tests/PHPUnit/System/ImportLogsTest.php +++ b/tests/PHPUnit/System/ImportLogsTest.php @@ -137,7 +137,7 @@ class ImportLogsTest extends SystemTestCase private function simulateTrackerFailure() { - $testingEnvironment = new \Piwik_TestingEnvironment(); + $testingEnvironment = new \Piwik\Tests\Framework\TestingEnvironment(); $testingEnvironment->configOverride = array( 'Tracker' => array('bulk_requests_require_authentication' => 1) ); @@ -151,7 +151,7 @@ class ImportLogsTest extends SystemTestCase private function resetTestingEnvironmentChanges() { - $testingEnvironment = new \Piwik_TestingEnvironment(); + $testingEnvironment = new \Piwik\Tests\Framework\TestingEnvironment(); $testingEnvironment->configOverride = null; $testingEnvironment->save(); } diff --git a/tests/PHPUnit/System/TrackerTest.php b/tests/PHPUnit/System/TrackerTest.php index 24b500b33c..6a75ea7584 100644 --- a/tests/PHPUnit/System/TrackerTest.php +++ b/tests/PHPUnit/System/TrackerTest.php @@ -36,7 +36,7 @@ class TrackerTest extends IntegrationTestCase Fixture::createWebsite('2014-02-04'); - $testingEnvironment = new \Piwik_TestingEnvironment(); + $testingEnvironment = new \Piwik\Tests\Framework\TestingEnvironment(); $testingEnvironment->testCaseClass = null; $testingEnvironment->addFailingScheduledTask = false; $testingEnvironment->addScheduledTask = false; @@ -291,7 +291,7 @@ class TrackerTest extends IntegrationTestCase private function setScheduledTasksToRunInTracker() { - $testingEnvironment = new \Piwik_TestingEnvironment(); + $testingEnvironment = new \Piwik\Tests\Framework\TestingEnvironment(); $testingEnvironment->testCaseClass = 'Piwik\Tests\System\TrackerTest'; $testingEnvironment->addScheduledTask = true; $testingEnvironment->configOverride = array('Tracker' => array('scheduled_tasks_min_interval' => 1, 'debug_on_demand' => 1)); @@ -300,7 +300,7 @@ class TrackerTest extends IntegrationTestCase private function addFailingScheduledTaskToTracker($doFatalError) { - $testingEnvironment = new \Piwik_TestingEnvironment(); + $testingEnvironment = new \Piwik\Tests\Framework\TestingEnvironment(); $testingEnvironment->addFailingScheduledTask = true; $testingEnvironment->scheduledTaskFailureShouldBeFatal = $doFatalError; $testingEnvironment->save(); @@ -312,7 +312,7 @@ class TrackerTest extends IntegrationTestCase define('DEBUG_FORCE_SCHEDULED_TASKS', 1); } - $testingEnvironment = new \Piwik_TestingEnvironment(); + $testingEnvironment = new \Piwik\Tests\Framework\TestingEnvironment(); $tasksToAdd = array(); diff --git a/tests/PHPUnit/bootstrap.php b/tests/PHPUnit/bootstrap.php index e946cfcb02..a6045ad407 100644 --- a/tests/PHPUnit/bootstrap.php +++ b/tests/PHPUnit/bootstrap.php @@ -36,7 +36,6 @@ if (!defined('PIWIK_INCLUDE_SEARCH_PATH')) { require_once PIWIK_INCLUDE_PATH . '/core/bootstrap.php'; require_once PIWIK_INCLUDE_PATH . '/libs/PiwikTracker/PiwikTracker.php'; -require_once PIWIK_INCLUDE_PATH . '/tests/PHPUnit/TestingEnvironment.php'; if (getenv('PIWIK_USE_XHPROF') == 1) { \Piwik\Profiler::setupProfilerXHProf(); diff --git a/tests/PHPUnit/proxy/archive.php b/tests/PHPUnit/proxy/archive.php index a4d5f4e476..33c7d715fc 100644 --- a/tests/PHPUnit/proxy/archive.php +++ b/tests/PHPUnit/proxy/archive.php @@ -3,7 +3,7 @@ define('PIWIK_ARCHIVE_NO_TRUNCATE', true); require realpath(dirname(__FILE__)) . "/includes.php"; -Piwik_TestingEnvironment::addHooks(); +\Piwik\Tests\Framework\TestingEnvironment::addHooks(); // include archive.php, and let 'er rip require_once PIWIK_INCLUDE_PATH . "/misc/cron/archive.php"; diff --git a/tests/PHPUnit/proxy/console b/tests/PHPUnit/proxy/console index 1ccef19ecc..a6cd68e1ae 100644 --- a/tests/PHPUnit/proxy/console +++ b/tests/PHPUnit/proxy/console @@ -2,6 +2,6 @@ <?php require realpath(dirname(__FILE__)) . "/includes.php"; -Piwik_TestingEnvironment::addHooks(); +\Piwik\Tests\Framework\TestingEnvironment::addHooks(); require_once PIWIK_INCLUDE_PATH . "/console"; diff --git a/tests/PHPUnit/proxy/includes.php b/tests/PHPUnit/proxy/includes.php index 0d6b3d878c..69af8b7804 100644 --- a/tests/PHPUnit/proxy/includes.php +++ b/tests/PHPUnit/proxy/includes.php @@ -9,6 +9,4 @@ if (!defined('PIWIK_USER_PATH')) { require_once PIWIK_INCLUDE_PATH . '/core/bootstrap.php'; -require_once PIWIK_INCLUDE_PATH . '/tests/PHPUnit/TestingEnvironment.php'; - Piwik\SettingsServer::setMaxExecutionTime(0); diff --git a/tests/PHPUnit/proxy/index.php b/tests/PHPUnit/proxy/index.php index 213df21cf8..2c1183235d 100644 --- a/tests/PHPUnit/proxy/index.php +++ b/tests/PHPUnit/proxy/index.php @@ -6,6 +6,6 @@ require realpath(dirname(__FILE__)) . "/includes.php"; -Piwik_TestingEnvironment::addHooks(); +\Piwik\Tests\Framework\TestingEnvironment::addHooks(); include PIWIK_INCLUDE_PATH . '/index.php';
\ No newline at end of file diff --git a/tests/PHPUnit/proxy/piwik.php b/tests/PHPUnit/proxy/piwik.php index 078069b30f..37d1ba834d 100755 --- a/tests/PHPUnit/proxy/piwik.php +++ b/tests/PHPUnit/proxy/piwik.php @@ -29,7 +29,7 @@ try { }) ); - Piwik_TestingEnvironment::addHooks($globalObservers); + \Piwik\Tests\Framework\TestingEnvironment::addHooks($globalObservers); GeoIp::$geoIPDatabaseDir = 'tests/lib/geoip-files'; |