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
diff options
context:
space:
mode:
authordiosmosis <diosmosis@users.noreply.github.com>2018-10-11 22:07:37 +0300
committerGitHub <noreply@github.com>2018-10-11 22:07:37 +0300
commit221a25f83989df5ea155fd2af6086bb48b280f28 (patch)
tree2cffd9be297e76f0ac362093a92162534b200a69
parenteb965d4ff002943ce926c99267511af55dee10cf (diff)
Fix single day archive check in ArchiveProcessor/Parameters. (#13580)
-rw-r--r--core/ArchiveProcessor/Parameters.php2
-rw-r--r--tests/PHPUnit/Integration/ArchiveProcessor/ParametersTest.php52
2 files changed, 53 insertions, 1 deletions
diff --git a/core/ArchiveProcessor/Parameters.php b/core/ArchiveProcessor/Parameters.php
index ce62199a53..d9af9ac77c 100644
--- a/core/ArchiveProcessor/Parameters.php
+++ b/core/ArchiveProcessor/Parameters.php
@@ -211,7 +211,7 @@ class Parameters
{
$period = $this->getPeriod();
$secondsInPeriod = $period->getDateEnd()->getTimestampUTC() - $period->getDateStart()->getTimestampUTC();
- $oneDay = $secondsInPeriod <= Date::NUM_SECONDS_IN_DAY;
+ $oneDay = $secondsInPeriod < Date::NUM_SECONDS_IN_DAY;
return $oneDay;
}
diff --git a/tests/PHPUnit/Integration/ArchiveProcessor/ParametersTest.php b/tests/PHPUnit/Integration/ArchiveProcessor/ParametersTest.php
new file mode 100644
index 0000000000..0c8f465a40
--- /dev/null
+++ b/tests/PHPUnit/Integration/ArchiveProcessor/ParametersTest.php
@@ -0,0 +1,52 @@
+<?php
+/**
+ * Piwik - free/libre analytics platform
+ *
+ * @link http://piwik.org
+ * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
+ *
+ */
+
+namespace Piwik\Tests\Integration\ArchiveProcessor;
+
+
+use Piwik\ArchiveProcessor\Parameters;
+use Piwik\Segment;
+use Piwik\Site;
+use Piwik\Tests\Framework\Fixture;
+use Piwik\Tests\Framework\TestCase\IntegrationTestCase;
+use Piwik\Period;
+
+class ParametersTest extends IntegrationTestCase
+{
+ public function setUp()
+ {
+ parent::setUp();
+
+ Fixture::createWebsite('2012-02-01 00:00:00');
+ }
+
+ /**
+ * @dataProvider getTestDataForIsDayArchive
+ */
+ public function test_isDayArchive_CorrectlyDetectsDayArchives($expected, $dateStr, $periodStr)
+ {
+ $period = Period\Factory::build($periodStr, $dateStr);
+ $params = new Parameters(new Site(1), $period, new Segment('', [1]));
+ $actual = $params->isDayArchive();
+ $this->assertEquals($expected, $actual);
+ }
+
+ public function getTestDataForIsDayArchive()
+ {
+ return [
+ [true, '2012-02-02', 'day'],
+ [false, '2013-03-04', 'week'],
+ [false, '2013-03-04', 'month'],
+ [false, '2013-03-04', 'year'],
+ [true, '2012-02-02,2012-02-02', 'range'],
+ [false, '2012-02-02,2012-02-03', 'range'],
+ [false, '2012-02-02,2012-02-05', 'range'],
+ ];
+ }
+} \ No newline at end of file