Skip to content

Commit

Permalink
Refs #4059 Work in progress: Conversion to use Namespaces
Browse files Browse the repository at this point in the history
  • Loading branch information
mattab committed Jul 21, 2013
1 parent aca8ec3 commit ae4b1f4
Show file tree
Hide file tree
Showing 13 changed files with 32 additions and 22 deletions.
5 changes: 3 additions & 2 deletions core/DataTable/Map.php
Expand Up @@ -9,6 +9,7 @@
* @package Piwik
*/
namespace Piwik\DataTable;
use Piwik\DataTable;

/**
* The DataTable_Array is a way to store an array of dataTable.
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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();
Expand Down
1 change: 1 addition & 0 deletions core/DataTable/Simple.php
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions core/Period.php
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions core/Period/Month.php
Expand Up @@ -10,6 +10,7 @@
*/
namespace Piwik\Period;

use Piwik\Period;
use Piwik\Period\Day;

/**
Expand Down
1 change: 1 addition & 0 deletions core/Period/Week.php
Expand Up @@ -11,6 +11,7 @@
namespace Piwik\Period;

use Piwik\Period\Day;
use Piwik\Period;

/**
* @package Piwik
Expand Down
4 changes: 3 additions & 1 deletion core/Period/Year.php
Expand Up @@ -8,6 +8,8 @@
* @category Piwik
* @package Piwik
*/
namespace Piwik\Period;

use Piwik\Period;
use Piwik\Date;
use Piwik\Period\Month;
Expand All @@ -16,7 +18,7 @@
* @package Piwik
* @subpackage Period
*/
class Piwik_Period_Year extends Period
class Year extends Period
{
protected $label = 'year';

Expand Down
2 changes: 1 addition & 1 deletion tests/PHPUnit/Core/DataTable/Filter/TruncateTest.php
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions tests/PHPUnit/Core/DataTable/MapTest.php
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/PHPUnit/Core/DataTableTest.php
Expand Up @@ -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();
Expand Down
5 changes: 3 additions & 2 deletions tests/PHPUnit/Core/Period/RangeTest.php
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
}
Expand All @@ -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());
}
Expand Down
11 changes: 6 additions & 5 deletions tests/PHPUnit/Core/Period/YearTest.php
Expand Up @@ -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;

/**
Expand Down Expand Up @@ -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());
}
Expand Down Expand Up @@ -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());
}
Expand All @@ -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());
}
Expand All @@ -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());
}
Expand All @@ -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());
}
Expand Down
13 changes: 7 additions & 6 deletions tests/PHPUnit/Core/PeriodTest.php
Expand Up @@ -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
Expand All @@ -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());
}

Expand All @@ -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);
Expand All @@ -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);
}

/**
Expand All @@ -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);
}

/**
Expand All @@ -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);
}

/**
Expand All @@ -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);
}

/**
Expand Down
1 change: 1 addition & 0 deletions tests/PHPUnit/Core/TaskSchedulerTest.php
Expand Up @@ -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
Expand Down

0 comments on commit ae4b1f4

Please sign in to comment.