diff options
author | mattab <matthieu.aubry@gmail.com> | 2013-10-09 10:01:53 +0400 |
---|---|---|
committer | mattab <matthieu.aubry@gmail.com> | 2013-10-09 10:01:53 +0400 |
commit | 90cfa38be8d7df953553b7e0f249d2166bf7d910 (patch) | |
tree | 59133542b737d1c8c69703ef37567aab2b54c57c | |
parent | 9c3a523e1c1d29062a62731d9bff50571f74f0f0 (diff) |
Fix tests
-rw-r--r-- | piwik.php | 1 | ||||
-rw-r--r-- | tests/PHPUnit/Core/ReleaseCheckListTest.php | 2 | ||||
-rw-r--r-- | tests/PHPUnit/Core/TaskSchedulerTest.php | 23 | ||||
-rw-r--r-- | tests/PHPUnit/proxy/archive.php | 8 | ||||
-rw-r--r-- | tests/PHPUnit/proxy/index.php | 13 | ||||
-rwxr-xr-x | tests/PHPUnit/proxy/piwik.php | 11 |
6 files changed, 14 insertions, 44 deletions
@@ -40,6 +40,7 @@ require_once PIWIK_INCLUDE_PATH . '/core/functions.php'; require_once PIWIK_INCLUDE_PATH . '/core/PluginsManager.php'; require_once PIWIK_INCLUDE_PATH . '/core/Plugin.php'; require_once PIWIK_INCLUDE_PATH . '/core/Common.php'; +require_once PIWIK_INCLUDE_PATH . '/core/Piwik.php'; require_once PIWIK_INCLUDE_PATH . '/core/IP.php'; require_once PIWIK_INCLUDE_PATH . '/core/UrlHelper.php'; require_once PIWIK_INCLUDE_PATH . '/core/Url.php'; diff --git a/tests/PHPUnit/Core/ReleaseCheckListTest.php b/tests/PHPUnit/Core/ReleaseCheckListTest.php index d4bfc2688d..4fb6f847e7 100644 --- a/tests/PHPUnit/Core/ReleaseCheckListTest.php +++ b/tests/PHPUnit/Core/ReleaseCheckListTest.php @@ -136,7 +136,7 @@ class ReleaseCheckListTest extends PHPUnit_Framework_TestCase } // skip files with these file extensions - if (preg_match('/\.(bmp|fdf|gif|deflate|gz|ico|jar|jpg|p12|pdf|png|rar|swf|vsd|z|zip|ttf|so|dat|eps|phar)$/', $file)) { + if (preg_match('/\.(bmp|fdf|gif|deflate|exe|gz|ico|jar|jpg|p12|pdf|png|rar|swf|vsd|z|zip|ttf|so|dat|eps|phar)$/', $file)) { continue; } diff --git a/tests/PHPUnit/Core/TaskSchedulerTest.php b/tests/PHPUnit/Core/TaskSchedulerTest.php index 18c0996529..c245732098 100644 --- a/tests/PHPUnit/Core/TaskSchedulerTest.php +++ b/tests/PHPUnit/Core/TaskSchedulerTest.php @@ -109,11 +109,11 @@ class TaskSchedulerTest extends PHPUnit_Framework_TestCase */ public function testGetScheduledTimeForMethod($expectedTime, $className, $methodName, $methodParameter, $timetable) { - self::stubPiwikOption($timetable); + \Piwik\Option::set(TaskScheduler::TIMETABLE_OPTION_STRING, $timetable); $this->assertEquals($expectedTime, TaskScheduler::getScheduledTimeForMethod($className, $methodName, $methodParameter)); - self::resetPiwikOption(); + \Piwik\Option::delete(TaskScheduler::TIMETABLE_OPTION_STRING); } /** @@ -293,7 +293,7 @@ class TaskSchedulerTest extends PHPUnit_Framework_TestCase }); // stub the piwik option object to control the returned option value - self::stubPiwikOption(serialize($timetableBeforeTaskExecution)); + \Piwik\Option::set(TaskScheduler::TIMETABLE_OPTION_STRING, serialize($timetableBeforeTaskExecution)); // execute tasks $executionResults = TaskScheduler::runTasks(); @@ -314,23 +314,8 @@ class TaskSchedulerTest extends PHPUnit_Framework_TestCase // restore loaded plugins & piwik options EventDispatcher::getInstance()->clearObservers(TaskScheduler::GET_TASKS_EVENT); \Piwik\PluginsManager::getInstance()->loadPlugins($plugins); - self::resetPiwikOption(); - } - private static function stubPiwikOption($timetable) - { - self::getReflectedPiwikOptionInstance()->setValue(new MockPiwikOption($timetable)); + \Piwik\Option::delete(TaskScheduler::TIMETABLE_OPTION_STRING); } - private static function resetPiwikOption() - { - self::getReflectedPiwikOptionInstance()->setValue(null); - } - - private static function getReflectedPiwikOptionInstance() - { - $piwikOptionInstance = new ReflectionProperty('\Piwik\Option', 'instance'); - $piwikOptionInstance->setAccessible(true); - return $piwikOptionInstance; - } } diff --git a/tests/PHPUnit/proxy/archive.php b/tests/PHPUnit/proxy/archive.php index 30ac475e53..b9a891bfb3 100644 --- a/tests/PHPUnit/proxy/archive.php +++ b/tests/PHPUnit/proxy/archive.php @@ -2,11 +2,9 @@ define('PIWIK_MODE_ARCHIVE', true); define('PIWIK_ARCHIVE_NO_TRUNCATE', true); -// make sure the test environment is loaded -require_once realpath(dirname(__FILE__)) . '/../../../core/EventDispatcher.php'; -require_once realpath(dirname(__FILE__)) . "/../../../core/functions.php"; -require_once realpath(dirname(__FILE__)) . "/../../../tests/PHPUnit/TestingEnvironment.php"; +require "includes.php"; + Piwik_TestingEnvironment::addHooks(); // include archive.php, and let 'er rip -require_once realpath(dirname(__FILE__)) . "/../../../misc/cron/archive.php";
\ No newline at end of file +require_once PIWIK_INCLUDE_PATH . "/misc/cron/archive.php"; diff --git a/tests/PHPUnit/proxy/index.php b/tests/PHPUnit/proxy/index.php index 56e86d91e3..b4decf08fe 100644 --- a/tests/PHPUnit/proxy/index.php +++ b/tests/PHPUnit/proxy/index.php @@ -7,20 +7,12 @@ // make sure the test environment is loaded use Piwik\Tracker\Cache; +require "includes.php"; + // Wrapping the request inside ob_start() calls to ensure that the Test // calling us waits for the full request to process before unblocking ob_start(); -define('PIWIK_INCLUDE_PATH', '../../..'); -define('PIWIK_USER_PATH', PIWIK_INCLUDE_PATH); -define('PIWIK_PRINT_ERROR_BACKTRACE', true); - -require_once PIWIK_INCLUDE_PATH . '/libs/upgradephp/upgrade.php'; -require_once PIWIK_INCLUDE_PATH . '/core/Loader.php'; -require_once PIWIK_INCLUDE_PATH . '/core/EventDispatcher.php'; - -require_once realpath(dirname(__FILE__)) . '/../../../core/functions.php'; -require_once realpath(dirname(__FILE__)) . "/../../../tests/PHPUnit/TestingEnvironment.php"; Piwik_TestingEnvironment::addHooks(); \Piwik\Tracker::setTestEnvironment(); @@ -35,3 +27,4 @@ $controller->init(); $controller->dispatch(); ob_flush(); + diff --git a/tests/PHPUnit/proxy/piwik.php b/tests/PHPUnit/proxy/piwik.php index 8d68aacb97..5f7e8ecbcc 100755 --- a/tests/PHPUnit/proxy/piwik.php +++ b/tests/PHPUnit/proxy/piwik.php @@ -5,8 +5,6 @@ * - Use the tests database to record Tracking data * - Allows to overwrite the Visitor IP, and Server datetime * - * @see Main.test.php - * */ // Wrapping the request inside ob_start() calls to ensure that the Test @@ -19,14 +17,9 @@ use Piwik\Tracker; use Piwik\Site; use Piwik\Tracker\Cache; -ob_start(); - -define('PIWIK_INCLUDE_PATH', '../../..'); -define('PIWIK_USER_PATH', PIWIK_INCLUDE_PATH); +require "includes.php"; -require_once PIWIK_INCLUDE_PATH . '/libs/upgradephp/upgrade.php'; -require_once PIWIK_INCLUDE_PATH . '/core/Loader.php'; -require_once PIWIK_INCLUDE_PATH . '/core/functions.php'; +ob_start(); // Config files forced to use the test database // Note that this also provides security for Piwik installs containing tests files: |