mirror of
https://github.com/Seldaek/monolog.git
synced 2025-07-31 18:30:15 +02:00
Merge pull request #1400 from tpraxl/fix/docblock
Fix misleading @throws tag in StreamHandler doc
This commit is contained in:
@@ -32,13 +32,12 @@ class StreamHandler extends AbstractProcessingHandler
|
||||
private $dirCreated;
|
||||
|
||||
/**
|
||||
* @param resource|string $stream
|
||||
* @param resource|string $stream If a missing path can't be created, an UnexpectedValueException will be thrown on first write
|
||||
* @param string|int $level The minimum logging level at which this handler will be triggered
|
||||
* @param bool $bubble Whether the messages that are handled can bubble up the stack or not
|
||||
* @param int|null $filePermission Optional file permissions (default (0644) are only for owner read/write)
|
||||
* @param bool $useLocking Try to lock log file before doing any writes
|
||||
*
|
||||
* @throws \Exception If a missing directory is not buildable
|
||||
* @throws \InvalidArgumentException If stream is not a resource or string
|
||||
*/
|
||||
public function __construct($stream, $level = Logger::DEBUG, bool $bubble = true, ?int $filePermission = null, bool $useLocking = false)
|
||||
|
@@ -184,33 +184,40 @@ class StreamHandlerTest extends TestCase
|
||||
/**
|
||||
* @covers Monolog\Handler\StreamHandler::__construct
|
||||
* @covers Monolog\Handler\StreamHandler::write
|
||||
* @dataProvider provideNonExistingAndNotCreatablePath
|
||||
*/
|
||||
public function testWriteNonExistingAndNotCreatablePath()
|
||||
public function testWriteNonExistingAndNotCreatablePath($nonExistingAndNotCreatablePath)
|
||||
{
|
||||
$this->expectException(\Exception::class);
|
||||
$this->expectExceptionMessage('There is no existing directory at');
|
||||
|
||||
|
||||
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
|
||||
$this->markTestSkipped('Permissions checks can not run on windows');
|
||||
}
|
||||
$handler = new StreamHandler('/foo/bar/'.rand(0, 10000).DIRECTORY_SEPARATOR.rand(0, 10000));
|
||||
|
||||
$handler = null;
|
||||
|
||||
try {
|
||||
$handler = new StreamHandler($nonExistingAndNotCreatablePath);
|
||||
} catch (\Exception $fail) {
|
||||
$this->fail(
|
||||
'A non-existing and not creatable path should throw an Exception earliest on first write.
|
||||
Not during instantiation.'
|
||||
);
|
||||
}
|
||||
|
||||
$this->expectException(\UnexpectedValueException::class);
|
||||
$this->expectExceptionMessage('There is no existing directory at');
|
||||
|
||||
$handler->handle($this->getRecord());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Monolog\Handler\StreamHandler::__construct
|
||||
* @covers Monolog\Handler\StreamHandler::write
|
||||
*/
|
||||
public function testWriteNonExistingAndNotCreatableFileResource()
|
||||
public function provideNonExistingAndNotCreatablePath()
|
||||
{
|
||||
$this->expectException(\Exception::class);
|
||||
$this->expectExceptionMessage('There is no existing directory at');
|
||||
|
||||
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
|
||||
$this->markTestSkipped('Permissions checks can not run on windows');
|
||||
}
|
||||
$handler = new StreamHandler('file:///foo/bar/'.rand(0, 10000).DIRECTORY_SEPARATOR.rand(0, 10000));
|
||||
$handler->handle($this->getRecord());
|
||||
return [
|
||||
'/foo/bar/…' => [
|
||||
'/foo/bar/'.rand(0, 10000).DIRECTORY_SEPARATOR.rand(0, 10000),
|
||||
],
|
||||
'file:///foo/bar/…' => [
|
||||
'file:///foo/bar/'.rand(0, 10000).DIRECTORY_SEPARATOR.rand(0, 10000),
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user