ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
Monolog\Handler\StreamHandlerTest Class Reference
+ Inheritance diagram for Monolog\Handler\StreamHandlerTest:
+ Collaboration diagram for Monolog\Handler\StreamHandlerTest:

Public Member Functions

 testWrite ()
 Monolog::__construct Monolog::write More...
 
 testCloseKeepsExternalHandlersOpen ()
 Monolog::close More...
 
 testClose ()
 Monolog::close More...
 
 testWriteCreatesTheStreamResource ()
 Monolog::write More...
 
 testWriteLocking ()
 Monolog::__construct Monolog::write More...
 
 testWriteMissingResource ()
 LogicException Monolog::__construct Monolog::write More...
 
 invalidArgumentProvider ()
 
 testWriteInvalidArgument ($invalidArgument)
 invalidArgumentProvider InvalidArgumentException Monolog::__construct More...
 
 testWriteInvalidResource ()
 UnexpectedValueException Monolog::__construct Monolog::write More...
 
 testWriteNonExistingResource ()
 UnexpectedValueException Monolog::__construct Monolog::write More...
 
 testWriteNonExistingPath ()
 Monolog::__construct Monolog::write More...
 
 testWriteNonExistingFileResource ()
 Monolog::__construct Monolog::write More...
 
 testWriteNonExistingAndNotCreatablePath ()
 Exception /There is no existing directory at/ Monolog::__construct Monolog::write More...
 
 testWriteNonExistingAndNotCreatableFileResource ()
 Exception /There is no existing directory at/ Monolog::__construct Monolog::write More...
 

Additional Inherited Members

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

Detailed Description

Definition at line 17 of file StreamHandlerTest.php.

Member Function Documentation

◆ invalidArgumentProvider()

Monolog\Handler\StreamHandlerTest::invalidArgumentProvider ( )

Definition at line 94 of file StreamHandlerTest.php.

95  {
96  return array(
97  array(1),
98  array(array()),
99  array(array('bogus://url')),
100  );
101  }

◆ testClose()

Monolog\Handler\StreamHandlerTest::testClose ( )

Monolog::close

Definition at line 50 of file StreamHandlerTest.php.

References $handler, Monolog\TestCase\getRecord(), and Monolog\Logger\WARNING.

51  {
52  $handler = new StreamHandler('php://memory');
53  $handler->handle($this->getRecord(Logger::WARNING, 'test'));
54  $streamProp = new \ReflectionProperty('Monolog\Handler\StreamHandler', 'stream');
55  $streamProp->setAccessible(true);
56  $handle = $streamProp->getValue($handler);
57 
58  $this->assertTrue(is_resource($handle));
59  $handler->close();
60  $this->assertFalse(is_resource($handle));
61  }
getRecord($level=Logger::WARNING, $message='test', $context=array())
Definition: TestCase.php:19
const WARNING
Exceptional occurrences that are not errors.
Definition: Logger.php:53
$handler
+ Here is the call graph for this function:

◆ testCloseKeepsExternalHandlersOpen()

Monolog\Handler\StreamHandlerTest::testCloseKeepsExternalHandlersOpen ( )

Monolog::close

Definition at line 38 of file StreamHandlerTest.php.

References $handler.

39  {
40  $handle = fopen('php://memory', 'a+');
41  $handler = new StreamHandler($handle);
42  $this->assertTrue(is_resource($handle));
43  $handler->close();
44  $this->assertTrue(is_resource($handle));
45  }
$handler

◆ testWrite()

Monolog\Handler\StreamHandlerTest::testWrite ( )

Monolog::__construct Monolog::write

Definition at line 23 of file StreamHandlerTest.php.

References $handler, Monolog\TestCase\getIdentityFormatter(), Monolog\TestCase\getRecord(), and Monolog\Logger\WARNING.

24  {
25  $handle = fopen('php://memory', 'a+');
26  $handler = new StreamHandler($handle);
27  $handler->setFormatter($this->getIdentityFormatter());
28  $handler->handle($this->getRecord(Logger::WARNING, 'test'));
29  $handler->handle($this->getRecord(Logger::WARNING, 'test2'));
30  $handler->handle($this->getRecord(Logger::WARNING, 'test3'));
31  fseek($handle, 0);
32  $this->assertEquals('testtest2test3', fread($handle, 100));
33  }
getRecord($level=Logger::WARNING, $message='test', $context=array())
Definition: TestCase.php:19
const WARNING
Exceptional occurrences that are not errors.
Definition: Logger.php:53
$handler
+ Here is the call graph for this function:

◆ testWriteCreatesTheStreamResource()

Monolog\Handler\StreamHandlerTest::testWriteCreatesTheStreamResource ( )

Monolog::write

Definition at line 66 of file StreamHandlerTest.php.

References $handler, and Monolog\TestCase\getRecord().

67  {
68  $handler = new StreamHandler('php://memory');
69  $handler->handle($this->getRecord());
70  }
getRecord($level=Logger::WARNING, $message='test', $context=array())
Definition: TestCase.php:19
$handler
+ Here is the call graph for this function:

◆ testWriteInvalidArgument()

Monolog\Handler\StreamHandlerTest::testWriteInvalidArgument (   $invalidArgument)

invalidArgumentProvider InvalidArgumentException Monolog::__construct

Definition at line 108 of file StreamHandlerTest.php.

References $handler.

109  {
110  $handler = new StreamHandler($invalidArgument);
111  }
$handler

