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 +- 11 files changed, 123 insertions(+), 103 deletions(-) (limited to 'tests/PHPUnit/Core') 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), -- cgit v1.2.3