1
0
mirror of https://github.com/Seldaek/monolog.git synced 2025-08-10 07:06:40 +02:00

stream handler creates a directory if its possible

This commit is contained in:
Dominik Zogg
2015-06-21 13:05:25 +02:00
parent 49f95a2d63
commit fe12c5278f
2 changed files with 76 additions and 2 deletions

View File

@@ -112,7 +112,51 @@ class StreamHandlerTest extends TestCase
*/
public function testWriteNonExistingResource()
{
$handler = new StreamHandler('/foo/bar/baz/'.rand(0, 10000));
$handler = new StreamHandler('ftp://foo/bar/baz/'.rand(0, 10000));
$handler->handle($this->getRecord());
}
/**
* @covers Monolog\Handler\StreamHandler::__construct
* @covers Monolog\Handler\StreamHandler::write
*/
public function testWriteNonExistingPath()
{
$handler = new StreamHandler(sys_get_temp_dir().'/bar/'.rand(0, 10000).DIRECTORY_SEPARATOR.rand(0, 10000));
$handler->handle($this->getRecord());
}
/**
* @covers Monolog\Handler\StreamHandler::__construct
* @covers Monolog\Handler\StreamHandler::write
*/
public function testWriteNonExistingFileResource()
{
$handler = new StreamHandler('file://'.sys_get_temp_dir().'/bar/'.rand(0, 10000).DIRECTORY_SEPARATOR.rand(0, 10000));
$handler->handle($this->getRecord());
}
/**
* @expectedException Exception
* @expectedExceptionMessageRegExp /There is no existing directory at/
* @covers Monolog\Handler\StreamHandler::__construct
* @covers Monolog\Handler\StreamHandler::write
*/
public function testWriteNonExistingAndNotCreatablePath()
{
$handler = new StreamHandler('/foo/bar/'.rand(0, 10000).DIRECTORY_SEPARATOR.rand(0, 10000));
$handler->handle($this->getRecord());
}
/**
* @expectedException Exception
* @expectedExceptionMessageRegExp /There is no existing directory at/
* @covers Monolog\Handler\StreamHandler::__construct
* @covers Monolog\Handler\StreamHandler::write
*/
public function testWriteNonExistingAndNotCreatableFileResource()
{
$handler = new StreamHandler('file:///foo/bar/'.rand(0, 10000).DIRECTORY_SEPARATOR.rand(0, 10000));
$handler->handle($this->getRecord());
}
}