◆ testWriteInvalidResource()

Monolog\Handler\StreamHandlerTest::testWriteInvalidResource ( )

UnexpectedValueException Monolog::__construct Monolog::write

Definition at line 118 of file StreamHandlerTest.php.

References $handler, and Monolog\TestCase\getRecord().

119  {
120  $handler = new StreamHandler('bogus://url');
121  $handler->handle($this->getRecord());
122  }
getRecord($level=Logger::WARNING, $message='test', $context=array())
Definition: TestCase.php:19
$handler
+ Here is the call graph for this function:

◆ testWriteLocking()

Monolog\Handler\StreamHandlerTest::testWriteLocking ( )

Monolog::__construct Monolog::write

Definition at line 76 of file StreamHandlerTest.php.

References $handler, Monolog\Logger\DEBUG, and Monolog\TestCase\getRecord().

77  {
78  $temp = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'monolog_locked_log';
79  $handler = new StreamHandler($temp, Logger::DEBUG, true, null, true);
80  $handler->handle($this->getRecord());
81  }
const DEBUG
Detailed debug information.
Definition: Logger.php:33
getRecord($level=Logger::WARNING, $message='test', $context=array())
Definition: TestCase.php:19
$handler
+ Here is the call graph for this function:

◆ testWriteMissingResource()

Monolog\Handler\StreamHandlerTest::testWriteMissingResource ( )

LogicException Monolog::__construct Monolog::write

Definition at line 88 of file StreamHandlerTest.php.

References $handler, and Monolog\TestCase\getRecord().

89  {
90  $handler = new StreamHandler(null);
91  $handler->handle($this->getRecord());
92  }
getRecord($level=Logger::WARNING, $message='test', $context=array())
Definition: TestCase.php:19
$handler
+ Here is the call graph for this function:

◆ testWriteNonExistingAndNotCreatableFileResource()

Monolog\Handler\StreamHandlerTest::testWriteNonExistingAndNotCreatableFileResource ( )

Exception /There is no existing directory at/ Monolog::__construct Monolog::write

Definition at line 176 of file StreamHandlerTest.php.

References $handler, and Monolog\TestCase\getRecord().

177  {
178  if (defined('PHP_WINDOWS_VERSION_BUILD')) {
179  $this->markTestSkipped('Permissions checks can not run on windows');
180  }
181  $handler = new StreamHandler('file:///foo/bar/'.rand(0, 10000).DIRECTORY_SEPARATOR.rand(0, 10000));
182  $handler->handle($this->getRecord());
183  }
getRecord($level=Logger::WARNING, $message='test', $context=array())
Definition: TestCase.php:19
$handler
+ Here is the call graph for this function:

◆ testWriteNonExistingAndNotCreatablePath()

Monolog\Handler\StreamHandlerTest::testWriteNonExistingAndNotCreatablePath ( )

Exception /There is no existing directory at/ Monolog::__construct Monolog::write

Definition at line 161 of file StreamHandlerTest.php.

References $handler, and Monolog\TestCase\getRecord().

162  {
163  if (defined('PHP_WINDOWS_VERSION_BUILD')) {
164  $this->markTestSkipped('Permissions checks can not run on windows');
165  }
166  $handler = new StreamHandler('/foo/bar/'.rand(0, 10000).DIRECTORY_SEPARATOR.rand(0, 10000));
167  $handler->handle($this->getRecord());
168  }
getRecord($level=Logger::WARNING, $message='test', $context=array())
Definition: TestCase.php:19
$handler
+ Here is the call graph for this function:

◆ testWriteNonExistingFileResource()

Monolog\Handler\StreamHandlerTest::testWriteNonExistingFileResource ( )

Monolog::__construct Monolog::write

Definition at line 149 of file StreamHandlerTest.php.

References $handler, and Monolog\TestCase\getRecord().

150  {
151  $handler = new StreamHandler('file://'.sys_get_temp_dir().'/bar/'.rand(0, 10000).DIRECTORY_SEPARATOR.rand(0, 10000));
152  $handler->handle($this->getRecord());
153  }
getRecord($level=Logger::WARNING, $message='test', $context=array())
Definition: TestCase.php:19
$handler
+ Here is the call graph for this function:

◆ testWriteNonExistingPath()

Monolog\Handler\StreamHandlerTest::testWriteNonExistingPath ( )

Monolog::__construct Monolog::write

Definition at line 139 of file StreamHandlerTest.php.

References $handler, and Monolog\TestCase\getRecord().

140  {
141  $handler = new StreamHandler(sys_get_temp_dir().'/bar/'.rand(0, 10000).DIRECTORY_SEPARATOR.rand(0, 10000));
142  $handler->handle($this->getRecord());
143  }
getRecord($level=Logger::WARNING, $message='test', $context=array())
Definition: TestCase.php:19
$handler
+ Here is the call graph for this function:

◆ testWriteNonExistingResource()

Monolog\Handler\StreamHandlerTest::testWriteNonExistingResource ( )

UnexpectedValueException Monolog::__construct Monolog::write

Definition at line 129 of file StreamHandlerTest.php.

References $handler, and Monolog\TestCase\getRecord().

130  {
131  $handler = new StreamHandler('ftp://foo/bar/baz/'.rand(0, 10000));
132  $handler->handle($this->getRecord());
133  }
getRecord($level=Logger::WARNING, $message='test', $context=array())
Definition: TestCase.php:19
$handler
+ Here is the call graph for this function:

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