Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorStefan Giehl <stefan@matomo.org>2020-12-24 08:21:02 +0300
committerGitHub <noreply@github.com>2020-12-24 08:21:02 +0300
commit04ac70e0cbf8b7a5ff3d5de66fc0825ace4b0b71 (patch)
tree29f57e261ffe1d82971e5b1a10da335dae6593f6 /tests
parentddfa42e16f6648a1f54d2912fcc897e0ae07b75e (diff)
Fix report showing data of wrong date (#17008)
* Use timezone in period factory only for magic keywords * add test * use better timezone * add non-timezone date Co-authored-by: diosmosis <diosmosis@users.noreply.github.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/PHPUnit/Integration/Period/FactoryTest.php29
1 files changed, 28 insertions, 1 deletions
diff --git a/tests/PHPUnit/Integration/Period/FactoryTest.php b/tests/PHPUnit/Integration/Period/FactoryTest.php
index 9ff978a646..ba1ee78164 100644
--- a/tests/PHPUnit/Integration/Period/FactoryTest.php
+++ b/tests/PHPUnit/Integration/Period/FactoryTest.php
@@ -9,6 +9,7 @@
namespace Piwik\Tests\Integration\Period;
use Piwik\Config;
+use Piwik\Date;
use Piwik\Period;
use Piwik\Period\Day;
use Piwik\Period\Month;
@@ -63,10 +64,36 @@ class MockPluginManager extends \Piwik\Plugin\Manager
class FactoryTest extends IntegrationTestCase
{
/**
+ * @dataProvider getTestDataForMakePeriodFromQueryParams
+ */
+ public function test_makePeriodFromQueryParams_appliesTimezoneProperly($period, $date, $expectedLabel, $expectedRange)
+ {
+ Date::$now = strtotime('2020-12-24 03:37:00');
+
+ $factory = Period\Factory::makePeriodFromQueryParams('America/Chicago', $period, $date);
+ $this->assertEquals($expectedLabel, $factory->getLabel());
+ $this->assertEquals($expectedRange, $factory->getRangeString());
+ }
+
+ public function getTestDataForMakePeriodFromQueryParams()
+ {
+ return [
+ ['day', 'now', 'day', '2020-12-23,2020-12-23'],
+ ['day', 'today', 'day', '2020-12-23,2020-12-23'],
+ ['day', 'yesterday', 'day', '2020-12-22,2020-12-22'],
+ ['day', 'yesterdaySameTime', 'day', '2020-12-22,2020-12-22'],
+ ['day', 'last-week', 'day', '2020-12-16,2020-12-16'],
+ ['day', 'last-month', 'day', '2020-11-23,2020-11-23'],
+ ['day', 'last-year', 'day', '2019-12-23,2019-12-23'],
+ ['day', '2020-12-23', 'day', '2020-12-23,2020-12-23'],
+ ];
+ }
+
+ /**
* @dataProvider getBuildTestData
*/
public function test_build_CreatesCorrectPeriodInstances($strPeriod, $date, $timezone, $expectedPeriodClass,
- $expectedRangeString)
+ $expectedRangeString)
{
$period = Period\Factory::build($strPeriod, $date, $timezone);
$this->assertInstanceOf($expectedPeriodClass, $period);