1
0
mirror of https://github.com/Seldaek/monolog.git synced 2025-08-07 05:36:45 +02:00
This commit is contained in:
Jordi Boggiano
2024-06-28 10:48:40 +02:00
parent 3ba77d1d39
commit 07cd08e0e4
34 changed files with 106 additions and 91 deletions

View File

@@ -1,4 +1,13 @@
<?php
<?php declare(strict_types=1);
/*
* This file is part of the Monolog package.
*
* (c) Jordi Boggiano <j.boggiano@seld.be>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Monolog\Attribute;
@@ -11,5 +20,4 @@ class WithMonologChannelTest extends TestCase
$attribute = new WithMonologChannel('fixture');
$this->assertSame('fixture', $attribute->channel);
}
}

View File

@@ -121,7 +121,7 @@ class JsonFormatterTest extends TestCase
public function testBasePathWithException(): void
{
$formatter = new JsonFormatter();
$formatter->setBasePath(dirname(dirname(dirname(__DIR__))));
$formatter->setBasePath(\dirname(\dirname(\dirname(__DIR__))));
$exception = new \RuntimeException('Foo');
$message = $this->formatRecordWithExceptionInContext($formatter, $exception);

View File

@@ -84,7 +84,7 @@ class NormalizerFormatterTest extends TestCase
public function testFormatExceptionWithBasePath(): void
{
$formatter = new NormalizerFormatter('Y-m-d');
$formatter->setBasePath(dirname(dirname(dirname(__DIR__))));
$formatter->setBasePath(\dirname(\dirname(\dirname(__DIR__))));
$e = new \LogicException('bar');
$formatted = $formatter->normalizeValue([
'exception' => $e,

View File

@@ -103,16 +103,25 @@ class RedisHandlerTest extends TestCase
{
$redis = new class extends \Predis\Client {
public array $testResults = [];
public function rpush(...$args) {
public function rpush(...$args)
{
$this->testResults[] = ['rpush', ...$args];
return $this;
}
public function ltrim(...$args) {
public function ltrim(...$args)
{
$this->testResults[] = ['ltrim', ...$args];
return $this;
}
public function transaction(...$args) {
public function transaction(...$args)
{
$this->testResults[] = ['transaction start'];
return ($args[0])($this);
}
};

View File

@@ -59,7 +59,8 @@ class RotatingFileHandlerTest extends TestCase
unset($this->lastError);
}
private function rrmdir($directory) {
private function rrmdir($directory)
{
if (! is_dir($directory)) {
throw new InvalidArgumentException("$directory must be a directory");
}

View File

@@ -69,6 +69,7 @@ class SymfonyMailerHandlerTest extends TestCase
// Callback dynamically changes subject based on number of logged records
$callback = function ($content, array $records) use ($expectedMessage) {
$subject = \count($records) > 0 ? 'Emergency' : 'Normal';
return $expectedMessage->subject($subject);
};
$handler = new SymfonyMailerHandler($this->mailer, $callback);

View File

@@ -285,11 +285,11 @@ class LoggerTest extends TestCase
$handler->expects($this->any())
->method('isHandling')
->willReturn(true);
;
$handler->expects($this->any())
->method('handle')
->willReturn(true);
;
$logger->pushHandler($handler);
$processor = $this->getMockBuilder('Monolog\Processor\WebProcessor')
@@ -316,7 +316,7 @@ class LoggerTest extends TestCase
$handler->expects($this->once())
->method('isHandling')
->willReturn(false);
;
$logger->pushHandler($handler);
$that = $this;
$logger->pushProcessor(function ($record) use ($that) {
@@ -337,29 +337,29 @@ class LoggerTest extends TestCase
$handler1->expects($this->never())
->method('isHandling')
->willReturn(false);
;
$handler1->expects($this->once())
->method('handle')
->willReturn(false);
;
$logger->pushHandler($handler1);
$handler2 = $this->createMock('Monolog\Handler\HandlerInterface');
$handler2->expects($this->once())
->method('isHandling')
->willReturn(true);
;
$handler2->expects($this->once())
->method('handle')
->willReturn(false);
;
$logger->pushHandler($handler2);
$handler3 = $this->createMock('Monolog\Handler\HandlerInterface');
$handler3->expects($this->once())
->method('isHandling')
->willReturn(false);
;
$handler3->expects($this->never())
->method('handle')
;
@@ -377,27 +377,25 @@ class LoggerTest extends TestCase
$handler1->expects($this->never())
->method('isHandling')
->willReturn(false);
;
$handler1->expects($this->once())
->method('handle')
->willReturn(false);
;
$handler2 = $this->createMock('Monolog\Handler\HandlerInterface');
$handler2->expects($this->once())
->method('isHandling')
->willReturn(true);
;
$handler2->expects($this->once())
->method('handle')
->willReturn(false);
;
$handler3 = $this->createMock('Monolog\Handler\HandlerInterface');
$handler3->expects($this->once())
->method('isHandling')
->willReturn(false);
;
$handler3->expects($this->never())
->method('handle')
;
@@ -419,22 +417,22 @@ class LoggerTest extends TestCase
$handler1->expects($this->any())
->method('isHandling')
->willReturn(true);
;
$handler1->expects($this->once())
->method('handle')
->willReturn(false);
;
$logger->pushHandler($handler1);
$handler2 = $this->createMock('Monolog\Handler\HandlerInterface');
$handler2->expects($this->any())
->method('isHandling')
->willReturn(true);
;
$handler2->expects($this->once())
->method('handle')
->willReturn(false);
;
$logger->pushHandler($handler2);
$logger->debug('test');
@@ -451,7 +449,7 @@ class LoggerTest extends TestCase
$handler1->expects($this->any())
->method('isHandling')
->willReturn(true);
;
$handler1->expects($this->never())
->method('handle')
;
@@ -461,11 +459,11 @@ class LoggerTest extends TestCase
$handler2->expects($this->any())
->method('isHandling')
->willReturn(true);
;
$handler2->expects($this->once())
->method('handle')
->willReturn(true);
;
$logger->pushHandler($handler2);
$logger->debug('test');
@@ -482,7 +480,6 @@ class LoggerTest extends TestCase
$handler1->expects($this->any())
->method('isHandling')
->willReturn(false);
;
$logger->pushHandler($handler1);
$this->assertFalse($logger->isHandling(Level::Debug));
@@ -491,7 +488,6 @@ class LoggerTest extends TestCase
$handler2->expects($this->any())
->method('isHandling')
->willReturn(true);
;
$logger->pushHandler($handler2);
$this->assertTrue($logger->isHandling(Level::Debug));
@@ -677,7 +673,7 @@ class LoggerTest extends TestCase
$handler->expects($this->any())
->method('isHandling')
->willReturn(true);
;
$handler->expects($this->any())
->method('handle')
->will($this->throwException(new \Exception('Some handler exception')))
@@ -706,7 +702,7 @@ class LoggerTest extends TestCase
$handler->expects($this->any())
->method('isHandling')
->willReturn(true);
;
$handler->expects($this->any())
->method('handle')
->will($this->throwException(new \Exception('Some handler exception')))
@@ -900,7 +896,6 @@ class LoggingHandler implements HandlerInterface
}
}
class FiberSuspendHandler implements HandlerInterface
{
public function isHandling(LogRecord $record): bool

View File

@@ -161,7 +161,7 @@ class PsrLogCompatTest extends TestCase
/**
* Creates a mock of a `Stringable`.
*
* @param string $string The string that must be represented by the stringable.
* @param string $string The string that must be represented by the stringable.
*/
protected function createStringable(string $string = ''): MockObject&Stringable
{