|
@@ -551,7 +551,7 @@ class LoggerTest extends \PHPUnit_Framework_TestCase
|
|
|
* @covers Monolog\Logger::useMicrosecondTimestamps
|
|
* @covers Monolog\Logger::useMicrosecondTimestamps
|
|
|
* @covers Monolog\Logger::addRecord
|
|
* @covers Monolog\Logger::addRecord
|
|
|
*/
|
|
*/
|
|
|
- public function testUseMicrosecondTimestamps($micro, $assert)
|
|
|
|
|
|
|
+ public function testUseMicrosecondTimestamps($micro, $assert, $assertFormat)
|
|
|
{
|
|
{
|
|
|
$logger = new Logger('foo');
|
|
$logger = new Logger('foo');
|
|
|
$logger->useMicrosecondTimestamps($micro);
|
|
$logger->useMicrosecondTimestamps($micro);
|
|
@@ -560,14 +560,16 @@ class LoggerTest extends \PHPUnit_Framework_TestCase
|
|
|
$logger->info('test');
|
|
$logger->info('test');
|
|
|
list($record) = $handler->getRecords();
|
|
list($record) = $handler->getRecords();
|
|
|
$this->{$assert}('000000', $record['datetime']->format('u'));
|
|
$this->{$assert}('000000', $record['datetime']->format('u'));
|
|
|
|
|
+ $this->assertSame($record['datetime']->format($assertFormat), (string) $record['datetime']);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public function useMicrosecondTimestampsProvider()
|
|
public function useMicrosecondTimestampsProvider()
|
|
|
{
|
|
{
|
|
|
return [
|
|
return [
|
|
|
// this has a very small chance of a false negative (1/10^6)
|
|
// this has a very small chance of a false negative (1/10^6)
|
|
|
- 'with microseconds' => [true, 'assertNotSame'],
|
|
|
|
|
- 'without microseconds' => [false, 'assertSame'],
|
|
|
|
|
|
|
+ 'with microseconds' => [true, 'assertNotSame', 'Y-m-d\TH:i:s.uP'],
|
|
|
|
|
+ // php 7.1 always includes microseconds, so we keep them in, but we format the datetime without
|
|
|
|
|
+ 'without microseconds' => [false, PHP_VERSION_ID >= 70100 ? 'assertNotSame' : 'assertSame', 'Y-m-d\TH:i:sP'],
|
|
|
];
|
|
];
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|