23 $dir = __DIR__.
'/Fixtures';
25 if (!is_writable($dir)) {
26 $this->markTestSkipped($dir.
' must be writeable to test the RotatingFileHandler.');
32 touch(__DIR__.
'/Fixtures/foo-'.date(
'Y-m-d', time() - 86400).
'.rot');
38 $log = __DIR__.
'/Fixtures/foo-'.date(
'Y-m-d').
'.rot';
39 $this->assertTrue(file_exists(
$log));
40 $this->assertEquals(
'test', file_get_contents(
$log));
48 touch($old1 = __DIR__.
'/Fixtures/foo-'.date(
'Y-m-d', time() - 86400).
'.rot');
49 touch($old2 = __DIR__.
'/Fixtures/foo-'.date(
'Y-m-d', time() - 86400 * 2).
'.rot');
50 touch($old3 = __DIR__.
'/Fixtures/foo-'.date(
'Y-m-d', time() - 86400 * 3).
'.rot');
51 touch($old4 = __DIR__.
'/Fixtures/foo-'.date(
'Y-m-d', time() - 86400 * 4).
'.rot');
53 $log = __DIR__.
'/Fixtures/foo-'.date(
'Y-m-d').
'.rot';
65 $this->assertTrue(file_exists(
$log));
66 $this->assertTrue(file_exists($old1));
67 $this->assertEquals($createFile, file_exists($old2));
68 $this->assertEquals($createFile, file_exists($old3));
69 $this->assertEquals($createFile, file_exists($old4));
70 $this->assertEquals(
'test', file_get_contents(
$log));
76 'Rotation is triggered when the file of the current day is not present' 78 'Rotation is not triggered when the file is already present' 85 $log = __DIR__.
'/Fixtures/foo-'.date(
'Y-m-d').
'.rot';
86 file_put_contents(
$log,
"foo");
90 $this->assertEquals(
'footest', file_get_contents(
$log));
95 foreach (glob(__DIR__.
'/Fixtures/*.rot') as
$file) {
testRotation($createFile)
rotationTests
testRotationCreatesNewFile()
Stores logs to files that are rotated every day and a limited number of files are kept...
getRecord($level=Logger::WARNING, $message='test', $context=array())