قرینه از
https://github.com/matomo-org/matomo.git
synced 2025-08-21 22:47:43 +00:00

* [Coding Style] Enable rule PSR1.Methods.CamelCapsMethodName.NotCamelCaps * [Coding Style] Use camel case for method names in API plugin tests (#22145) * [Coding Style] Use camel case for method names in Core* plugin tests (#22147) * [Coding Style] Use camel case for method names in core Unit tests (#22149) * [Coding Style] Use camel case for method names in Actions and BulkTracking plugin tests (#22146) * [Coding Style] Use camel case for method names in CustomDimensions and CustomJSTracker plugin tests (#22148) * [Coding Style] Use camel case for method names in core Integration tests (#22151) * [Coding Style] Use camel case for method names in more core plugin tests (#22153) * [Coding Style] Use camel case for method names in more core plugin tests (#22157) * [Coding Style] Use camel case for method names in more core plugin tests * Update plugins/Monolog/tests/Unit/Processor/ExceptionToTextProcessorTest.php Co-authored-by: Michal Kleiner <michal@innocraft.com> --------- Co-authored-by: Michal Kleiner <michal@innocraft.com> * [Coding Style] Use camel case for method names in more core plugin tests (#22159) * [Coding Style] Use camel case for method names in remaining tests (#22160) * [Coding Style] Use camel case for method names in remaining tests * rename expected test files --------- Co-authored-by: Michal Kleiner <michal@innocraft.com>
114 خطوط
3.3 KiB
PHP
114 خطوط
3.3 KiB
PHP
<?php
|
|
|
|
/**
|
|
* Matomo - free/libre analytics platform
|
|
*
|
|
* @link https://matomo.org
|
|
* @license https://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
|
*/
|
|
|
|
namespace Piwik\Plugins\VisitTime\tests\Unit;
|
|
|
|
use Piwik\DataTable\Row;
|
|
use Piwik\DataTable;
|
|
|
|
/**
|
|
* @group VisitTime
|
|
* @group AddSegmentByLabelInUTCTest
|
|
* @group Plugins
|
|
*/
|
|
class AddSegmentByLabelInUTCTest extends \PHPUnit\Framework\TestCase
|
|
{
|
|
private $filter = 'Piwik\Plugins\VisitTime\DataTable\Filter\AddSegmentByLabelInUTC';
|
|
|
|
/**
|
|
* @var DataTable
|
|
*/
|
|
private $table;
|
|
|
|
public function setUp(): void
|
|
{
|
|
$this->table = new DataTable();
|
|
$this->addRow(array('label' => '0'));
|
|
$this->addRow(array('label' => '1'));
|
|
$this->addRow(array('label' => '2'));
|
|
$this->addRow(array('label' => '12'));
|
|
$this->addRow(array('label' => '13'));
|
|
$this->addRow(array('label' => '14'));
|
|
$this->addRow(array('label' => '20'));
|
|
}
|
|
|
|
private function addRow($columns)
|
|
{
|
|
$this->table->addRow($this->buildRow($columns));
|
|
}
|
|
|
|
private function buildRow($columns)
|
|
{
|
|
return new Row(array(Row::COLUMNS => $columns));
|
|
}
|
|
|
|
public function testFilterShouldNotChangeHoursIfTimezoneIsUTCAlready()
|
|
{
|
|
$this->table->filter($this->filter, array('UTC', 'day', 'today'));
|
|
|
|
$this->assertSegmentValues(array('0', '1', '2', '12', '13', '14', '20'));
|
|
}
|
|
|
|
public function testFilterShouldConvertHoursFromTimezoneIntoUTCMinus1()
|
|
{
|
|
$this->table->filter($this->filter, array('UTC-1', 'day', 'today'));
|
|
$this->assertSegmentValues(array('1', '2', '3', '13', '14', '15', '21'));
|
|
}
|
|
|
|
public function testFilterShouldConvertHoursFromTimezoneIntoUTCPlus1()
|
|
{
|
|
$this->table->filter($this->filter, array('UTC+1', 'day', 'today'));
|
|
$this->assertSegmentValuesInUTCplus1();
|
|
}
|
|
|
|
public function testFilterShouldHandleRangePeriodPlus1()
|
|
{
|
|
$this->table->filter($this->filter, array('UTC+1', 'range', '2015-02-02,2015-02-14'));
|
|
$this->assertSegmentValuesInUTCplus1();
|
|
}
|
|
|
|
public function testFilterShouldHandleRangePeriodWithLast7Plus1()
|
|
{
|
|
$this->table->filter($this->filter, array('UTC+1', 'range', 'last7'));
|
|
$this->assertSegmentValuesInUTCplus1();
|
|
}
|
|
|
|
public function testFilterShouldHandleDayPeriodWithRangePlus1()
|
|
{
|
|
$this->table->filter($this->filter, array('UTC+1', 'day', '2015-02-02,2015-02-14'));
|
|
$this->assertSegmentValuesInUTCplus1();
|
|
}
|
|
|
|
public function testFilterShouldHandleWeekWithLast7Plus1()
|
|
{
|
|
$this->table->filter($this->filter, array('UTC+1', 'day', 'last7'));
|
|
$this->assertSegmentValuesInUTCplus1();
|
|
}
|
|
|
|
public function testFilterShouldIgnoreSummaryRow()
|
|
{
|
|
$row = $this->buildRow(array('label' => 'other'));
|
|
$this->table->addSummaryRow($row);
|
|
$this->table->filter($this->filter, array('UTC', 'day', 'today'));
|
|
|
|
$this->assertFalse($row->getMetadata('segmentValue'));
|
|
}
|
|
|
|
private function assertSegmentValuesInUTCplus1()
|
|
{
|
|
$this->assertSegmentValues(array('23', '0', '1', '11', '12', '13', '19'));
|
|
}
|
|
|
|
private function assertSegmentValues($expectedSegmentValues)
|
|
{
|
|
$segmentValues = $this->table->getRowsMetadata('segmentValue');
|
|
$this->assertSame($expectedSegmentValues, $segmentValues);
|
|
}
|
|
}
|