mirror of
https://github.com/Seldaek/monolog.git
synced 2025-08-03 03:37:34 +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;
|
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 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 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 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
|
* @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
|
* @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)
|
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::__construct
|
||||||
* @covers Monolog\Handler\StreamHandler::write
|
* @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')) {
|
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
|
||||||
$this->markTestSkipped('Permissions checks can not run on windows');
|
$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());
|
$handler->handle($this->getRecord());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public function provideNonExistingAndNotCreatablePath()
|
||||||
* @covers Monolog\Handler\StreamHandler::__construct
|
|
||||||
* @covers Monolog\Handler\StreamHandler::write
|
|
||||||
*/
|
|
||||||
public function testWriteNonExistingAndNotCreatableFileResource()
|
|
||||||
{
|
{
|
||||||
$this->expectException(\Exception::class);
|
return [
|
||||||
$this->expectExceptionMessage('There is no existing directory at');
|
'/foo/bar/…' => [
|
||||||
|
'/foo/bar/'.rand(0, 10000).DIRECTORY_SEPARATOR.rand(0, 10000),
|
||||||
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
|
],
|
||||||
$this->markTestSkipped('Permissions checks can not run on windows');
|
'file:///foo/bar/…' => [
|
||||||
}
|
'file:///foo/bar/'.rand(0, 10000).DIRECTORY_SEPARATOR.rand(0, 10000),
|
||||||
$handler = new StreamHandler('file:///foo/bar/'.rand(0, 10000).DIRECTORY_SEPARATOR.rand(0, 10000));
|
],
|
||||||
$handler->handle($this->getRecord());
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user