diff --git a/core/DataTable/Map.php b/core/DataTable/Map.php index 7bda0c19843..443e741f2c0 100644 --- a/core/DataTable/Map.php +++ b/core/DataTable/Map.php @@ -9,6 +9,7 @@ * @package Piwik */ namespace Piwik\DataTable; +use Piwik\DataTable; /** * The DataTable_Array is a way to store an array of dataTable. @@ -294,7 +295,7 @@ public function mergeChildren() { $firstChild = reset($this->array); - if ($firstChild instanceof Set) { + if ($firstChild instanceof Map) { $result = $firstChild->getEmptyClone(); foreach ($this->array as $label => $subTableArray) { @@ -328,7 +329,7 @@ public function mergeChildren() * @param DataTable $fromTable The table to copy rows from. * @param string $label The value to set the 'label' column of every copied row. */ - private function copyRowsAndSetLabel(DataTable $toTable, DataTable $fromTable, $label) + private function copyRowsAndSetLabel($toTable, $fromTable, $label) { foreach ($fromTable->getRows() as $fromRow) { $oldColumns = $fromRow->getColumns(); diff --git a/core/DataTable/Simple.php b/core/DataTable/Simple.php index d7f9c430ad8..5dc11d780ba 100644 --- a/core/DataTable/Simple.php +++ b/core/DataTable/Simple.php @@ -9,6 +9,7 @@ * @package Piwik */ namespace Piwik\DataTable; +use Piwik\DataTable; /** * The DataTable\Simple is used to provide an easy way to create simple DataGrid. diff --git a/core/Period.php b/core/Period.php index 7edf4ea8108..3c04d543081 100644 --- a/core/Period.php +++ b/core/Period.php @@ -16,7 +16,7 @@ use Piwik\Period\Month; use Piwik\Period\Range; use Piwik\Period\Week; -use Piwik_Period_Year; +use Piwik\Period\Year; /** * Creating a new Period subclass: @@ -84,7 +84,7 @@ static public function factory($strPeriod, Date $date) break; case 'year': - return new Piwik_Period_Year($date); + return new Year($date); break; default: diff --git a/core/Period/Month.php b/core/Period/Month.php index 5434bd6efe7..e53c5282d05 100644 --- a/core/Period/Month.php +++ b/core/Period/Month.php @@ -10,6 +10,7 @@ */ namespace Piwik\Period; +use Piwik\Period; use Piwik\Period\Day; /** diff --git a/core/Period/Week.php b/core/Period/Week.php index 370a05656bf..c975aba1357 100644 --- a/core/Period/Week.php +++ b/core/Period/Week.php @@ -11,6 +11,7 @@ namespace Piwik\Period; use Piwik\Period\Day; +use Piwik\Period; /** * @package Piwik diff --git a/core/Period/Year.php b/core/Period/Year.php index 56cc52fa6b3..d56d6934649 100644 --- a/core/Period/Year.php +++ b/core/Period/Year.php @@ -8,6 +8,8 @@ * @category Piwik * @package Piwik */ +namespace Piwik\Period; + use Piwik\Period; use Piwik\Date; use Piwik\Period\Month; @@ -16,7 +18,7 @@ * @package Piwik * @subpackage Period */ -class Piwik_Period_Year extends Period +class Year extends Period { protected $label = 'year'; diff --git a/tests/PHPUnit/Core/DataTable/Filter/TruncateTest.php b/tests/PHPUnit/Core/DataTable/Filter/TruncateTest.php index c499350066b..52460f93ad7 100644 --- a/tests/PHPUnit/Core/DataTable/Filter/TruncateTest.php +++ b/tests/PHPUnit/Core/DataTable/Filter/TruncateTest.php @@ -51,7 +51,7 @@ public function testForInfiniteRecursion() // remark: this unit test would become invalid and would need to be rewritten if // Truncate filter stops calling getIdSubDataTable() on rows associated with a SubDataTable - $rowBeingFiltered = $this->getMock('Row', array('getIdSubDataTable')); + $rowBeingFiltered = $this->getMock('\Piwik\DataTable\Row', array('getIdSubDataTable')); $rowBeingFiltered->expects($this->never())->method('getIdSubDataTable'); $dataTableBeingFiltered->addRow($rowBeingFiltered); diff --git a/tests/PHPUnit/Core/DataTable/MapTest.php b/tests/PHPUnit/Core/DataTable/MapTest.php index 2ac19275a9a..788c7597ad7 100644 --- a/tests/PHPUnit/Core/DataTable/MapTest.php +++ b/tests/PHPUnit/Core/DataTable/MapTest.php @@ -64,7 +64,7 @@ public function test_MergeChildrenDataTable() $result = $dataTable->mergeChildren(); // check that the result is a DataTable w/ 4 rows - $this->assertInstanceOf('DataTable', $result); + $this->assertInstanceOf('\Piwik\DataTable', $result); $this->assertEquals(4, $result->getRowsCount()); // check that the first two rows have 'subDataTable1' as the label @@ -95,7 +95,7 @@ public function testMergeChildrenDataTableArray() $result = $dataTable->mergeChildren(); // check that the result is a DataTable_Array w/ two DataTable children - $this->assertInstanceOf('Set', $result); + $this->assertInstanceOf('\Piwik\DataTable\Map', $result); $this->assertEquals(2, $result->getRowsCount()); // check that the first sub-DataTable is a DataTable with 4 rows diff --git a/tests/PHPUnit/Core/DataTableTest.php b/tests/PHPUnit/Core/DataTableTest.php index 95e2c8d2fcf..d558e12c085 100644 --- a/tests/PHPUnit/Core/DataTableTest.php +++ b/tests/PHPUnit/Core/DataTableTest.php @@ -774,7 +774,7 @@ public function testUnrelatedDataTableNotDestructed() */ public function testGetSerializedCallsCleanPostSerialize() { - $mockedDataTableRow = $this->getMock('Row', array('cleanPostSerialize')); + $mockedDataTableRow = $this->getMock('\Piwik\DataTable\Row', array('cleanPostSerialize')); $mockedDataTableRow->expects($this->once())->method('cleanPostSerialize'); $dataTableBeingSerialized = new DataTable(); diff --git a/tests/PHPUnit/Core/Period/RangeTest.php b/tests/PHPUnit/Core/Period/RangeTest.php index dc7799e732f..707e32f301f 100644 --- a/tests/PHPUnit/Core/Period/RangeTest.php +++ b/tests/PHPUnit/Core/Period/RangeTest.php @@ -6,6 +6,7 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later */ use Piwik\Period\Month; +use Piwik\Period\Year; use Piwik\Period\Week; use Piwik\Period\Range; use Piwik\Date; @@ -460,7 +461,7 @@ public function testRangeYear() $correct = array(); for ($i = 0; $i < 10; $i++) { $date = $today->subMonth(12 * $i); - $week = new Piwik_Period_Year($date); + $week = new Year($date); $correct[] = $week->toString(); } @@ -479,7 +480,7 @@ public function testRangeYear() public function testRangeYearLast1() { $range = new Range('year', 'last1'); - $currentYear = new Piwik_Period_Year(Date::today()); + $currentYear = new Year(Date::today()); $this->assertEquals(1, $range->getNumberOfSubperiods()); $this->assertEquals(array($currentYear->toString()), $range->toString()); } diff --git a/tests/PHPUnit/Core/Period/YearTest.php b/tests/PHPUnit/Core/Period/YearTest.php index 191790424e3..c69489ef637 100644 --- a/tests/PHPUnit/Core/Period/YearTest.php +++ b/tests/PHPUnit/Core/Period/YearTest.php @@ -6,6 +6,7 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later */ use Piwik\Date; +use Piwik\Period\Year; use Piwik\Translate; /** @@ -35,7 +36,7 @@ public function testYearNormalcase() '2024-11-01', '2024-12-01',); - $year = new Piwik_Period_Year(Date::factory('2024-10-09')); + $year = new Year(Date::factory('2024-10-09')); $this->assertEquals(12, $year->getNumberOfSubperiods()); $this->assertEquals($correct, $year->toString()); } @@ -63,7 +64,7 @@ public function testYearPastAndWrongdate() '2000-12-01', ); - $year = new Piwik_Period_Year(Date::factory('2000-02-15')); + $year = new Year(Date::factory('2000-02-15')); $this->assertEquals(12, $year->getNumberOfSubperiods()); $this->assertEquals($correct, $year->toString()); } @@ -76,7 +77,7 @@ public function testYearPastAndWrongdate() public function testGetLocalizedShortString() { Translate::getInstance()->loadEnglishTranslation(); - $year = new Piwik_Period_Year(Date::factory('2024-10-09')); + $year = new Year(Date::factory('2024-10-09')); $shouldBe = '2024'; $this->assertEquals($shouldBe, $year->getLocalizedShortString()); } @@ -89,7 +90,7 @@ public function testGetLocalizedShortString() public function testGetLocalizedLongString() { Translate::getInstance()->loadEnglishTranslation(); - $year = new Piwik_Period_Year(Date::factory('2024-10-09')); + $year = new Year(Date::factory('2024-10-09')); $shouldBe = '2024'; $this->assertEquals($shouldBe, $year->getLocalizedLongString()); } @@ -102,7 +103,7 @@ public function testGetLocalizedLongString() public function testGetPrettyString() { Translate::getInstance()->loadEnglishTranslation(); - $year = new Piwik_Period_Year(Date::factory('2024-10-09')); + $year = new Year(Date::factory('2024-10-09')); $shouldBe = '2024'; $this->assertEquals($shouldBe, $year->getPrettyString()); } diff --git a/tests/PHPUnit/Core/PeriodTest.php b/tests/PHPUnit/Core/PeriodTest.php index 0b315b2527d..97ad458ea30 100644 --- a/tests/PHPUnit/Core/PeriodTest.php +++ b/tests/PHPUnit/Core/PeriodTest.php @@ -9,6 +9,7 @@ use Piwik\Date; use Piwik\Period\Month; use Piwik\Period\Day; +use Piwik\Period\Year; use Piwik\Period\Week; class PeriodTest extends PHPUnit_Framework_TestCase @@ -25,7 +26,7 @@ public function testGetId() $this->assertNotEquals(0, $period->getId()); $period = new Month(Date::today()); $this->assertNotEquals(0, $period->getId()); - $period = new Piwik_Period_Year(Date::today()); + $period = new Year(Date::today()); $this->assertNotEquals(0, $period->getId()); } @@ -47,7 +48,7 @@ public function testGetLabel() $label = $period->getLabel(); $this->assertInternalType('string', $label); $this->assertNotEmpty($label); - $period = new Piwik_Period_Year(Date::today()); + $period = new Year(Date::today()); $label = $period->getLabel(); $this->assertInternalType('string', $label); $this->assertNotEmpty($label); @@ -60,7 +61,7 @@ public function testGetLabel() public function testFactoryDay() { $period = Period::factory('day', Date::today()); - $this->assertInstanceOf('Day', $period); + $this->assertInstanceOf('\Piwik\Period\Day', $period); } /** @@ -70,7 +71,7 @@ public function testFactoryDay() public function testFactoryMonth() { $period = Period::factory('month', Date::today()); - $this->assertInstanceOf('Month', $period); + $this->assertInstanceOf('\Piwik\Period\Month', $period); } /** @@ -80,7 +81,7 @@ public function testFactoryMonth() public function testFactoryWeek() { $period = Period::factory('week', Date::today()); - $this->assertInstanceOf('Week', $period); + $this->assertInstanceOf('\Piwik\Period\Week', $period); } /** @@ -90,7 +91,7 @@ public function testFactoryWeek() public function testFactoryYear() { $period = Period::factory('year', Date::today()); - $this->assertInstanceOf('Piwik_Period_Year', $period); + $this->assertInstanceOf('\Piwik\Period\Year', $period); } /** diff --git a/tests/PHPUnit/Core/TaskSchedulerTest.php b/tests/PHPUnit/Core/TaskSchedulerTest.php index 4ae0c321402..df32496940d 100644 --- a/tests/PHPUnit/Core/TaskSchedulerTest.php +++ b/tests/PHPUnit/Core/TaskSchedulerTest.php @@ -282,6 +282,7 @@ public function testRunTasks($expectedTimetable, $expectedExecutedTasks, $timeta // temporarily unload plugins $plugins = \Piwik\PluginsManager::getInstance()->getLoadedPlugins(); $plugins = array_map(function ($p) { return $p->getPluginName(); }, $plugins); + \Piwik\PluginsManager::getInstance()->unloadPlugins(); // make sure the get tasks event returns our configured tasks