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:
Diffstat (limited to 'tests/PHPUnit/Unit/PeriodTest.php')
-rw-r--r--tests/PHPUnit/Unit/PeriodTest.php25
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/PHPUnit/Unit/PeriodTest.php b/tests/PHPUnit/Unit/PeriodTest.php
index 2d90fdbfdc..6e4f16f7b2 100644
--- a/tests/PHPUnit/Unit/PeriodTest.php
+++ b/tests/PHPUnit/Unit/PeriodTest.php
@@ -255,4 +255,29 @@ class PeriodTest extends \PHPUnit\Framework\TestCase
return array($period->getLabel(), $period->getRangeString());
}, $periods);
}
+
+ /**
+ * @dataProvider getTestDataForIsDateInPeriod
+ */
+ public function test_isDateInPeriod($date, $period, $periodDate, $expected)
+ {
+ $date = Date::factory($date);
+ $period = Period\Factory::build($period, $periodDate);
+
+ $actual = $period->isDateInPeriod($date);
+ $this->assertEquals($expected, $actual);
+ }
+
+ public function getTestDataForIsDateInPeriod()
+ {
+ return [
+ ['2014-02-03 00:00:00', 'day', '2014-02-03 03:04:05', true],
+ ['2014-02-03 00:00:00', 'week', '2014-02-03 03:04:05', true],
+ ['2014-02-03 00:00:00', 'month', '2014-02-03 03:04:05', true],
+ ['2014-02-02 23:59:59', 'day', '2014-02-03 03:04:05', false],
+ ['2014-01-31 23:59:59', 'month', '2014-02-03 03:04:05', false],
+ ['2014-03-01 00:00:00', 'month', '2014-02-03 03:04:05', false],
+ ['2014-03-31 23:59:59', 'month', '2014-03-03 03:04:05', true],
+ ];
+ }
} \ No newline at end of file