From 11752942f0e6526a0d254af2bb2b101491238f29 Mon Sep 17 00:00:00 2001 From: mattab Date: Wed, 31 Jul 2013 18:46:40 +0200 Subject: Refs #3741 PHP Namespace conversion continued: Tracker classes, renaming Unzip to Uncompress, Renaming Tracker/Referer to Tracker/Referrer, and few more --- tests/PHPUnit/Core/DataTableTest.php | 8 +-- tests/PHPUnit/Core/ReleaseCheckListTest.php | 3 +- tests/PHPUnit/Core/ScheduledTime/DailyTest.php | 26 +++++----- tests/PHPUnit/Core/ScheduledTime/HourlyTest.php | 16 +++--- tests/PHPUnit/Core/ScheduledTime/MonthlyTest.php | 32 ++++++------ tests/PHPUnit/Core/ScheduledTime/WeeklyTest.php | 34 ++++++------ tests/PHPUnit/Core/TaskSchedulerTest.php | 5 +- tests/PHPUnit/Core/Tracker/ActionTest.php | 60 +++++++++++----------- tests/PHPUnit/Core/Tracker/VisitTest.php | 12 +++-- tests/PHPUnit/Core/UnzipTest.php | 28 +++++----- tests/PHPUnit/Core/UrlTest.php | 2 +- tests/PHPUnit/DatabaseTestCase.php | 3 +- .../PHPUnit/Fixtures/FewVisitsWithSetVisitorId.php | 5 +- ...CustomVariables_SegmentMatchVisitorTypeTest.php | 2 +- tests/PHPUnit/Integration/UrlNormalizationTest.php | 3 +- tests/PHPUnit/IntegrationTestCase.php | 5 +- tests/PHPUnit/Plugins/ActionsTest.php | 41 +++++++-------- tests/PHPUnit/Plugins/PDFReportsTest.php | 10 ++-- tests/PHPUnit/Plugins/PrivacyManagerTest.php | 6 ++- tests/PHPUnit/proxy/index.php | 3 +- tests/PHPUnit/proxy/piwik.php | 3 +- 21 files changed, 169 insertions(+), 138 deletions(-) (limited to 'tests/PHPUnit') diff --git a/tests/PHPUnit/Core/DataTableTest.php b/tests/PHPUnit/Core/DataTableTest.php index 5568c259e2..d8e825ef88 100644 --- a/tests/PHPUnit/Core/DataTableTest.php +++ b/tests/PHPUnit/Core/DataTableTest.php @@ -304,12 +304,14 @@ class DataTableTest extends PHPUnit_Framework_TestCase public function test_unserializeWorks_WhenDataTableFormatPriorPiwik2() { + $serializedDatatable = ''; // Prior Piwik 2.0, we didn't use namespaces. Some - $oldSerialized = 'O:19:"Piwik_DataTable_Row":1:{s:1:"c";a:3:{i:0;a:8:{s:8:"test_int";i:150;s:10:"test_float";d:150;s:11:"test_float2";d:14.5; - s:14:"test_stringint";i:150;i:0;s:4:"toto";s:17:"integerArrayToSum";a:3:{i:1;i:6;i:2;d:15.5;i:3;a:2:{i:2;i:7;i:1;i:2;}}s:11:"test_float3";d:1.5;s:4:"test";s:11:"string fake";}i:1;a:2:{s:4:"logo";s:9:"piwik.png";s:5:"super";a:1:{i:0;s:39:"this column has an array value, amazing";}}i:3;N;}}'; - + require PIWIK_INCLUDE_PATH . "/tests/resources/pre-Piwik2-DataTable-archived.php"; + $this->assertTrue(strlen($serializedDatatable) > 1000); + $table = unserialize($serializedDatatable); + $this->assertTrue($table[0] instanceof \Piwik\DataTable\Row); } /** diff --git a/tests/PHPUnit/Core/ReleaseCheckListTest.php b/tests/PHPUnit/Core/ReleaseCheckListTest.php index 116ddae02c..1d12346cca 100644 --- a/tests/PHPUnit/Core/ReleaseCheckListTest.php +++ b/tests/PHPUnit/Core/ReleaseCheckListTest.php @@ -1,6 +1,7 @@ assertTrue(Piwik_Tracker_Db::isProfilingEnabled() === false, 'SQL profiler should be disabled in production! See Piwik_Tracker_Db::$profiling'); + $this->assertTrue(Db::isProfilingEnabled() === false, 'SQL profiler should be disabled in production! See Db::$profiling'); } /** diff --git a/tests/PHPUnit/Core/ScheduledTime/DailyTest.php b/tests/PHPUnit/Core/ScheduledTime/DailyTest.php index 982e19cd12..501e1adb34 100644 --- a/tests/PHPUnit/Core/ScheduledTime/DailyTest.php +++ b/tests/PHPUnit/Core/ScheduledTime/DailyTest.php @@ -5,6 +5,8 @@ * @link http://piwik.org * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later */ +use Piwik\ScheduledTime\Daily; + class ScheduledTime_DailyTest extends PHPUnit_Framework_TestCase { private static $_JANUARY_01_1971_09_00_00; @@ -24,7 +26,7 @@ class ScheduledTime_DailyTest extends PHPUnit_Framework_TestCase } /** - * Tests invalid call to setHour on Piwik_ScheduledTime_Daily + * Tests invalid call to setHour on Daily * @group Core * @group ScheduledTime * @group ScheduledTime_Daily @@ -32,7 +34,7 @@ class ScheduledTime_DailyTest extends PHPUnit_Framework_TestCase public function testSetHourScheduledTimeDailyNegative() { try { - $dailySchedule = new Piwik_ScheduledTime_Daily(); + $dailySchedule = new Daily(); $dailySchedule->setHour(-1); } catch (Exception $e) { @@ -42,7 +44,7 @@ class ScheduledTime_DailyTest extends PHPUnit_Framework_TestCase } /** - * Tests invalid call to setHour on Piwik_ScheduledTime_Daily + * Tests invalid call to setHour on Daily * @group Core * @group ScheduledTime * @group ScheduledTime_Daily @@ -50,7 +52,7 @@ class ScheduledTime_DailyTest extends PHPUnit_Framework_TestCase public function testSetHourScheduledTimeDailyOver24() { try { - $dailySchedule = new Piwik_ScheduledTime_Daily(); + $dailySchedule = new Daily(); $dailySchedule->setHour(25); } catch (Exception $e) { return; @@ -59,7 +61,7 @@ class ScheduledTime_DailyTest extends PHPUnit_Framework_TestCase } /** - * Tests forbidden call to setDay on Piwik_ScheduledTime_Daily + * Tests forbidden call to setDay on Daily * @group Core * @group ScheduledTime * @group ScheduledTime_Daily @@ -67,7 +69,7 @@ class ScheduledTime_DailyTest extends PHPUnit_Framework_TestCase public function testSetDayScheduledTimeDaily() { try { - $dailySchedule = new Piwik_ScheduledTime_Daily(); + $dailySchedule = new Daily(); $dailySchedule->setDay(1); } catch (Exception $e) { return; @@ -76,7 +78,7 @@ class ScheduledTime_DailyTest extends PHPUnit_Framework_TestCase } /** - * Tests getRescheduledTime on Piwik_ScheduledTime_Daily with unspecified hour + * Tests getRescheduledTime on Daily with unspecified hour * @group Core * @group ScheduledTime * @group ScheduledTime_Daily @@ -93,7 +95,7 @@ class ScheduledTime_DailyTest extends PHPUnit_Framework_TestCase * Expected : * getRescheduledTime returns Saturday January 2 1971 00:00:00 UTC */ - $mock = $this->getMock('Piwik_ScheduledTime_Daily', array('getTime')); + $mock = $this->getMock('\Piwik\ScheduledTime\Daily', array('getTime')); $mock->expects($this->any()) ->method('getTime') ->will($this->returnValue(self::$_JANUARY_01_1971_09_10_00)); @@ -101,7 +103,7 @@ class ScheduledTime_DailyTest extends PHPUnit_Framework_TestCase } /** - * Tests getRescheduledTime on Piwik_ScheduledTime_Daily with specified hour + * Tests getRescheduledTime on Daily with specified hour * @group Core * @group ScheduledTime * @group ScheduledTime_Daily @@ -118,7 +120,7 @@ class ScheduledTime_DailyTest extends PHPUnit_Framework_TestCase * Expected : * getRescheduledTime returns Saturday January 2 1971 09:00:00 UTC */ - $mock = $this->getMock('Piwik_ScheduledTime_Daily', array('getTime')); + $mock = $this->getMock('\Piwik\ScheduledTime\Daily', array('getTime')); $mock->expects($this->any()) ->method('getTime') ->will($this->returnValue(self::$_JANUARY_01_1971_09_00_00)); @@ -135,7 +137,7 @@ class ScheduledTime_DailyTest extends PHPUnit_Framework_TestCase * Expected : * getRescheduledTime returns Saturday January 2 1971 09:00:00 UTC */ - $mock = $this->getMock('Piwik_ScheduledTime_Daily', array('getTime')); + $mock = $this->getMock('\Piwik\ScheduledTime\Daily', array('getTime')); $mock->expects($this->any()) ->method('getTime') ->will($this->returnValue(self::$_JANUARY_01_1971_12_10_00)); @@ -152,7 +154,7 @@ class ScheduledTime_DailyTest extends PHPUnit_Framework_TestCase * Expected : * getRescheduledTime returns Saturday January 2 1971 00:00:00 UTC */ - $mock = $this->getMock('Piwik_ScheduledTime_Daily', array('getTime')); + $mock = $this->getMock('\Piwik\ScheduledTime\Daily', array('getTime')); $mock->expects($this->any()) ->method('getTime') ->will($this->returnValue(self::$_JANUARY_01_1971_12_10_00)); diff --git a/tests/PHPUnit/Core/ScheduledTime/HourlyTest.php b/tests/PHPUnit/Core/ScheduledTime/HourlyTest.php index b0c808fe5e..43b422739f 100644 --- a/tests/PHPUnit/Core/ScheduledTime/HourlyTest.php +++ b/tests/PHPUnit/Core/ScheduledTime/HourlyTest.php @@ -5,6 +5,8 @@ * @link http://piwik.org * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later */ +use Piwik\ScheduledTime\Hourly; + class ScheduledTime_HourlyTest extends PHPUnit_Framework_TestCase { private static $_JANUARY_01_1971_09_00_00; @@ -20,7 +22,7 @@ class ScheduledTime_HourlyTest extends PHPUnit_Framework_TestCase } /** - * Tests forbidden call to setHour on Piwik_ScheduledTime_Hourly + * Tests forbidden call to setHour on Hourly * @group Core * @group ScheduledTime * @group ScheduledTime_Hourly @@ -28,7 +30,7 @@ class ScheduledTime_HourlyTest extends PHPUnit_Framework_TestCase public function testSetHourScheduledTimeHourly() { try { - $hourlySchedule = new Piwik_ScheduledTime_Hourly(); + $hourlySchedule = new Hourly(); $hourlySchedule->setHour(0); } catch (Exception $e) { return; @@ -37,7 +39,7 @@ class ScheduledTime_HourlyTest extends PHPUnit_Framework_TestCase } /** - * Tests forbidden call to setDay on Piwik_ScheduledTime_Hourly + * Tests forbidden call to setDay on Hourly * @group Core * @group ScheduledTime * @group ScheduledTime_Hourly @@ -45,7 +47,7 @@ class ScheduledTime_HourlyTest extends PHPUnit_Framework_TestCase public function testSetDayScheduledTimeHourly() { try { - $hourlySchedule = new Piwik_ScheduledTime_Hourly(); + $hourlySchedule = new Hourly(); $hourlySchedule->setDay(1); } catch (Exception $e) { return; @@ -54,7 +56,7 @@ class ScheduledTime_HourlyTest extends PHPUnit_Framework_TestCase } /** - * Tests getRescheduledTime on Piwik_ScheduledTime_Hourly + * Tests getRescheduledTime on Hourly * @group Core * @group ScheduledTime * @group ScheduledTime_Hourly @@ -70,7 +72,7 @@ class ScheduledTime_HourlyTest extends PHPUnit_Framework_TestCase * Expected : * getRescheduledTime returns Friday January 1 1971 10:00:00 GMT */ - $mock = $this->getMock('Piwik_ScheduledTime_Hourly', array('getTime')); + $mock = $this->getMock('\Piwik\ScheduledTime\Hourly', array('getTime')); $mock->expects($this->any()) ->method('getTime') ->will($this->returnValue(self::$_JANUARY_01_1971_09_00_00)); @@ -85,7 +87,7 @@ class ScheduledTime_HourlyTest extends PHPUnit_Framework_TestCase * Expected : * getRescheduledTime returns Friday January 1 1971 10:00:00 GMT */ - $mock = $this->getMock('Piwik_ScheduledTime_Hourly', array('getTime')); + $mock = $this->getMock('\Piwik\ScheduledTime\Hourly', array('getTime')); $mock->expects($this->any()) ->method('getTime') ->will($this->returnValue(self::$_JANUARY_01_1971_09_10_00)); diff --git a/tests/PHPUnit/Core/ScheduledTime/MonthlyTest.php b/tests/PHPUnit/Core/ScheduledTime/MonthlyTest.php index 8bab11da43..00f61917df 100644 --- a/tests/PHPUnit/Core/ScheduledTime/MonthlyTest.php +++ b/tests/PHPUnit/Core/ScheduledTime/MonthlyTest.php @@ -5,6 +5,8 @@ * @link http://piwik.org * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later */ +use Piwik\ScheduledTime\Monthly; + class ScheduledTime_MonthlyTest extends PHPUnit_Framework_TestCase { private static $_JANUARY_01_1971_09_00_00; @@ -32,7 +34,7 @@ class ScheduledTime_MonthlyTest extends PHPUnit_Framework_TestCase } /** - * Tests invalid call to setHour on Piwik_ScheduledTime_Monthly + * Tests invalid call to setHour on Monthly * @group Core * @group ScheduledTime * @group ScheduledTime_Monthly @@ -40,7 +42,7 @@ class ScheduledTime_MonthlyTest extends PHPUnit_Framework_TestCase public function testSetHourScheduledTimeMonthlyNegative() { try { - $monthlySchedule = new Piwik_ScheduledTime_Monthly(); + $monthlySchedule = new Monthly(); $monthlySchedule->setHour(-1); } catch (Exception $e) { return; @@ -49,7 +51,7 @@ class ScheduledTime_MonthlyTest extends PHPUnit_Framework_TestCase } /** - * Tests invalid call to setHour on Piwik_ScheduledTime_Monthly + * Tests invalid call to setHour on Monthly * @group Core * @group ScheduledTime * @group ScheduledTime_Monthly @@ -57,7 +59,7 @@ class ScheduledTime_MonthlyTest extends PHPUnit_Framework_TestCase public function testSetHourScheduledTimMonthlyOver24() { try { - $monthlySchedule = new Piwik_ScheduledTime_Monthly(); + $monthlySchedule = new Monthly(); $monthlySchedule->setHour(25); } catch (Exception $e) { return; @@ -66,7 +68,7 @@ class ScheduledTime_MonthlyTest extends PHPUnit_Framework_TestCase } /** - * Tests invalid call to setDay on Piwik_ScheduledTime_Monthly + * Tests invalid call to setDay on Monthly * @group Core * @group ScheduledTime * @group ScheduledTime_Monthly @@ -74,7 +76,7 @@ class ScheduledTime_MonthlyTest extends PHPUnit_Framework_TestCase public function testSetDayScheduledTimeMonthlyDay0() { try { - $monthlySchedule = new Piwik_ScheduledTime_Monthly(); + $monthlySchedule = new Monthly(); $monthlySchedule->setDay(0); } catch (Exception $e) { return; @@ -83,7 +85,7 @@ class ScheduledTime_MonthlyTest extends PHPUnit_Framework_TestCase } /** - * Tests invalid call to setDay on Piwik_ScheduledTime_Monthly + * Tests invalid call to setDay on Monthly * @group Core * @group ScheduledTime * @group ScheduledTime_Monthly @@ -91,7 +93,7 @@ class ScheduledTime_MonthlyTest extends PHPUnit_Framework_TestCase public function testSetDayScheduledTimeMonthlyOver31() { try { - $monthlySchedule = new Piwik_ScheduledTime_Monthly(); + $monthlySchedule = new Monthly(); $monthlySchedule->setDay(32); } catch (Exception $e) { return; @@ -100,7 +102,7 @@ class ScheduledTime_MonthlyTest extends PHPUnit_Framework_TestCase } /** - * Tests getRescheduledTime on Piwik_ScheduledTime_Monthly with unspecified hour and unspecified day + * Tests getRescheduledTime on Monthly with unspecified hour and unspecified day * @group Core * @group ScheduledTime * @group ScheduledTime_Monthly @@ -118,7 +120,7 @@ class ScheduledTime_MonthlyTest extends PHPUnit_Framework_TestCase * Expected : * getRescheduledTime returns Monday February 1 1971 00:00:00 UTC */ - $mock = $this->getMock('Piwik_ScheduledTime_Monthly', array('getTime')); + $mock = $this->getMock('\Piwik\ScheduledTime\Monthly', array('getTime')); $mock->expects($this->any()) ->method('getTime') ->will($this->returnValue(self::$_JANUARY_01_1971_09_00_00)); @@ -135,7 +137,7 @@ class ScheduledTime_MonthlyTest extends PHPUnit_Framework_TestCase * Expected : * getRescheduledTime returns Monday February 1 1971 00:00:00 UTC */ - $mock = $this->getMock('Piwik_ScheduledTime_Monthly', array('getTime')); + $mock = $this->getMock('\Piwik\ScheduledTime\Monthly', array('getTime')); $mock->expects($this->any()) ->method('getTime') ->will($this->returnValue(self::$_JANUARY_05_1971_09_00_00)); @@ -144,7 +146,7 @@ class ScheduledTime_MonthlyTest extends PHPUnit_Framework_TestCase /** - * Tests getRescheduledTime on Piwik_ScheduledTime_Monthly with unspecified hour and specified day + * Tests getRescheduledTime on Monthly with unspecified hour and specified day * @group Core * @group ScheduledTime * @group ScheduledTime_Monthly @@ -153,7 +155,7 @@ class ScheduledTime_MonthlyTest extends PHPUnit_Framework_TestCase */ public function testGetRescheduledTimeMonthlyUnspecifiedHourSpecifiedDay($currentTime, $day, $expected) { - $mock = $this->getMock('Piwik_ScheduledTime_Monthly', array('getTime')); + $mock = $this->getMock('\Piwik\ScheduledTime\Monthly', array('getTime')); $mock->expects($this->any()) ->method('getTime') ->will($this->returnValue(self::$$currentTime)); @@ -226,7 +228,7 @@ class ScheduledTime_MonthlyTest extends PHPUnit_Framework_TestCase */ public function testMonthlyDayOfWeek() { - $mock = $this->getMock('Piwik_ScheduledTime_Monthly', array('getTime')); + $mock = $this->getMock('\Piwik\ScheduledTime\Monthly', array('getTime')); $mock->expects($this->any()) ->method('getTime') ->will($this->returnValue(self::$_JANUARY_15_1971_09_00_00)); @@ -246,7 +248,7 @@ class ScheduledTime_MonthlyTest extends PHPUnit_Framework_TestCase */ public function testMonthlyDayOfWeekInvalid($day, $week) { - $mock = $this->getMock('Piwik_ScheduledTime_Monthly', array('getTime')); + $mock = $this->getMock('\Piwik\ScheduledTime\Monthly', array('getTime')); $mock->expects($this->any()) ->method('getTime') ->will($this->returnValue(self::$_JANUARY_15_1971_09_00_00)); diff --git a/tests/PHPUnit/Core/ScheduledTime/WeeklyTest.php b/tests/PHPUnit/Core/ScheduledTime/WeeklyTest.php index 6812bc90c0..a5a6913db1 100644 --- a/tests/PHPUnit/Core/ScheduledTime/WeeklyTest.php +++ b/tests/PHPUnit/Core/ScheduledTime/WeeklyTest.php @@ -5,6 +5,8 @@ * @link http://piwik.org * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later */ +use Piwik\ScheduledTime\Weekly; + class ScheduledTime_WeeklyTest extends PHPUnit_Framework_TestCase { private static $_JANUARY_01_1971_09_10_00; @@ -26,7 +28,7 @@ class ScheduledTime_WeeklyTest extends PHPUnit_Framework_TestCase } /** - * Tests invalid call to setHour on Piwik_ScheduledTime_Weekly + * Tests invalid call to setHour on Weekly * @group Core * @group ScheduledTime * @group ScheduledTime_Weekly @@ -34,7 +36,7 @@ class ScheduledTime_WeeklyTest extends PHPUnit_Framework_TestCase public function testSetHourScheduledTimeWeeklyNegative() { try { - $weeklySchedule = new Piwik_ScheduledTime_Weekly(); + $weeklySchedule = new Weekly(); $weeklySchedule->setHour(-1); } catch (Exception $e) { return; @@ -43,7 +45,7 @@ class ScheduledTime_WeeklyTest extends PHPUnit_Framework_TestCase } /** - * Tests invalid call to setHour on Piwik_ScheduledTime_Weekly + * Tests invalid call to setHour on Weekly * @group Core * @group ScheduledTime * @group ScheduledTime_Weekly @@ -51,7 +53,7 @@ class ScheduledTime_WeeklyTest extends PHPUnit_Framework_TestCase public function testSetHourScheduledTimeWeeklyOver24() { try { - $weeklySchedule = new Piwik_ScheduledTime_Weekly(); + $weeklySchedule = new Weekly(); $weeklySchedule->setHour(25); } catch (Exception $e) { return; @@ -60,7 +62,7 @@ class ScheduledTime_WeeklyTest extends PHPUnit_Framework_TestCase } /** - * Tests invalid call to setDay on Piwik_ScheduledTime_Weekly + * Tests invalid call to setDay on Weekly * @group Core * @group ScheduledTime * @group ScheduledTime_Weekly @@ -68,7 +70,7 @@ class ScheduledTime_WeeklyTest extends PHPUnit_Framework_TestCase public function testSetDayScheduledTimeWeeklyDay0() { try { - $weeklySchedule = new Piwik_ScheduledTime_Weekly(); + $weeklySchedule = new Weekly(); $weeklySchedule->setDay(0); } catch (Exception $e) { return; @@ -77,7 +79,7 @@ class ScheduledTime_WeeklyTest extends PHPUnit_Framework_TestCase } /** - * Tests invalid call to setDay on Piwik_ScheduledTime_Weekly + * Tests invalid call to setDay on Weekly * @group Core * @group ScheduledTime * @group ScheduledTime_Weekly @@ -85,7 +87,7 @@ class ScheduledTime_WeeklyTest extends PHPUnit_Framework_TestCase public function testSetDayScheduledTimeWeeklyOver7() { try { - $weeklySchedule = new Piwik_ScheduledTime_Weekly(); + $weeklySchedule = new Weekly(); $weeklySchedule->setDay(8); } catch (Exception $e) { return; @@ -94,7 +96,7 @@ class ScheduledTime_WeeklyTest extends PHPUnit_Framework_TestCase } /** - * Tests getRescheduledTime on Piwik_ScheduledTime_Weekly with unspecified hour and unspecified day + * Tests getRescheduledTime on Weekly with unspecified hour and unspecified day * @group Core * @group ScheduledTime * @group ScheduledTime_Weekly @@ -112,7 +114,7 @@ class ScheduledTime_WeeklyTest extends PHPUnit_Framework_TestCase * Expected : * getRescheduledTime returns Monday January 4 1971 00:00:00 UTC */ - $mock = $this->getMock('Piwik_ScheduledTime_Weekly', array('getTime')); + $mock = $this->getMock('\Piwik\ScheduledTime\Weekly', array('getTime')); $mock->expects($this->any()) ->method('getTime') ->will($this->returnValue(self::$_JANUARY_01_1971_09_10_00)); @@ -120,7 +122,7 @@ class ScheduledTime_WeeklyTest extends PHPUnit_Framework_TestCase } /** - * Tests getRescheduledTime on Piwik_ScheduledTime_Weekly with specified hour and unspecified day + * Tests getRescheduledTime on Weekly with specified hour and unspecified day * @group Core * @group ScheduledTime * @group ScheduledTime_Weekly @@ -138,7 +140,7 @@ class ScheduledTime_WeeklyTest extends PHPUnit_Framework_TestCase * Expected : * getRescheduledTime returns Monday January 4 1971 09:00:00 UTC */ - $mock = $this->getMock('Piwik_ScheduledTime_Weekly', array('getTime')); + $mock = $this->getMock('\Piwik\ScheduledTime\Weekly', array('getTime')); $mock->expects($this->any()) ->method('getTime') ->will($this->returnValue(self::$_JANUARY_01_1971_09_10_00)); @@ -147,7 +149,7 @@ class ScheduledTime_WeeklyTest extends PHPUnit_Framework_TestCase } /** - * Tests getRescheduledTime on Piwik_ScheduledTime_Weekly with unspecified hour and specified day + * Tests getRescheduledTime on Weekly with unspecified hour and specified day * @group Core * @group ScheduledTime * @group ScheduledTime_Weekly @@ -165,7 +167,7 @@ class ScheduledTime_WeeklyTest extends PHPUnit_Framework_TestCase * Expected : * getRescheduledTime returns Monday January 11 1971 00:00:00 UTC */ - $mock = $this->getMock('Piwik_ScheduledTime_Weekly', array('getTime')); + $mock = $this->getMock('\Piwik\ScheduledTime\Weekly', array('getTime')); $mock->expects($this->any()) ->method('getTime') ->will($this->returnValue(self::$_JANUARY_04_1971_09_00_00)); @@ -183,7 +185,7 @@ class ScheduledTime_WeeklyTest extends PHPUnit_Framework_TestCase * Expected : * getRescheduledTime returns Monday January 11 1971 00:00:00 UTC */ - $mock = $this->getMock('Piwik_ScheduledTime_Weekly', array('getTime')); + $mock = $this->getMock('\Piwik\ScheduledTime\Weekly', array('getTime')); $mock->expects($this->any()) ->method('getTime') ->will($this->returnValue(self::$_JANUARY_05_1971_09_00_00)); @@ -201,7 +203,7 @@ class ScheduledTime_WeeklyTest extends PHPUnit_Framework_TestCase * Expected : * getRescheduledTime returns Friday January 15 1971 00:00:00 UTC */ - $mock = $this->getMock('Piwik_ScheduledTime_Weekly', array('getTime')); + $mock = $this->getMock('\Piwik\ScheduledTime\Weekly', array('getTime')); $mock->expects($this->any()) ->method('getTime') ->will($this->returnValue(self::$_JANUARY_04_1971_09_00_00)); diff --git a/tests/PHPUnit/Core/TaskSchedulerTest.php b/tests/PHPUnit/Core/TaskSchedulerTest.php index 88db5b2db4..ae6a80ba4b 100644 --- a/tests/PHPUnit/Core/TaskSchedulerTest.php +++ b/tests/PHPUnit/Core/TaskSchedulerTest.php @@ -6,6 +6,7 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later */ use Piwik\EventDispatcher; +use Piwik\ScheduledTime\Daily; use Piwik\TaskScheduler; use Piwik\ScheduledTask; @@ -179,7 +180,7 @@ class TaskSchedulerTest extends PHPUnit_Framework_TestCase $this->assertNotEmpty($executeTask->invoke( new TaskScheduler(), - new ScheduledTask ($mock, $methodName, $parameterValue, new Piwik_ScheduledTime_Daily()) + new ScheduledTask ($mock, $methodName, $parameterValue, new Daily()) )); } @@ -190,7 +191,7 @@ class TaskSchedulerTest extends PHPUnit_Framework_TestCase { $systemTime = time(); - $dailySchedule = $this->getMock('Piwik_ScheduledTime_Daily', array('getTime')); + $dailySchedule = $this->getMock('\Piwik\ScheduledTime\Daily', array('getTime')); $dailySchedule->expects($this->any()) ->method('getTime') ->will($this->returnValue($systemTime)); diff --git a/tests/PHPUnit/Core/Tracker/ActionTest.php b/tests/PHPUnit/Core/Tracker/ActionTest.php index 95a8fee7b4..f04bfafea5 100644 --- a/tests/PHPUnit/Core/Tracker/ActionTest.php +++ b/tests/PHPUnit/Core/Tracker/ActionTest.php @@ -1,6 +1,8 @@ assertEquals($filteredUrl[0], Piwik_Tracker_Action::excludeQueryParametersFromUrl($url, $idSite)); + $this->assertEquals($filteredUrl[0], Action::excludeQueryParametersFromUrl($url, $idSite)); } public function getTestUrlsHashtag() @@ -140,7 +142,7 @@ class Tracker_ActionTest extends DatabaseTestCase */ public function testRemoveTrailingHashtag($url, $expectedUrl) { - $this->assertEquals(Piwik_Tracker_Action::reconstructNormalizedUrl($url, Piwik_Tracker_Action::$urlPrefixMap['http://']), $expectedUrl); + $this->assertEquals(Action::reconstructNormalizedUrl($url, Action::$urlPrefixMap['http://']), $expectedUrl); } @@ -159,7 +161,7 @@ class Tracker_ActionTest extends DatabaseTestCase $siteSearch = 1, $searchKeywordParameters = null, $searchCategoryParameters = null, $excludedIps = '', $excludedQueryParameters, $timezone = null, $currency = null, $group = null, $startDate = null, $excludedUserAgents = null, $keepURLFragments = 1); - $this->assertEquals($filteredUrl[1], Piwik_Tracker_Action::excludeQueryParametersFromUrl($url, $idSite)); + $this->assertEquals($filteredUrl[1], Action::excludeQueryParametersFromUrl($url, $idSite)); } /** @@ -180,7 +182,7 @@ class Tracker_ActionTest extends DatabaseTestCase $excludedIps = '', $excludedQueryParameters, $timezone = null, $currency = null, $group = null, $startDate = null, $excludedUserAgents = null, $keepURLFragments = 1); Piwik_SitesManager_API::getInstance()->setGlobalExcludedQueryParameters($excludedGlobalParameters); - $this->assertEquals($filteredUrl[1], Piwik_Tracker_Action::excludeQueryParametersFromUrl($url, $idSite)); + $this->assertEquals($filteredUrl[1], Action::excludeQueryParametersFromUrl($url, $idSite)); } @@ -192,21 +194,21 @@ class Tracker_ActionTest extends DatabaseTestCase 'request' => array('link' => 'http://example.org'), 'expected' => array('name' => null, 'url' => 'http://example.org', - 'type' => Piwik_Tracker_Action::TYPE_OUTLINK), + 'type' => Action::TYPE_OUTLINK), ), // outlinks with custom name array( 'request' => array('link' => 'http://example.org', 'action_name' => 'Example.org'), 'expected' => array('name' => 'Example.org', 'url' => 'http://example.org', - 'type' => Piwik_Tracker_Action::TYPE_OUTLINK), + 'type' => Action::TYPE_OUTLINK), ), // keep the case in urls, but trim array( 'request' => array('link' => ' http://example.org/Category/Test/ '), 'expected' => array('name' => null, 'url' => 'http://example.org/Category/Test/', - 'type' => Piwik_Tracker_Action::TYPE_OUTLINK), + 'type' => Action::TYPE_OUTLINK), ), // trim the custom name @@ -214,7 +216,7 @@ class Tracker_ActionTest extends DatabaseTestCase 'request' => array('link' => ' http://example.org/Category/Test/ ', 'action_name' => ' Example dot org '), 'expected' => array('name' => 'Example dot org', 'url' => 'http://example.org/Category/Test/', - 'type' => Piwik_Tracker_Action::TYPE_OUTLINK), + 'type' => Action::TYPE_OUTLINK), ), // downloads @@ -222,7 +224,7 @@ class Tracker_ActionTest extends DatabaseTestCase 'request' => array('download' => 'http://example.org/*$test.zip'), 'expected' => array('name' => null, 'url' => 'http://example.org/*$test.zip', - 'type' => Piwik_Tracker_Action::TYPE_DOWNLOAD), + 'type' => Action::TYPE_DOWNLOAD), ), // downloads with custom name @@ -230,7 +232,7 @@ class Tracker_ActionTest extends DatabaseTestCase 'request' => array('download' => 'http://example.org/*$test.zip', 'action_name' => 'Download test.zip'), 'expected' => array('name' => 'Download test.zip', 'url' => 'http://example.org/*$test.zip', - 'type' => Piwik_Tracker_Action::TYPE_DOWNLOAD), + 'type' => Action::TYPE_DOWNLOAD), ), // keep the case and multiple / in urls @@ -238,7 +240,7 @@ class Tracker_ActionTest extends DatabaseTestCase 'request' => array('download' => 'http://example.org/CATEGORY/test///test.pdf'), 'expected' => array('name' => null, 'url' => 'http://example.org/CATEGORY/test///test.pdf', - 'type' => Piwik_Tracker_Action::TYPE_DOWNLOAD), + 'type' => Action::TYPE_DOWNLOAD), ), // page view @@ -246,71 +248,71 @@ class Tracker_ActionTest extends DatabaseTestCase 'request' => array('url' => 'http://example.org/'), 'expected' => array('name' => null, 'url' => 'http://example.org/', - 'type' => Piwik_Tracker_Action::TYPE_ACTION_URL), + 'type' => Action::TYPE_ACTION_URL), ), array( 'request' => array('url' => 'http://example.org/', 'action_name' => 'Example.org Website'), 'expected' => array('name' => 'Example.org Website', 'url' => 'http://example.org/', - 'type' => Piwik_Tracker_Action::TYPE_ACTION_URL), + 'type' => Action::TYPE_ACTION_URL), ), array( 'request' => array('url' => 'http://example.org/CATEGORY/'), 'expected' => array('name' => null, 'url' => 'http://example.org/CATEGORY/', - 'type' => Piwik_Tracker_Action::TYPE_ACTION_URL), + 'type' => Action::TYPE_ACTION_URL), ), array( 'request' => array('url' => 'http://example.org/CATEGORY/TEST', 'action_name' => 'Example.org / Category / test /'), 'expected' => array('name' => 'Example.org/Category/test', 'url' => 'http://example.org/CATEGORY/TEST', - 'type' => Piwik_Tracker_Action::TYPE_ACTION_URL), + 'type' => Action::TYPE_ACTION_URL), ), array( 'request' => array('url' => 'http://example.org/?2,123'), 'expected' => array('name' => null, 'url' => 'http://example.org/?2,123', - 'type' => Piwik_Tracker_Action::TYPE_ACTION_URL), + 'type' => Action::TYPE_ACTION_URL), ), // empty request array( 'request' => array(), 'expected' => array('name' => null, 'url' => '', - 'type' => Piwik_Tracker_Action::TYPE_ACTION_URL), + 'type' => Action::TYPE_ACTION_URL), ), array( 'request' => array('name' => null, 'url' => "\n"), 'expected' => array('name' => null, 'url' => '', - 'type' => Piwik_Tracker_Action::TYPE_ACTION_URL), + 'type' => Action::TYPE_ACTION_URL), ), array( 'request' => array('url' => 'http://example.org/category/', 'action_name' => 'custom name with/one delimiter/two delimiters/'), 'expected' => array('name' => 'custom name with/one delimiter/two delimiters', 'url' => 'http://example.org/category/', - 'type' => Piwik_Tracker_Action::TYPE_ACTION_URL), + 'type' => Action::TYPE_ACTION_URL), ), array( 'request' => array('url' => 'http://example.org/category/', 'action_name' => 'http://custom action name look like url/'), 'expected' => array('name' => 'http:/custom action name look like url', 'url' => 'http://example.org/category/', - 'type' => Piwik_Tracker_Action::TYPE_ACTION_URL), + 'type' => Action::TYPE_ACTION_URL), ), // testing: delete tab, trimmed, not strtolowered array( 'request' => array('url' => "http://example.org/category/test///test wOw "), 'expected' => array('name' => null, 'url' => 'http://example.org/category/test///test wOw', - 'type' => Piwik_Tracker_Action::TYPE_ACTION_URL), + 'type' => Action::TYPE_ACTION_URL), ), // testing: inclusion of zero values in action name array( 'request' => array('url' => "http://example.org/category/1/0/t/test"), 'expected' => array('name' => null, 'url' => 'http://example.org/category/1/0/t/test', - 'type' => Piwik_Tracker_Action::TYPE_ACTION_URL), + 'type' => Action::TYPE_ACTION_URL), ), // testing: action name ("Test …") - expect decoding of some html entities array( @@ -318,7 +320,7 @@ class Tracker_ActionTest extends DatabaseTestCase 'action_name' => "Test …"), 'expected' => array('name' => 'Test …', 'url' => 'http://example.org/ACTION/URL', - 'type' => Piwik_Tracker_Action::TYPE_ACTION_URL), + 'type' => Action::TYPE_ACTION_URL), ), // testing: action name ("Special & chars") - expect no conversion of html special chars array( @@ -326,7 +328,7 @@ class Tracker_ActionTest extends DatabaseTestCase 'action_name' => "Special & chars"), 'expected' => array('name' => 'Special & chars', 'url' => 'http://example.org/ACTION/URL', - 'type' => Piwik_Tracker_Action::TYPE_ACTION_URL), + 'type' => Action::TYPE_ACTION_URL), ), // testing: action name ("Tést") - handle wide character array( @@ -334,7 +336,7 @@ class Tracker_ActionTest extends DatabaseTestCase 'action_name' => "Tést"), 'expected' => array('name' => 'Tést', 'url' => 'http://example.org/ACTION/URL', - 'type' => Piwik_Tracker_Action::TYPE_ACTION_URL), + 'type' => Action::TYPE_ACTION_URL), ), // testing: action name ("Tést") - handle UTF-8 byte sequence array( @@ -342,7 +344,7 @@ class Tracker_ActionTest extends DatabaseTestCase 'action_name' => "T\xc3\xa9st"), 'expected' => array('name' => 'Tést', 'url' => 'http://example.org/ACTION/URL', - 'type' => Piwik_Tracker_Action::TYPE_ACTION_URL), + 'type' => Action::TYPE_ACTION_URL), ), // testing: action name ("Tést") - invalid UTF-8 (e.g., ISO-8859-1) is not handled array( @@ -350,7 +352,7 @@ class Tracker_ActionTest extends DatabaseTestCase 'action_name' => "T\xe9st"), 'expected' => array('name' => version_compare(PHP_VERSION, '5.2.5') === -1 ? 'T\xe9st' : 'Tést', 'url' => 'http://example.org/ACTION/URL', - 'type' => Piwik_Tracker_Action::TYPE_ACTION_URL), + 'type' => Action::TYPE_ACTION_URL), ), ); } @@ -366,14 +368,14 @@ class Tracker_ActionTest extends DatabaseTestCase $this->setUpRootAccess(); $idSite = Piwik_SitesManager_API::getInstance()->addSite("site1", array('http://example.org')); $request['idsite'] = $idSite; - $request = new Piwik_Tracker_Request($request); + $request = new Request($request); $action = new Test_Piwik_TrackerAction_extractUrlAndActionNameFromRequest($request); $this->assertEquals($action->public_extractUrlAndActionNameFromRequest(), $expected); } } -class Test_Piwik_TrackerAction_extractUrlAndActionNameFromRequest extends Piwik_Tracker_Action +class Test_Piwik_TrackerAction_extractUrlAndActionNameFromRequest extends Action { public function public_extractUrlAndActionNameFromRequest() { diff --git a/tests/PHPUnit/Core/Tracker/VisitTest.php b/tests/PHPUnit/Core/Tracker/VisitTest.php index 23eed1d310..dd5490f2ff 100644 --- a/tests/PHPUnit/Core/Tracker/VisitTest.php +++ b/tests/PHPUnit/Core/Tracker/VisitTest.php @@ -7,6 +7,8 @@ */ use Piwik\Access; use Piwik\IP; +use Piwik\Tracker\VisitExcluded; +use Piwik\Tracker\Request; class Tracker_VisitTest extends DatabaseTestCase { @@ -75,13 +77,13 @@ class Tracker_VisitTest extends DatabaseTestCase $idsite = Piwik_SitesManager_API::getInstance()->addSite("name", "http://piwik.net/", $ecommerce = 0, $siteSearch = 1, $searchKeywordParameters = null, $searchCategoryParameters = null, $excludedIp); - $request = new Piwik_Tracker_Request(array('idsite' => $idsite)); + $request = new Request(array('idsite' => $idsite)); // test that IPs within the range, or the given IP, are excluded foreach ($tests as $ip => $expected) { $testIpIsExcluded = IP::P2N($ip); - $excluded = new Test_Piwik_Tracker_VisitExcluded_public($request, $testIpIsExcluded); + $excluded = new VisitExcluded_public($request, $testIpIsExcluded); $this->assertSame($expected, $excluded->public_isVisitorIpExcluded($testIpIsExcluded)); } } @@ -126,18 +128,18 @@ class Tracker_VisitTest extends DatabaseTestCase $excludedQueryParameters = null, $timezone = null, $currency = null, $group = null, $startDate = null, $excludedUserAgent); - $request = new Piwik_Tracker_Request(array('idsite' => $idsite)); + $request = new Request(array('idsite' => $idsite)); // test that user agents that contain excluded user agent strings are excluded foreach ($tests as $ua => $expected) { - $excluded = new Test_Piwik_Tracker_VisitExcluded_public($request, $ip = false, $ua); + $excluded = new VisitExcluded_public($request, $ip = false, $ua); $this->assertSame($expected, $excluded->public_isUserAgentExcluded($ua), "Result if isUserAgentExcluded('$ua') was not " . ($expected ? 'true' : 'false') . "."); } } } -class Test_Piwik_Tracker_VisitExcluded_public extends Piwik_Tracker_VisitExcluded +class VisitExcluded_public extends VisitExcluded { public function public_isVisitorIpExcluded($ip) { diff --git a/tests/PHPUnit/Core/UnzipTest.php b/tests/PHPUnit/Core/UnzipTest.php index 221c420991..a0865e6e46 100644 --- a/tests/PHPUnit/Core/UnzipTest.php +++ b/tests/PHPUnit/Core/UnzipTest.php @@ -6,6 +6,10 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later */ use Piwik\Unzip; +use Piwik\Unzip\Gzip; +use Piwik\Unzip\PclZip; +use Piwik\Unzip\ZipArchive; +use Piwik\Unzip\Tar; class UnzipTest extends PHPUnit_Framework_TestCase { @@ -29,7 +33,7 @@ class UnzipTest extends PHPUnit_Framework_TestCase $this->assertFileNotExists(dirname(__FILE__) . '/../../tests/' . $test . '.txt'); unlink($extractDir . $test . '.txt'); - $unzip = new Piwik_Unzip_ZipArchive($filename); + $unzip = new ZipArchive($filename); $res = $unzip->extract($extractDir); $this->assertEquals(1, count($res)); $this->assertFileExists($extractDir . $test . '.txt'); @@ -46,7 +50,7 @@ class UnzipTest extends PHPUnit_Framework_TestCase $this->assertFileNotExists(dirname(__FILE__) . '/../../tests/' . $test . '.txt'); unlink($extractDir . $test . '.txt'); - $unzip = new Piwik_Unzip_PclZip($filename); + $unzip = new PclZip($filename); $res = $unzip->extract($extractDir); $this->assertEquals(1, count($res)); $this->assertFileExists($extractDir . $test . '.txt'); @@ -67,7 +71,7 @@ class UnzipTest extends PHPUnit_Framework_TestCase $filename = dirname(__FILE__) . '/Unzip/' . $test . '.zip'; if (class_exists('ZipArchive', false)) { - $unzip = new Piwik_Unzip_ZipArchive($filename); + $unzip = new ZipArchive($filename); $res = $unzip->extract($extractDir); $this->assertEquals(0, $res); $this->assertFileNotExists($extractDir . $test . '.txt'); @@ -77,7 +81,7 @@ class UnzipTest extends PHPUnit_Framework_TestCase $this->assertFileNotExists(dirname(__FILE__) . '/../../' . $test . '.txt'); } - $unzip = new Piwik_Unzip_PclZip($filename); + $unzip = new PclZip($filename); $res = $unzip->extract($extractDir); $this->assertEquals(0, $res); $this->assertFileNotExists($extractDir . $test . '.txt'); @@ -99,14 +103,14 @@ class UnzipTest extends PHPUnit_Framework_TestCase $filename = dirname(__FILE__) . '/Unzip/' . $test . '.zip'; if (class_exists('ZipArchive', false)) { - $unzip = new Piwik_Unzip_ZipArchive($filename); + $unzip = new ZipArchive($filename); $res = $unzip->extract($extractDir); $this->assertEquals(0, $res); $this->assertFileNotExists($extractDir . $test . '.txt'); $this->assertFileNotExists(dirname(__FILE__) . '/' . $test . '.txt'); } - $unzip = new Piwik_Unzip_PclZip($filename); + $unzip = new PclZip($filename); $res = $unzip->extract($extractDir); $this->assertEquals(0, $res); $this->assertFileNotExists($extractDir . $test . '.txt'); @@ -123,7 +127,7 @@ class UnzipTest extends PHPUnit_Framework_TestCase $filename = dirname(__FILE__) . '/Unzip/zaabs.zip'; $extractDir = PIWIK_USER_PATH . '/tmp/latest/'; - $unzip = new Piwik_Unzip_ZipArchive($filename); + $unzip = new ZipArchive($filename); $this->assertContains('No error', $unzip->errorInfo()); } @@ -137,7 +141,7 @@ class UnzipTest extends PHPUnit_Framework_TestCase $filename = dirname(__FILE__) . '/Unzip/empty.zip'; $extractDir = PIWIK_USER_PATH . '/tmp/latest/'; - $unzip = new Piwik_Unzip_ZipArchive($filename); + $unzip = new ZipArchive($filename); $res = $unzip->extract($extractDir); $this->assertEquals(0, $res); } @@ -152,7 +156,7 @@ class UnzipTest extends PHPUnit_Framework_TestCase $filename = dirname(__FILE__) . '/Unzip/NotExisting.zip'; try { - $unzip = new Piwik_Unzip_ZipArchive($filename); + $unzip = new ZipArchive($filename); } catch (Exception $e) { return; } @@ -169,7 +173,7 @@ class UnzipTest extends PHPUnit_Framework_TestCase $extractDir = PIWIK_USER_PATH . '/tmp/latest/'; $filename = dirname(__FILE__) . '/Unzip/NotExisting.zip'; - $unzip = new Piwik_Unzip_PclZip($filename); + $unzip = new PclZip($filename); $res = $unzip->extract($extractDir); $this->assertEquals(0, $res); @@ -186,7 +190,7 @@ class UnzipTest extends PHPUnit_Framework_TestCase $extractFile = $extractDir . 'testgz.txt'; $filename = dirname(__FILE__) . '/Unzip/test.gz'; - $unzip = new Piwik_Unzip_Gzip($filename); + $unzip = new Gzip($filename); $res = $unzip->extract($extractFile); $this->assertTrue($res); @@ -202,7 +206,7 @@ class UnzipTest extends PHPUnit_Framework_TestCase $extractDir = PIWIK_USER_PATH . '/tmp/latest/'; $filename = dirname(__FILE__) . '/Unzip/test.tar.gz'; - $unzip = new Piwik_Unzip_Tar($filename, 'gz'); + $unzip = new Tar($filename, 'gz'); $res = $unzip->extract($extractDir); $this->assertTrue($res); diff --git a/tests/PHPUnit/Core/UrlTest.php b/tests/PHPUnit/Core/UrlTest.php index 12fb22033c..334edef1ca 100644 --- a/tests/PHPUnit/Core/UrlTest.php +++ b/tests/PHPUnit/Core/UrlTest.php @@ -116,7 +116,7 @@ class UrlTest extends PHPUnit_Framework_TestCase // mangled HTTP_HOST array('www.example.com', 'http://example.com/path/#anchor', '/path/index.php', 'http://example.com/path/referrer', true), - // suppressed Referer + // suppressed Referrer array('www.example.com', 'http://www.example.com/path/#anchor', '/path/index.php', null, true), array('www.example.com', 'http://www.example.com/path/#anchor', '/path/index.php', '', true), diff --git a/tests/PHPUnit/DatabaseTestCase.php b/tests/PHPUnit/DatabaseTestCase.php index b2144d5c15..47a34f8bbe 100644 --- a/tests/PHPUnit/DatabaseTestCase.php +++ b/tests/PHPUnit/DatabaseTestCase.php @@ -11,6 +11,7 @@ use Piwik\DataTable\Manager; use Piwik\Piwik; use Piwik\Option; use Piwik\Site; +use Piwik\Tracker\Cache; /** * Tests extending DatabaseTestCase are much slower to run: the setUp will @@ -72,7 +73,7 @@ class DatabaseTestCase extends PHPUnit_Framework_TestCase Option::getInstance()->clearCache(); Piwik_PDFReports_API::$cache = array(); Site::clearCache(); - Piwik_Tracker_Cache::deleteTrackerCache(); + Cache::deleteTrackerCache(); Config::getInstance()->clear(); ArchiveTableCreator::clear(); \Zend_Registry::_unsetInstance(); diff --git a/tests/PHPUnit/Fixtures/FewVisitsWithSetVisitorId.php b/tests/PHPUnit/Fixtures/FewVisitsWithSetVisitorId.php index b1f7828610..2284a14aa9 100644 --- a/tests/PHPUnit/Fixtures/FewVisitsWithSetVisitorId.php +++ b/tests/PHPUnit/Fixtures/FewVisitsWithSetVisitorId.php @@ -6,6 +6,7 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later */ use Piwik\Date; +use Piwik\Tracker\Visit; /** * Adds one site and tracks a couple visits using a custom visitor ID. @@ -44,14 +45,14 @@ class Test_Piwik_Fixture_FewVisitsWithSetVisitorId extends Test_Piwik_BaseFixtur // We create VISITOR A $t->setUrl('http://example.org/index.htm'); - $t->setVisitorId(Piwik_Tracker_Visit::generateUniqueVisitorId()); + $t->setVisitorId(Visit::generateUniqueVisitorId()); self::checkResponse($t->doTrackPageView('incredible title!')); // VISITOR B: few minutes later, we trigger the same tracker but with a custom visitor ID, // => this will create a new visit B $t->setForceVisitDateTime(Date::factory($dateTime)->addHour(0.05)->getDatetime()); $t->setUrl('http://example.org/index2.htm'); - $t->setVisitorId(Piwik_Tracker_Visit::generateUniqueVisitorId()); + $t->setVisitorId(Visit::generateUniqueVisitorId()); self::checkResponse($t->doTrackPageView('incredible title!')); // This new visit B will have 2 page views diff --git a/tests/PHPUnit/Integration/TwoVisitsWithCustomVariables_SegmentMatchVisitorTypeTest.php b/tests/PHPUnit/Integration/TwoVisitsWithCustomVariables_SegmentMatchVisitorTypeTest.php index 1fc9dfe5aa..4e6b18cbfc 100755 --- a/tests/PHPUnit/Integration/TwoVisitsWithCustomVariables_SegmentMatchVisitorTypeTest.php +++ b/tests/PHPUnit/Integration/TwoVisitsWithCustomVariables_SegmentMatchVisitorTypeTest.php @@ -80,7 +80,7 @@ class Test_Piwik_Integration_TwoVisitsWithCustomVariables_SegmentMatchVisitorTyp // We expect 2 segments * (1 custom variable name + 2 ref metrics + 6 subtable for the values of the name + 5 referers blob) 'archive_blob_2009_12' => 30, // 6 metrics, - // 2 Referer metrics (Referers_distinctSearchEngines/Referers_distinctKeywords), + // 2 Referrer metrics (Referers_distinctSearchEngines/Referers_distinctKeywords), // 3 done flag (referers, CustomVar, VisitsSummary), // X * 2 segments 'archive_numeric_2009_12' => (6 + 2 + 3) * 2, diff --git a/tests/PHPUnit/Integration/UrlNormalizationTest.php b/tests/PHPUnit/Integration/UrlNormalizationTest.php index db1931a31e..7e8d4fa7a1 100644 --- a/tests/PHPUnit/Integration/UrlNormalizationTest.php +++ b/tests/PHPUnit/Integration/UrlNormalizationTest.php @@ -1,5 +1,6 @@ assertEquals($expected, $count, "only $expected actions expected"); $sql = "SELECT name, url_prefix FROM " . Common::prefixTable('log_action') - . " WHERE type = " . Piwik_Tracker_Action::TYPE_ACTION_URL + . " WHERE type = " . Action::TYPE_ACTION_URL . " ORDER BY idaction ASC"; $urls = \Zend_Registry::get('db')->fetchAll($sql); $expected = array( diff --git a/tests/PHPUnit/IntegrationTestCase.php b/tests/PHPUnit/IntegrationTestCase.php index 12cbf5574d..0fdb16c32d 100755 --- a/tests/PHPUnit/IntegrationTestCase.php +++ b/tests/PHPUnit/IntegrationTestCase.php @@ -19,6 +19,7 @@ use Piwik\Access; use Piwik\Option; use Piwik\ReportRenderer; use Piwik\Site; +use Piwik\Tracker\Cache; use Piwik\Translate; use Piwik\Db; use Piwik\Visualization\Cloud; @@ -185,7 +186,7 @@ abstract class IntegrationTestCase extends PHPUnit_Framework_TestCase // We need to be SU to create websites for tests Piwik::setUserIsSuperUser(); - Piwik_Tracker_Cache::deleteTrackerCache(); + Cache::deleteTrackerCache(); if ($installPlugins === null) $installPlugins = $createEmptyDatabase; self::installAndLoadPlugins( $installPlugins); @@ -234,7 +235,7 @@ abstract class IntegrationTestCase extends PHPUnit_Framework_TestCase Manager::getInstance()->deleteAll(); Option::getInstance()->clearCache(); Site::clearCache(); - Piwik_Tracker_Cache::deleteTrackerCache(); + Cache::deleteTrackerCache(); Config::getInstance()->clear(); ArchiveTableCreator::clear(); Piwik_PDFReports_API::$cache = array(); diff --git a/tests/PHPUnit/Plugins/ActionsTest.php b/tests/PHPUnit/Plugins/ActionsTest.php index cf89fe5317..c6c3465fa9 100644 --- a/tests/PHPUnit/Plugins/ActionsTest.php +++ b/tests/PHPUnit/Plugins/ActionsTest.php @@ -5,6 +5,7 @@ * @link http://piwik.org * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later */ +use Piwik\Tracker\Action; use Piwik\Translate; require_once 'Actions/Actions.php'; @@ -25,83 +26,83 @@ class ActionsTests extends PHPUnit_Framework_TestCase { return array( array( - 'params' => array('name' => 'http://example.org/', 'type' => Piwik_Tracker_Action::TYPE_ACTION_URL, 'urlPrefix' => null), + 'params' => array('name' => 'http://example.org/', 'type' => Action::TYPE_ACTION_URL, 'urlPrefix' => null), 'expected' => array('/index'), ), array( - 'params' => array('name' => 'example.org/', 'type' => Piwik_Tracker_Action::TYPE_ACTION_URL, 'urlPrefix' => 1), + 'params' => array('name' => 'example.org/', 'type' => Action::TYPE_ACTION_URL, 'urlPrefix' => 1), 'expected' => array('/index'), ), array( - 'params' => array('name' => 'example.org/', 'type' => Piwik_Tracker_Action::TYPE_ACTION_URL, 'urlPrefix' => 2), + 'params' => array('name' => 'example.org/', 'type' => Action::TYPE_ACTION_URL, 'urlPrefix' => 2), 'expected' => array('/index'), ), array( - 'params' => array('name' => 'example.org/', 'type' => Piwik_Tracker_Action::TYPE_ACTION_URL, 'urlPrefix' => 3), + 'params' => array('name' => 'example.org/', 'type' => Action::TYPE_ACTION_URL, 'urlPrefix' => 3), 'expected' => array('/index'), ), array( - 'params' => array('name' => 'example.org/', 'type' => Piwik_Tracker_Action::TYPE_ACTION_URL, 'urlPrefix' => 4), + 'params' => array('name' => 'example.org/', 'type' => Action::TYPE_ACTION_URL, 'urlPrefix' => 4), 'expected' => array('/index'), ), array( - 'params' => array('name' => 'example.org/path/', 'type' => Piwik_Tracker_Action::TYPE_ACTION_URL, 'urlPrefix' => 4), + 'params' => array('name' => 'example.org/path/', 'type' => Action::TYPE_ACTION_URL, 'urlPrefix' => 4), 'expected' => array('path', '/index'), ), array( - 'params' => array('name' => 'example.org/test/path', 'type' => Piwik_Tracker_Action::TYPE_ACTION_URL, 'urlPrefix' => 1), + 'params' => array('name' => 'example.org/test/path', 'type' => Action::TYPE_ACTION_URL, 'urlPrefix' => 1), 'expected' => array('test', '/path'), ), array( - 'params' => array('name' => 'http://example.org/path/', 'type' => Piwik_Tracker_Action::TYPE_ACTION_URL), + 'params' => array('name' => 'http://example.org/path/', 'type' => Action::TYPE_ACTION_URL), 'expected' => array('path', '/index'), ), array( - 'params' => array('name' => 'example.org/test/path', 'type' => Piwik_Tracker_Action::TYPE_ACTION_URL, 'urlPrefix' => 1), + 'params' => array('name' => 'example.org/test/path', 'type' => Action::TYPE_ACTION_URL, 'urlPrefix' => 1), 'expected' => array('test', '/path'), ), array( - 'params' => array('name' => 'Test / Path', 'type' => Piwik_Tracker_Action::TYPE_ACTION_URL), + 'params' => array('name' => 'Test / Path', 'type' => Action::TYPE_ACTION_URL), 'expected' => array('Test', '/Path'), ), array( - 'params' => array('name' => ' Test trim ', 'type' => Piwik_Tracker_Action::TYPE_ACTION_URL), + 'params' => array('name' => ' Test trim ', 'type' => Action::TYPE_ACTION_URL), 'expected' => array('/Test trim'), ), array( - 'params' => array('name' => 'Category / Subcategory', 'type' => Piwik_Tracker_Action::TYPE_ACTION_NAME), + 'params' => array('name' => 'Category / Subcategory', 'type' => Action::TYPE_ACTION_NAME), 'expected' => array('Category', ' Subcategory'), ), array( - 'params' => array('name' => '/path/index.php?var=test', 'type' => Piwik_Tracker_Action::TYPE_ACTION_NAME), + 'params' => array('name' => '/path/index.php?var=test', 'type' => Action::TYPE_ACTION_NAME), 'expected' => array('path', ' index.php?var=test'), ), array( - 'params' => array('name' => 'http://example.org/path/Default.aspx#anchor', 'type' => Piwik_Tracker_Action::TYPE_ACTION_NAME), + 'params' => array('name' => 'http://example.org/path/Default.aspx#anchor', 'type' => Action::TYPE_ACTION_NAME), 'expected' => array('path', ' Default.aspx#anchor'), ), array( - 'params' => array('name' => '', 'type' => Piwik_Tracker_Action::TYPE_ACTION_NAME), + 'params' => array('name' => '', 'type' => Action::TYPE_ACTION_NAME), 'expected' => array('Page Name not defined'), ), array( - 'params' => array('name' => '', 'type' => Piwik_Tracker_Action::TYPE_ACTION_URL), + 'params' => array('name' => '', 'type' => Action::TYPE_ACTION_URL), 'expected' => array('Page URL not defined'), ), array( - 'params' => array('name' => 'http://example.org/download.zip', 'type' => Piwik_Tracker_Action::TYPE_DOWNLOAD), + 'params' => array('name' => 'http://example.org/download.zip', 'type' => Action::TYPE_DOWNLOAD), 'expected' => array('example.org', '/download.zip'), ), array( - 'params' => array('name' => 'http://example.org/download/1/', 'type' => Piwik_Tracker_Action::TYPE_DOWNLOAD), + 'params' => array('name' => 'http://example.org/download/1/', 'type' => Action::TYPE_DOWNLOAD), 'expected' => array('example.org', '/download/1/'), ), array( - 'params' => array('name' => 'http://example.org/link', 'type' => Piwik_Tracker_Action::TYPE_OUTLINK), + 'params' => array('name' => 'http://example.org/link', 'type' => Action::TYPE_OUTLINK), 'expected' => array('example.org', '/link'), ), array( - 'params' => array('name' => 'http://example.org/some/path/', 'type' => Piwik_Tracker_Action::TYPE_OUTLINK), + 'params' => array('name' => 'http://example.org/some/path/', 'type' => Action::TYPE_OUTLINK), 'expected' => array('example.org', '/some/path/'), ), ); diff --git a/tests/PHPUnit/Plugins/PDFReportsTest.php b/tests/PHPUnit/Plugins/PDFReportsTest.php index cc61ddf161..85b32a89c9 100644 --- a/tests/PHPUnit/Plugins/PDFReportsTest.php +++ b/tests/PHPUnit/Plugins/PDFReportsTest.php @@ -8,6 +8,8 @@ use Piwik\Access; use Piwik\ScheduledTime; use Piwik\ScheduledTask; +use Piwik\ScheduledTime\Daily; +use Piwik\ScheduledTime\Monthly; use Piwik\Site; require_once 'PDFReports/PDFReports.php'; @@ -365,16 +367,16 @@ class PDFReportsTest extends DatabaseTestCase ); // expected tasks - $scheduleTask1 = new Piwik_ScheduledTime_Daily(); + $scheduleTask1 = new Daily(); $scheduleTask1->setHour(23); // paris is UTC-1, period ends at 23h UTC - $scheduleTask2 = new Piwik_ScheduledTime_Monthly(); + $scheduleTask2 = new Monthly(); $scheduleTask2->setHour(7); // site is UTC-6.5, period ends at 6h30 UTC, smallest resolution is hour - $scheduleTask3 = new Piwik_ScheduledTime_Monthly(); + $scheduleTask3 = new Monthly(); $scheduleTask3->setHour(7); // paris is UTC-1, configured to be sent at 8h - $scheduleTask4 = new Piwik_ScheduledTime_Monthly(); + $scheduleTask4 = new Monthly(); $scheduleTask4->setHour(15); // site is UTC-6.5, configured to be sent at 8h $expectedTasks = array( diff --git a/tests/PHPUnit/Plugins/PrivacyManagerTest.php b/tests/PHPUnit/Plugins/PrivacyManagerTest.php index 4d44c6464f..17ca9d2c8c 100755 --- a/tests/PHPUnit/Plugins/PrivacyManagerTest.php +++ b/tests/PHPUnit/Plugins/PrivacyManagerTest.php @@ -16,6 +16,8 @@ use Piwik\Date; use Piwik\Option; use Piwik\Site; use Piwik\Db; +use Piwik\Tracker\Cache; +use Piwik\Tracker\GoalManager; require_once 'PrivacyManager/PrivacyManager.php'; @@ -115,7 +117,7 @@ class PrivacyManagerTest extends IntegrationTestCase Manager::getInstance()->deleteAll(); Option::getInstance()->clearCache(); Site::clearCache(); - Piwik_Tracker_Cache::deleteTrackerCache(); + Cache::deleteTrackerCache(); ArchiveTableCreator::clear(); $tempTableName = Common::prefixTable(Piwik_PrivacyManager_LogDataPurger::TEMP_TABLE_NAME); @@ -718,7 +720,7 @@ class PrivacyManagerTest extends IntegrationTestCase 'nb_actions', Piwik_Goals_Archiver::getRecordName('revenue'), Piwik_Goals_Archiver::getRecordName('nb_conversions', 1), - Piwik_Goals_Archiver::getRecordName('revenue', Piwik_Tracker_GoalManager::IDGOAL_ORDER) + Piwik_Goals_Archiver::getRecordName('revenue', GoalManager::IDGOAL_ORDER) ); $archiveTables = self::_getArchiveTableNames(); diff --git a/tests/PHPUnit/proxy/index.php b/tests/PHPUnit/proxy/index.php index ce08221128..12f5e0b2a9 100644 --- a/tests/PHPUnit/proxy/index.php +++ b/tests/PHPUnit/proxy/index.php @@ -5,6 +5,7 @@ */ // make sure the test environment is loaded +use Piwik\Tracker\Cache; use Piwik\Visualization\Cloud; // Wrapping the request inside ob_start() calls to ensure that the Test @@ -25,7 +26,7 @@ Piwik_TestingEnvironment::addHooks(); Cloud::$debugDisableShuffle = true; \Piwik\Tracker::setTestEnvironment(); -Piwik_Tracker_Cache::deleteTrackerCache(); +Cache::deleteTrackerCache(); // Disable index.php dispatch since we do it manually below define('PIWIK_ENABLE_DISPATCH', false); diff --git a/tests/PHPUnit/proxy/piwik.php b/tests/PHPUnit/proxy/piwik.php index 8610ef8b4d..2a72cfbd88 100755 --- a/tests/PHPUnit/proxy/piwik.php +++ b/tests/PHPUnit/proxy/piwik.php @@ -16,6 +16,7 @@ use Piwik\DataTable\Manager; use Piwik\Option; use Piwik\Tracker; use Piwik\Site; +use Piwik\Tracker\Cache; ob_start(); @@ -44,7 +45,7 @@ Tracker::setTestEnvironment(); Manager::getInstance()->deleteAll(); Option::getInstance()->clearCache(); Site::clearCache(); -Piwik_Tracker_Cache::deleteTrackerCache(); +Cache::deleteTrackerCache(); include PIWIK_INCLUDE_PATH . '/piwik.php'; ob_end_flush(); -- cgit v1.2.3