ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
Monolog\Handler\RotatingFileHandlerTest Class Reference

Monolog More...

+ Inheritance diagram for Monolog\Handler\RotatingFileHandlerTest:
+ Collaboration diagram for Monolog\Handler\RotatingFileHandlerTest:

Public Member Functions

 setUp ()
 
 testRotationCreatesNewFile ()
 
 testRotation ($createFile)
 rotationTests More...
 
 rotationTests ()
 
 testReuseCurrentFile ()
 
 tearDown ()
 

Additional Inherited Members

- Protected Member Functions inherited from Monolog\TestCase
 getRecord ($level=Logger::WARNING, $message='test', $context=array())
 
 getMultipleRecords ()
 
 getIdentityFormatter ()
 

Detailed Description

Monolog

Definition at line 19 of file RotatingFileHandlerTest.php.

Member Function Documentation

◆ rotationTests()

Monolog\Handler\RotatingFileHandlerTest::rotationTests ( )

Definition at line 73 of file RotatingFileHandlerTest.php.

74  {
75  return array(
76  'Rotation is triggered when the file of the current day is not present'
77  => array(true),
78  'Rotation is not triggered when the file is already present'
79  => array(false),
80  );
81  }

◆ setUp()

Monolog\Handler\RotatingFileHandlerTest::setUp ( )

Definition at line 21 of file RotatingFileHandlerTest.php.

22  {
23  $dir = __DIR__.'/Fixtures';
24  chmod($dir, 0777);
25  if (!is_writable($dir)) {
26  $this->markTestSkipped($dir.' must be writeable to test the RotatingFileHandler.');
27  }
28  }

◆ tearDown()

Monolog\Handler\RotatingFileHandlerTest::tearDown ( )

Definition at line 93 of file RotatingFileHandlerTest.php.

References $file.

94  {
95  foreach (glob(__DIR__.'/Fixtures/*.rot') as $file) {
96  unlink($file);
97  }
98  }
print $file

◆ testReuseCurrentFile()

Monolog\Handler\RotatingFileHandlerTest::testReuseCurrentFile ( )

Definition at line 83 of file RotatingFileHandlerTest.php.

References $log, Monolog\TestCase\getIdentityFormatter(), and Monolog\TestCase\getRecord().

84  {
85  $log = __DIR__.'/Fixtures/foo-'.date('Y-m-d').'.rot';
86  file_put_contents($log, "foo");
87  $handler = new RotatingFileHandler(__DIR__.'/Fixtures/foo.rot');
88  $handler->setFormatter($this->getIdentityFormatter());
89  $handler->handle($this->getRecord());
90  $this->assertEquals('footest', file_get_contents($log));
91  }
getRecord($level=Logger::WARNING, $message='test', $context=array())
Definition: TestCase.php:19
+ Here is the call graph for this function:

◆ testRotation()

Monolog\Handler\RotatingFileHandlerTest::testRotation (   $createFile)

rotationTests

Definition at line 46 of file RotatingFileHandlerTest.php.

References $log, Monolog\TestCase\getIdentityFormatter(), and Monolog\TestCase\getRecord().

47  {
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');
52 
53  $log = __DIR__.'/Fixtures/foo-'.date('Y-m-d').'.rot';
54 
55  if ($createFile) {
56  touch($log);
57  }
58 
59  $handler = new RotatingFileHandler(__DIR__.'/Fixtures/foo.rot', 2);
60  $handler->setFormatter($this->getIdentityFormatter());
61  $handler->handle($this->getRecord());
62 
63  $handler->close();
64 
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));
71  }
getRecord($level=Logger::WARNING, $message='test', $context=array())
Definition: TestCase.php:19
+ Here is the call graph for this function:

◆ testRotationCreatesNewFile()

Monolog\Handler\RotatingFileHandlerTest::testRotationCreatesNewFile ( )

Definition at line 30 of file RotatingFileHandlerTest.php.

References $log, Monolog\TestCase\getIdentityFormatter(), and Monolog\TestCase\getRecord().

31  {
32  touch(__DIR__.'/Fixtures/foo-'.date('Y-m-d', time() - 86400).'.rot');
33 
34  $handler = new RotatingFileHandler(__DIR__.'/Fixtures/foo.rot');
35  $handler->setFormatter($this->getIdentityFormatter());
36  $handler->handle($this->getRecord());
37 
38  $log = __DIR__.'/Fixtures/foo-'.date('Y-m-d').'.rot';
39  $this->assertTrue(file_exists($log));
40  $this->assertEquals('test', file_get_contents($log));
41  }
getRecord($level=Logger::WARNING, $message='test', $context=array())
Definition: TestCase.php:19
+ Here is the call graph for this function:

The documentation for this class was generated from the following file: