diff options
author | Remon van de Kamp <rpkamp@gmail.com> | 2017-06-19 01:33:57 +0200 |
---|---|---|
committer | Jordi Boggiano <j.boggiano@seld.be> | 2017-06-19 01:33:57 +0200 |
commit | deb0ea4ee79a389b3004b0ef43499def511bbe9d (patch) | |
tree | 89a83001b3ae1ab1b251f3ffee905c401a4bbb5e | |
parent | 1b769912d1d7f1c6ed8b17de7a9aee9ba3fe92b0 (diff) | |
download | monolog-deb0ea4ee79a389b3004b0ef43499def511bbe9d.zip monolog-deb0ea4ee79a389b3004b0ef43499def511bbe9d.tar.gz monolog-deb0ea4ee79a389b3004b0ef43499def511bbe9d.tar.bz2 |
Use first day/first month for date calculations in RotatingFileHandlerTest (#963)
When making the calculations for the filename of the current month using
date('d') does not work because you may run into the situation where you run
the tests on a day in a month that does not exist in the previous month,
for example March 30th. As there is no February 30th, PHP will skip ahead
to March, and the filename for the "previous" month will incorrectly be
"2017-03" instead of the expected "2017-02". Using the first day of the
month instead of the current day of the month solves this problem.
For consistency we now also use the first month of each year for calculations
regarding years even if this is not necessary, it would break symmetry
if we don't, plus it makes it clear that the value is not relevant in the
calculation.
-rw-r--r-- | tests/Monolog/Handler/RotatingFileHandlerTest.php | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/tests/Monolog/Handler/RotatingFileHandlerTest.php b/tests/Monolog/Handler/RotatingFileHandlerTest.php index c510617..f1feb22 100644 --- a/tests/Monolog/Handler/RotatingFileHandlerTest.php +++ b/tests/Monolog/Handler/RotatingFileHandlerTest.php @@ -111,10 +111,10 @@ class RotatingFileHandlerTest extends TestCase return $now + 86400 * $ago; }; $monthCallback = function($ago) { - return gmmktime(0, 0, 0, date('n') + $ago, date('d'), date('Y')); + return gmmktime(0, 0, 0, date('n') + $ago, 1, date('Y')); }; $yearCallback = function($ago) { - return gmmktime(0, 0, 0, date('n'), date('d'), date('Y') + $ago); + return gmmktime(0, 0, 0, 1, 1, date('Y') + $ago); }; return array( |