mirror of
https://github.com/Seldaek/monolog.git
synced 2025-08-03 11:47:38 +02:00
Fix phpunit deprecations
This commit is contained in:
@@ -29,7 +29,7 @@
|
||||
"phpstan/phpstan": "^1.9",
|
||||
"phpstan/phpstan-deprecation-rules": "^1.0",
|
||||
"phpstan/phpstan-strict-rules": "^1.4",
|
||||
"phpunit/phpunit": "^10.1",
|
||||
"phpunit/phpunit": "^10.5.17",
|
||||
"predis/predis": "^1.1 || ^2",
|
||||
"ruflin/elastica": "^7",
|
||||
"symfony/mailer": "^5.4 || ^6",
|
||||
|
@@ -12,6 +12,8 @@
|
||||
namespace Monolog;
|
||||
|
||||
use Monolog\Handler\TestHandler;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use PHPUnit\Framework\Attributes\WithoutErrorHandler;
|
||||
use Psr\Log\LogLevel;
|
||||
|
||||
class ErrorHandlerTest extends \PHPUnit\Framework\TestCase
|
||||
@@ -23,6 +25,7 @@ class ErrorHandlerTest extends \PHPUnit\Framework\TestCase
|
||||
$this->assertInstanceOf(ErrorHandler::class, ErrorHandler::register($logger, false, false, false));
|
||||
}
|
||||
|
||||
#[WithoutErrorHandler]
|
||||
public function testHandleError()
|
||||
{
|
||||
$logger = new Logger('test', [$handler = new TestHandler]);
|
||||
@@ -44,7 +47,9 @@ class ErrorHandlerTest extends \PHPUnit\Framework\TestCase
|
||||
$this->assertTrue($handler->hasErrorRecords());
|
||||
trigger_error('Foo', E_USER_NOTICE);
|
||||
$this->assertCount(2, $handler->getRecords());
|
||||
// check that the remapping of notice to emergency above worked
|
||||
$this->assertTrue($handler->hasEmergencyRecords());
|
||||
$this->assertFalse($handler->hasNoticeRecords());
|
||||
} finally {
|
||||
// restore previous handler
|
||||
set_error_handler($phpunitHandler);
|
||||
@@ -68,9 +73,8 @@ class ErrorHandlerTest extends \PHPUnit\Framework\TestCase
|
||||
return $prop->getValue($instance);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider fatalHandlerProvider
|
||||
*/
|
||||
#[DataProvider('fatalHandlerProvider')]
|
||||
#[WithoutErrorHandler]
|
||||
public function testFatalHandler(
|
||||
$level,
|
||||
$reservedMemorySize,
|
||||
|
@@ -13,6 +13,7 @@ namespace Monolog\Formatter;
|
||||
|
||||
use Monolog\Test\TestCase;
|
||||
use Monolog\Level;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use RuntimeException;
|
||||
|
||||
/**
|
||||
@@ -291,9 +292,7 @@ class LineFormatterTest extends TestCase
|
||||
$this->assertStringContainsString(' #1', $message);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerMaxLevelNameLength
|
||||
*/
|
||||
#[DataProvider('providerMaxLevelNameLength')]
|
||||
public function testMaxLevelNameLength(?int $maxLength, Level $logLevel, string $expectedLevelName): void
|
||||
{
|
||||
$formatter = new LineFormatter();
|
||||
@@ -307,21 +306,21 @@ class LineFormatterTest extends TestCase
|
||||
{
|
||||
return [
|
||||
'info_no_max_length' => [
|
||||
'max_length' => null,
|
||||
'level' => Level::Info,
|
||||
'expected_level_name' => 'INFO',
|
||||
'maxLength' => null,
|
||||
'logLevel' => Level::Info,
|
||||
'expectedLevelName' => 'INFO',
|
||||
],
|
||||
|
||||
'error_max_length_3' => [
|
||||
'max_length' => 3,
|
||||
'level' => Level::Error,
|
||||
'expected_level_name' => 'ERR',
|
||||
'maxLength' => 3,
|
||||
'logLevel' => Level::Error,
|
||||
'expectedLevelName' => 'ERR',
|
||||
],
|
||||
|
||||
'debug_max_length_2' => [
|
||||
'max_length' => 2,
|
||||
'level' => Level::Debug,
|
||||
'expected_level_name' => 'DE',
|
||||
'maxLength' => 2,
|
||||
'logLevel' => Level::Debug,
|
||||
'expectedLevelName' => 'DE',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
@@ -16,6 +16,7 @@ use MongoDB\BSON\Regex;
|
||||
use MongoDB\BSON\UTCDateTime;
|
||||
use Monolog\Level;
|
||||
use Monolog\Test\TestCase;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
|
||||
/**
|
||||
* @author Florian Plattner <me@florianplattner.de>
|
||||
@@ -37,14 +38,7 @@ class MongoDBFormatterTest extends TestCase
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $traceDepth
|
||||
* @param $traceAsString
|
||||
* @param $expectedTraceDepth
|
||||
* @param $expectedTraceAsString
|
||||
*
|
||||
* @dataProvider constructArgumentProvider
|
||||
*/
|
||||
#[DataProvider('constructArgumentProvider')]
|
||||
public function testConstruct($traceDepth, $traceAsString, $expectedTraceDepth, $expectedTraceAsString)
|
||||
{
|
||||
$formatter = new MongoDBFormatter($traceDepth, $traceAsString);
|
||||
|
@@ -14,23 +14,16 @@ namespace Monolog\Formatter;
|
||||
use DateTimeImmutable;
|
||||
use Monolog\Level;
|
||||
use Monolog\LogRecord;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class SyslogFormatterTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider formatDataProvider
|
||||
*
|
||||
* @param string $expected
|
||||
* @param DateTimeImmutable $dateTime
|
||||
* @param string $channel
|
||||
* @param Level $level
|
||||
* @param string $message
|
||||
* @param string|null $appName
|
||||
* @param mixed[] $context
|
||||
* @param mixed[] $extra
|
||||
* @return void
|
||||
*/
|
||||
#[DataProvider('formatDataProvider')]
|
||||
public function testFormat(
|
||||
string $expected,
|
||||
DateTimeImmutable $dateTime,
|
||||
|
@@ -25,7 +25,7 @@ class AbstractHandlerTest extends TestCase
|
||||
*/
|
||||
public function testConstructAndGetSet()
|
||||
{
|
||||
$handler = $this->getMockForAbstractClass('Monolog\Handler\AbstractHandler', [Level::Warning, false]);
|
||||
$handler = $this->getMockBuilder('Monolog\Handler\AbstractHandler')->setConstructorArgs([Level::Warning, false])->onlyMethods(['handle'])->getMock();
|
||||
$this->assertEquals(Level::Warning, $handler->getLevel());
|
||||
$this->assertEquals(false, $handler->getBubble());
|
||||
|
||||
@@ -40,7 +40,7 @@ class AbstractHandlerTest extends TestCase
|
||||
*/
|
||||
public function testHandleBatch()
|
||||
{
|
||||
$handler = $this->getMockForAbstractClass('Monolog\Handler\AbstractHandler');
|
||||
$handler = $this->createPartialMock('Monolog\Handler\AbstractHandler', ['handle']);
|
||||
$handler->expects($this->exactly(2))
|
||||
->method('handle');
|
||||
$handler->handleBatch([$this->getRecord(), $this->getRecord()]);
|
||||
@@ -51,7 +51,7 @@ class AbstractHandlerTest extends TestCase
|
||||
*/
|
||||
public function testIsHandling()
|
||||
{
|
||||
$handler = $this->getMockForAbstractClass('Monolog\Handler\AbstractHandler', [Level::Warning, false]);
|
||||
$handler = $this->getMockBuilder('Monolog\Handler\AbstractHandler')->setConstructorArgs([Level::Warning, false])->onlyMethods(['handle'])->getMock();
|
||||
$this->assertTrue($handler->isHandling($this->getRecord()));
|
||||
$this->assertFalse($handler->isHandling($this->getRecord(Level::Debug)));
|
||||
}
|
||||
@@ -61,7 +61,7 @@ class AbstractHandlerTest extends TestCase
|
||||
*/
|
||||
public function testHandlesPsrStyleLevels()
|
||||
{
|
||||
$handler = $this->getMockForAbstractClass('Monolog\Handler\AbstractHandler', ['warning', false]);
|
||||
$handler = $this->getMockBuilder('Monolog\Handler\AbstractHandler')->setConstructorArgs(['warning', false])->onlyMethods(['handle'])->getMock();
|
||||
$this->assertFalse($handler->isHandling($this->getRecord(Level::Debug)));
|
||||
$handler->setLevel('debug');
|
||||
$this->assertTrue($handler->isHandling($this->getRecord(Level::Debug)));
|
||||
|
@@ -24,7 +24,7 @@ class AbstractProcessingHandlerTest extends TestCase
|
||||
*/
|
||||
public function testConstructAndGetSet()
|
||||
{
|
||||
$handler = $this->getMockForAbstractClass('Monolog\Handler\AbstractProcessingHandler', [Level::Warning, false]);
|
||||
$handler = $this->getMockBuilder('Monolog\Handler\AbstractProcessingHandler')->setConstructorArgs([Level::Warning, false])->onlyMethods(['write'])->getMock();
|
||||
$handler->setFormatter($formatter = new LineFormatter);
|
||||
$this->assertSame($formatter, $handler->getFormatter());
|
||||
}
|
||||
@@ -34,7 +34,7 @@ class AbstractProcessingHandlerTest extends TestCase
|
||||
*/
|
||||
public function testHandleLowerLevelMessage()
|
||||
{
|
||||
$handler = $this->getMockForAbstractClass('Monolog\Handler\AbstractProcessingHandler', [Level::Warning, true]);
|
||||
$handler = $this->getMockBuilder('Monolog\Handler\AbstractProcessingHandler')->setConstructorArgs([Level::Warning, true])->onlyMethods(['write'])->getMock();
|
||||
$this->assertFalse($handler->handle($this->getRecord(Level::Debug)));
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ class AbstractProcessingHandlerTest extends TestCase
|
||||
*/
|
||||
public function testHandleBubbling()
|
||||
{
|
||||
$handler = $this->getMockForAbstractClass('Monolog\Handler\AbstractProcessingHandler', [Level::Debug, true]);
|
||||
$handler = $this->getMockBuilder('Monolog\Handler\AbstractProcessingHandler')->setConstructorArgs([Level::Debug, true])->onlyMethods(['write'])->getMock();
|
||||
$this->assertFalse($handler->handle($this->getRecord()));
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ class AbstractProcessingHandlerTest extends TestCase
|
||||
*/
|
||||
public function testHandleNotBubbling()
|
||||
{
|
||||
$handler = $this->getMockForAbstractClass('Monolog\Handler\AbstractProcessingHandler', [Level::Debug, false]);
|
||||
$handler = $this->getMockBuilder('Monolog\Handler\AbstractProcessingHandler')->setConstructorArgs([Level::Debug, false])->onlyMethods(['write'])->getMock();
|
||||
$this->assertTrue($handler->handle($this->getRecord()));
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ class AbstractProcessingHandlerTest extends TestCase
|
||||
*/
|
||||
public function testHandleIsFalseWhenNotHandled()
|
||||
{
|
||||
$handler = $this->getMockForAbstractClass('Monolog\Handler\AbstractProcessingHandler', [Level::Warning, false]);
|
||||
$handler = $this->getMockBuilder('Monolog\Handler\AbstractProcessingHandler')->setConstructorArgs([Level::Warning, false])->onlyMethods(['write'])->getMock();
|
||||
$this->assertTrue($handler->handle($this->getRecord()));
|
||||
$this->assertFalse($handler->handle($this->getRecord(Level::Debug)));
|
||||
}
|
||||
@@ -71,7 +71,7 @@ class AbstractProcessingHandlerTest extends TestCase
|
||||
*/
|
||||
public function testProcessRecord()
|
||||
{
|
||||
$handler = $this->getMockForAbstractClass('Monolog\Handler\AbstractProcessingHandler');
|
||||
$handler = $this->createPartialMock('Monolog\Handler\AbstractProcessingHandler', ['write']);
|
||||
$handler->pushProcessor(new WebProcessor([
|
||||
'REQUEST_URI' => '',
|
||||
'REQUEST_METHOD' => '',
|
||||
@@ -82,9 +82,9 @@ class AbstractProcessingHandlerTest extends TestCase
|
||||
$handledRecord = null;
|
||||
$handler->expects($this->once())
|
||||
->method('write')
|
||||
->will($this->returnCallback(function ($record) use (&$handledRecord) {
|
||||
->willReturnCallback(function ($record) use (&$handledRecord) {
|
||||
$handledRecord = $record;
|
||||
}))
|
||||
})
|
||||
;
|
||||
$handler->handle($this->getRecord());
|
||||
$this->assertEquals(6, count($handledRecord['extra']));
|
||||
@@ -96,7 +96,7 @@ class AbstractProcessingHandlerTest extends TestCase
|
||||
*/
|
||||
public function testPushPopProcessor()
|
||||
{
|
||||
$logger = $this->getMockForAbstractClass('Monolog\Handler\AbstractProcessingHandler');
|
||||
$logger = $this->createPartialMock('Monolog\Handler\AbstractProcessingHandler', ['write']);
|
||||
$processor1 = new WebProcessor;
|
||||
$processor2 = new WebProcessor;
|
||||
|
||||
@@ -116,7 +116,7 @@ class AbstractProcessingHandlerTest extends TestCase
|
||||
*/
|
||||
public function testPushProcessorWithNonCallable()
|
||||
{
|
||||
$handler = $this->getMockForAbstractClass('Monolog\Handler\AbstractProcessingHandler');
|
||||
$handler = $this->createPartialMock('Monolog\Handler\AbstractProcessingHandler', ['write']);
|
||||
|
||||
$this->expectException(\TypeError::class);
|
||||
|
||||
@@ -129,7 +129,7 @@ class AbstractProcessingHandlerTest extends TestCase
|
||||
*/
|
||||
public function testGetFormatterInitializesDefault()
|
||||
{
|
||||
$handler = $this->getMockForAbstractClass('Monolog\Handler\AbstractProcessingHandler');
|
||||
$handler = $this->createPartialMock('Monolog\Handler\AbstractProcessingHandler', ['write']);
|
||||
$this->assertInstanceOf(LineFormatter::class, $handler->getFormatter());
|
||||
}
|
||||
}
|
||||
|
@@ -39,9 +39,9 @@ class AmqpHandlerTest extends TestCase
|
||||
|
||||
$exchange->expects($this->any())
|
||||
->method('publish')
|
||||
->will($this->returnCallback(function ($message, $routing_key, $flags = 0, $attributes = []) use (&$messages) {
|
||||
->willReturnCallback(function ($message, $routing_key, $flags = 0, $attributes = []) use (&$messages) {
|
||||
$messages[] = [$message, $routing_key, $flags, $attributes];
|
||||
}))
|
||||
})
|
||||
;
|
||||
|
||||
$handler = new AmqpHandler($exchange);
|
||||
@@ -96,9 +96,9 @@ class AmqpHandlerTest extends TestCase
|
||||
|
||||
$exchange->expects($this->any())
|
||||
->method('basic_publish')
|
||||
->will($this->returnCallback(function (AMQPMessage $msg, $exchange = "", $routing_key = "", $mandatory = false, $immediate = false, $ticket = null) use (&$messages) {
|
||||
->willReturnCallback(function (AMQPMessage $msg, $exchange = "", $routing_key = "", $mandatory = false, $immediate = false, $ticket = null) use (&$messages) {
|
||||
$messages[] = [$msg, $exchange, $routing_key, $mandatory, $immediate, $ticket];
|
||||
}))
|
||||
})
|
||||
;
|
||||
|
||||
$handler = new AmqpHandler($exchange, 'log');
|
||||
|
@@ -13,6 +13,7 @@ namespace Monolog\Handler;
|
||||
|
||||
use Monolog\Test\TestCase;
|
||||
use Monolog\Level;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
|
||||
/**
|
||||
* @covers Monolog\Handler\ChromePHPHandler
|
||||
@@ -25,9 +26,7 @@ class ChromePHPHandlerTest extends TestCase
|
||||
$_SERVER['HTTP_USER_AGENT'] = 'Monolog Test; Chrome/1.0';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider agentsProvider
|
||||
*/
|
||||
#[DataProvider('agentsProvider')]
|
||||
public function testHeaders($agent)
|
||||
{
|
||||
$_SERVER['HTTP_USER_AGENT'] = $agent;
|
||||
|
@@ -30,19 +30,10 @@ class DynamoDbHandlerTest extends TestCase
|
||||
$this->isV3 = defined('Aws\Sdk::VERSION') && version_compare(\Aws\Sdk::VERSION, '3.0', '>=');
|
||||
|
||||
$implementedMethods = ['__call'];
|
||||
$absentMethods = [];
|
||||
if (method_exists(DynamoDbClient::class, 'formatAttributes')) {
|
||||
$implementedMethods[] = 'formatAttributes';
|
||||
} else {
|
||||
$absentMethods[] = 'formatAttributes';
|
||||
}
|
||||
|
||||
$clientMockBuilder = $this->getMockBuilder(DynamoDbClient::class)
|
||||
->onlyMethods($implementedMethods)
|
||||
->disableOriginalConstructor();
|
||||
if ($absentMethods) {
|
||||
$clientMockBuilder->addMethods($absentMethods);
|
||||
}
|
||||
|
||||
$this->client = $clientMockBuilder->getMock();
|
||||
}
|
||||
@@ -78,12 +69,7 @@ class DynamoDbHandlerTest extends TestCase
|
||||
->expects($this->once())
|
||||
->method('format')
|
||||
->with($record)
|
||||
->will($this->returnValue($formatted));
|
||||
$this->client
|
||||
->expects($this->isV3 ? $this->never() : $this->once())
|
||||
->method('formatAttributes')
|
||||
->with($this->isType('array'))
|
||||
->will($this->returnValue($formatted));
|
||||
->willReturn($formatted);
|
||||
$this->client
|
||||
->expects($this->once())
|
||||
->method('__call')
|
||||
|
@@ -18,6 +18,7 @@ use Monolog\Level;
|
||||
use Elastica\Client;
|
||||
use Elastica\Request;
|
||||
use Elastica\Response;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
|
||||
/**
|
||||
* @group Elastica
|
||||
@@ -128,8 +129,8 @@ class ElasticaHandlerTest extends TestCase
|
||||
|
||||
/**
|
||||
* @covers Monolog\Handler\ElasticaHandler::bulkSend
|
||||
* @dataProvider providerTestConnectionErrors
|
||||
*/
|
||||
#[DataProvider('providerTestConnectionErrors')]
|
||||
public function testConnectionErrors($ignore, $expectedError)
|
||||
{
|
||||
$clientOpts = ['host' => '127.0.0.1', 'port' => 1];
|
||||
|
@@ -19,10 +19,13 @@ use Elasticsearch\Client;
|
||||
use Elastic\Elasticsearch\Client as Client8;
|
||||
use Elasticsearch\ClientBuilder;
|
||||
use Elastic\Elasticsearch\ClientBuilder as ClientBuilder8;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
|
||||
/**
|
||||
* @group Elasticsearch
|
||||
*/
|
||||
#[CoversClass(ElasticsearchHandler::class)]
|
||||
class ElasticsearchHandlerTest extends TestCase
|
||||
{
|
||||
protected Client|Client8 $client;
|
||||
@@ -57,9 +60,6 @@ class ElasticsearchHandlerTest extends TestCase
|
||||
unset($this->client);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Monolog\Handler\ElasticsearchHandler::setFormatter
|
||||
*/
|
||||
public function testSetFormatter()
|
||||
{
|
||||
$handler = new ElasticsearchHandler($this->client);
|
||||
@@ -70,9 +70,6 @@ class ElasticsearchHandlerTest extends TestCase
|
||||
$this->assertEquals('type_new', $handler->getFormatter()->getType());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Monolog\Handler\ElasticsearchHandler::setFormatter
|
||||
*/
|
||||
public function testSetFormatterInvalid()
|
||||
{
|
||||
$handler = new ElasticsearchHandler($this->client);
|
||||
@@ -84,10 +81,6 @@ class ElasticsearchHandlerTest extends TestCase
|
||||
$handler->setFormatter($formatter);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Monolog\Handler\ElasticsearchHandler::__construct
|
||||
* @covers Monolog\Handler\ElasticsearchHandler::getOptions
|
||||
*/
|
||||
public function testOptions()
|
||||
{
|
||||
$expected = [
|
||||
@@ -105,10 +98,7 @@ class ElasticsearchHandlerTest extends TestCase
|
||||
$this->assertEquals($expected, $handler->getOptions());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Monolog\Handler\ElasticsearchHandler::bulkSend
|
||||
* @dataProvider providerTestConnectionErrors
|
||||
*/
|
||||
#[DataProvider('providerTestConnectionErrors')]
|
||||
public function testConnectionErrors($ignore, $expectedError)
|
||||
{
|
||||
$hosts = ['http://127.0.0.1:1'];
|
||||
|
@@ -78,13 +78,12 @@ class FlowdockHandlerTest extends TestCase
|
||||
|
||||
$this->handler->expects($this->any())
|
||||
->method('fsockopen')
|
||||
->will($this->returnValue($this->res));
|
||||
->willReturn($this->res);
|
||||
$this->handler->expects($this->any())
|
||||
->method('streamSetTimeout')
|
||||
->will($this->returnValue(true));
|
||||
->willReturn(true);
|
||||
$this->handler->expects($this->any())
|
||||
->method('closeSocket')
|
||||
->will($this->returnValue(true));
|
||||
->method('closeSocket');
|
||||
|
||||
$this->handler->setFormatter(new FlowdockFormatter('test_source', 'source@test.com'));
|
||||
}
|
||||
|
@@ -12,6 +12,7 @@
|
||||
namespace Monolog\Handler;
|
||||
|
||||
use Monolog\Test\TestCase;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
|
||||
/**
|
||||
@@ -45,11 +46,8 @@ class HandlerWrapperTest extends TestCase
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $result
|
||||
* @dataProvider trueFalseDataProvider
|
||||
*/
|
||||
public function testIsHandling($result)
|
||||
#[DataProvider('trueFalseDataProvider')]
|
||||
public function testIsHandling(bool $result)
|
||||
{
|
||||
$record = $this->getRecord();
|
||||
$this->handler->expects($this->once())
|
||||
@@ -60,11 +58,8 @@ class HandlerWrapperTest extends TestCase
|
||||
$this->assertEquals($result, $this->wrapper->isHandling($record));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $result
|
||||
* @dataProvider trueFalseDataProvider
|
||||
*/
|
||||
public function testHandle($result)
|
||||
#[DataProvider('trueFalseDataProvider')]
|
||||
public function testHandle(bool $result)
|
||||
{
|
||||
$record = $this->getRecord();
|
||||
$this->handler->expects($this->once())
|
||||
@@ -75,11 +70,8 @@ class HandlerWrapperTest extends TestCase
|
||||
$this->assertEquals($result, $this->wrapper->handle($record));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $result
|
||||
* @dataProvider trueFalseDataProvider
|
||||
*/
|
||||
public function testHandleBatch($result)
|
||||
#[DataProvider('trueFalseDataProvider')]
|
||||
public function testHandleBatch(bool $result)
|
||||
{
|
||||
$records = $this->getMultipleRecords();
|
||||
$this->handler->expects($this->once())
|
||||
|
@@ -73,12 +73,11 @@ class InsightOpsHandlerTest extends TestCase
|
||||
|
||||
$this->handler->expects($this->any())
|
||||
->method('fsockopen')
|
||||
->will($this->returnValue($this->resource));
|
||||
->willReturn($this->resource);
|
||||
$this->handler->expects($this->any())
|
||||
->method('streamSetTimeout')
|
||||
->will($this->returnValue(true));
|
||||
->willReturn(true);
|
||||
$this->handler->expects($this->any())
|
||||
->method('closeSocket')
|
||||
->will($this->returnValue(true));
|
||||
->method('closeSocket');
|
||||
}
|
||||
}
|
||||
|
@@ -77,12 +77,11 @@ class LogEntriesHandlerTest extends TestCase
|
||||
|
||||
$this->handler->expects($this->any())
|
||||
->method('fsockopen')
|
||||
->will($this->returnValue($this->res));
|
||||
->willReturn($this->res);
|
||||
$this->handler->expects($this->any())
|
||||
->method('streamSetTimeout')
|
||||
->will($this->returnValue(true));
|
||||
->willReturn(true);
|
||||
$this->handler->expects($this->any())
|
||||
->method('closeSocket')
|
||||
->will($this->returnValue(true));
|
||||
->method('closeSocket');
|
||||
}
|
||||
}
|
||||
|
@@ -77,12 +77,11 @@ class LogmaticHandlerTest extends TestCase
|
||||
|
||||
$this->handler->expects($this->any())
|
||||
->method('fsockopen')
|
||||
->will($this->returnValue($this->res));
|
||||
->willReturn($this->res);
|
||||
$this->handler->expects($this->any())
|
||||
->method('streamSetTimeout')
|
||||
->will($this->returnValue(true));
|
||||
->willReturn(true);
|
||||
$this->handler->expects($this->any())
|
||||
->method('closeSocket')
|
||||
->will($this->returnValue(true));
|
||||
->method('closeSocket');
|
||||
}
|
||||
}
|
||||
|
@@ -21,11 +21,11 @@ class MailHandlerTest extends TestCase
|
||||
*/
|
||||
public function testHandleBatch()
|
||||
{
|
||||
$formatter = $this->createMock('Monolog\\Formatter\\FormatterInterface');
|
||||
$formatter = $this->createMock('Monolog\Formatter\FormatterInterface');
|
||||
$formatter->expects($this->once())
|
||||
->method('formatBatch'); // Each record is formatted
|
||||
|
||||
$handler = $this->getMockForAbstractClass('Monolog\\Handler\\MailHandler', [], '', true, true, true, ['send', 'write']);
|
||||
$handler = $this->createPartialMock('Monolog\Handler\MailHandler', ['send', 'write']);
|
||||
$handler->expects($this->once())
|
||||
->method('send');
|
||||
$handler->expects($this->never())
|
||||
@@ -47,7 +47,7 @@ class MailHandlerTest extends TestCase
|
||||
$this->getRecord(Level::Info, 'information'),
|
||||
];
|
||||
|
||||
$handler = $this->getMockForAbstractClass('Monolog\\Handler\\MailHandler');
|
||||
$handler = $this->createPartialMock('Monolog\Handler\MailHandler', ['send']);
|
||||
$handler->expects($this->never())
|
||||
->method('send');
|
||||
$handler->setLevel(Level::Error);
|
||||
@@ -60,16 +60,15 @@ class MailHandlerTest extends TestCase
|
||||
*/
|
||||
public function testHandle()
|
||||
{
|
||||
$handler = $this->getMockForAbstractClass('Monolog\\Handler\\MailHandler');
|
||||
$handler = $this->createPartialMock('Monolog\Handler\MailHandler', ['send']);
|
||||
$handler->setFormatter(new \Monolog\Formatter\LineFormatter);
|
||||
|
||||
$record = $this->getRecord();
|
||||
$records = [$record];
|
||||
$records[0]['formatted'] = '['.$record->datetime.'] test.WARNING: test [] []'."\n";
|
||||
$record = $this->getRecord(message: 'test handle');
|
||||
$record->formatted = '['.$record->datetime.'] test.WARNING: test handle [] []'."\n";
|
||||
|
||||
$handler->expects($this->once())
|
||||
->method('send')
|
||||
->with($records[0]['formatted'], $records);
|
||||
->with($record->formatted, [$record]);
|
||||
|
||||
$handler->handle($record);
|
||||
}
|
||||
|
@@ -43,7 +43,7 @@ class MongoDBHandlerTest extends TestCase
|
||||
$mongodb->expects($this->once())
|
||||
->method('selectCollection')
|
||||
->with('db', 'collection')
|
||||
->will($this->returnValue($collection));
|
||||
->willReturn($collection);
|
||||
|
||||
$record = $this->getRecord();
|
||||
$expected = $record->toArray();
|
||||
|
@@ -13,24 +13,21 @@ namespace Monolog\Handler;
|
||||
|
||||
use Monolog\Level;
|
||||
use Monolog\Test\TestCase;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
|
||||
/**
|
||||
* @covers Monolog\Handler\NoopHandler::handle
|
||||
*/
|
||||
class NoopHandlerTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider logLevelsProvider
|
||||
*/
|
||||
#[DataProvider('logLevelsProvider')]
|
||||
public function testIsHandling(Level $level)
|
||||
{
|
||||
$handler = new NoopHandler();
|
||||
$this->assertTrue($handler->isHandling($this->getRecord($level)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider logLevelsProvider
|
||||
*/
|
||||
#[DataProvider('logLevelsProvider')]
|
||||
public function testHandle(Level $level)
|
||||
{
|
||||
$handler = new NoopHandler();
|
||||
|
@@ -20,6 +20,7 @@ use PhpConsole\Connector;
|
||||
use PhpConsole\Dispatcher\Debug as DebugDispatcher;
|
||||
use PhpConsole\Dispatcher\Errors as ErrorDispatcher;
|
||||
use PhpConsole\Handler as VendorPhpConsoleHandler;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
|
||||
/**
|
||||
@@ -99,7 +100,7 @@ class PHPConsoleHandlerTest extends TestCase
|
||||
|
||||
$connector->expects($this->any())
|
||||
->method('isActiveClient')
|
||||
->will($this->returnValue(true));
|
||||
->willReturn(true);
|
||||
|
||||
return $connector;
|
||||
}
|
||||
@@ -246,9 +247,7 @@ class PHPConsoleHandlerTest extends TestCase
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideConnectorMethodsOptionsSets
|
||||
*/
|
||||
#[DataProvider('provideConnectorMethodsOptionsSets')]
|
||||
public function testOptionCallsConnectorMethod($option, $method, $value, $isArgument = true)
|
||||
{
|
||||
$expectCall = $this->connector->expects($this->once())->method($method);
|
||||
@@ -275,9 +274,7 @@ class PHPConsoleHandlerTest extends TestCase
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideDumperOptionsValues
|
||||
*/
|
||||
#[DataProvider('provideDumperOptionsValues')]
|
||||
public function testDumperOptions($option, $dumperProperty, $value)
|
||||
{
|
||||
new PHPConsoleHandler([$option => $value], $this->connector);
|
||||
|
@@ -13,6 +13,7 @@ namespace Monolog\Handler;
|
||||
|
||||
use Monolog\Test\TestCase;
|
||||
use Monolog\Level;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
|
||||
class ProcessHandlerTest extends TestCase
|
||||
{
|
||||
@@ -76,11 +77,10 @@ class ProcessHandlerTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider invalidCommandProvider
|
||||
* @param mixed $invalidCommand
|
||||
* @covers Monolog\Handler\ProcessHandler::guardAgainstInvalidCommand
|
||||
*/
|
||||
public function testConstructWithInvalidCommandThrowsInvalidArgumentException($invalidCommand, $expectedExcep)
|
||||
#[DataProvider('invalidCommandProvider')]
|
||||
public function testConstructWithInvalidCommandThrowsInvalidArgumentException(mixed $invalidCommand, string $expectedExcep)
|
||||
{
|
||||
$this->expectException($expectedExcep);
|
||||
new ProcessHandler($invalidCommand, Level::Debug);
|
||||
@@ -99,10 +99,10 @@ class ProcessHandlerTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider invalidCwdProvider
|
||||
* @param mixed $invalidCwd
|
||||
* @covers Monolog\Handler\ProcessHandler::guardAgainstInvalidCwd
|
||||
*/
|
||||
#[DataProvider('invalidCwdProvider')]
|
||||
public function testConstructWithInvalidCwdThrowsInvalidArgumentException($invalidCwd, $expectedExcep)
|
||||
{
|
||||
$this->expectException($expectedExcep);
|
||||
@@ -136,7 +136,7 @@ class ProcessHandlerTest extends TestCase
|
||||
|
||||
$handler->expects($this->once())
|
||||
->method('selectErrorStream')
|
||||
->will($this->returnValue(false));
|
||||
->willReturn(false);
|
||||
|
||||
$this->expectException(\UnexpectedValueException::class);
|
||||
/** @var ProcessHandler $handler */
|
||||
@@ -170,7 +170,7 @@ class ProcessHandlerTest extends TestCase
|
||||
|
||||
$handler->expects($this->exactly(2))
|
||||
->method('readProcessErrors')
|
||||
->willReturnOnConsecutiveCalls('', $this->returnValue('some fake error message here'));
|
||||
->willReturnOnConsecutiveCalls('', 'some fake error message here');
|
||||
|
||||
$this->expectException(\UnexpectedValueException::class);
|
||||
/** @var ProcessHandler $handler */
|
||||
|
@@ -14,6 +14,7 @@ namespace Monolog\Handler;
|
||||
use Monolog\Level;
|
||||
use Monolog\Test\TestCase;
|
||||
use Monolog\Formatter\LineFormatter;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
|
||||
/**
|
||||
* @covers Monolog\Handler\PsrHandler::handle
|
||||
@@ -28,9 +29,7 @@ class PsrHandlerTest extends TestCase
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider logLevelProvider
|
||||
*/
|
||||
#[DataProvider('logLevelProvider')]
|
||||
public function testHandlesAllLevels(string $levelName, Level $level)
|
||||
{
|
||||
$message = 'Hello, world! ' . $level->value;
|
||||
|
@@ -136,13 +136,12 @@ class PushoverHandlerTest extends TestCase
|
||||
|
||||
$this->handler->expects($this->any())
|
||||
->method('fsockopen')
|
||||
->will($this->returnValue($this->res));
|
||||
->willReturn($this->res);
|
||||
$this->handler->expects($this->any())
|
||||
->method('streamSetTimeout')
|
||||
->will($this->returnValue(true));
|
||||
->willReturn(true);
|
||||
$this->handler->expects($this->any())
|
||||
->method('closeSocket')
|
||||
->will($this->returnValue(true));
|
||||
->method('closeSocket');
|
||||
|
||||
$this->handler->setFormatter($this->getIdentityFormatter());
|
||||
}
|
||||
|
@@ -78,19 +78,19 @@ class RedisHandlerTest extends TestCase
|
||||
// Redis uses multi
|
||||
$redis->expects($this->once())
|
||||
->method('multi')
|
||||
->will($this->returnSelf());
|
||||
->willReturnSelf();
|
||||
|
||||
$redis->expects($this->once())
|
||||
->method('rPush')
|
||||
->will($this->returnSelf());
|
||||
->willReturnSelf();
|
||||
|
||||
$redis->expects($this->once())
|
||||
->method('lTrim')
|
||||
->will($this->returnSelf());
|
||||
->willReturnSelf();
|
||||
|
||||
$redis->expects($this->once())
|
||||
->method('exec')
|
||||
->will($this->returnSelf());
|
||||
->willReturnSelf();
|
||||
|
||||
$record = $this->getRecord(Level::Warning, 'test', ['data' => new \stdClass, 'foo' => 34]);
|
||||
|
||||
@@ -101,32 +101,32 @@ class RedisHandlerTest extends TestCase
|
||||
|
||||
public function testPredisHandleCapped()
|
||||
{
|
||||
$redis = $this->createPartialMock('Predis\Client', ['transaction']);
|
||||
|
||||
$redisTransaction = $this->getMockBuilder('Predis\Client')
|
||||
->disableOriginalConstructor()
|
||||
->addMethods(['rPush', 'lTrim'])
|
||||
->getMock();
|
||||
|
||||
$redisTransaction->expects($this->once())
|
||||
->method('rPush')
|
||||
->will($this->returnSelf());
|
||||
|
||||
$redisTransaction->expects($this->once())
|
||||
->method('lTrim')
|
||||
->will($this->returnSelf());
|
||||
|
||||
// Redis uses multi
|
||||
$redis->expects($this->once())
|
||||
->method('transaction')
|
||||
->will($this->returnCallback(function ($cb) use ($redisTransaction) {
|
||||
$cb($redisTransaction);
|
||||
}));
|
||||
$redis = new class extends \Predis\Client {
|
||||
public array $testResults = [];
|
||||
public function rpush(...$args) {
|
||||
$this->testResults[] = ['rpush', ...$args];
|
||||
return $this;
|
||||
}
|
||||
public function ltrim(...$args) {
|
||||
$this->testResults[] = ['ltrim', ...$args];
|
||||
return $this;
|
||||
}
|
||||
public function transaction(...$args) {
|
||||
$this->testResults[] = ['transaction start'];
|
||||
return ($args[0])($this);
|
||||
}
|
||||
};
|
||||
|
||||
$record = $this->getRecord(Level::Warning, 'test', ['data' => new \stdClass, 'foo' => 34]);
|
||||
|
||||
$handler = new RedisHandler($redis, 'key', Level::Debug, true, 10);
|
||||
$handler->setFormatter(new LineFormatter("%message%"));
|
||||
$handler->handle($record);
|
||||
|
||||
self::assertsame([
|
||||
['transaction start'],
|
||||
['rpush', 'key', 'test'],
|
||||
['ltrim', 'key', -10, -1],
|
||||
], $redis->testResults);
|
||||
}
|
||||
}
|
||||
|
@@ -13,6 +13,7 @@ namespace Monolog\Handler;
|
||||
|
||||
use InvalidArgumentException;
|
||||
use Monolog\Test\TestCase;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
|
||||
/**
|
||||
* @covers Monolog\Handler\RotatingFileHandler
|
||||
@@ -106,9 +107,7 @@ class RotatingFileHandlerTest extends TestCase
|
||||
$this->assertEquals('test', file_get_contents($log));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider rotationTests
|
||||
*/
|
||||
#[DataProvider('rotationTests')]
|
||||
public function testRotation($createFile, $dateFormat, $timeCallback)
|
||||
{
|
||||
touch($old1 = __DIR__.'/Fixtures/foo-'.date($dateFormat, $timeCallback(-1)).'.rot');
|
||||
@@ -176,9 +175,7 @@ class RotatingFileHandlerTest extends TestCase
|
||||
return $file;
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider rotationWithFolderByDateTests
|
||||
*/
|
||||
#[DataProvider('rotationWithFolderByDateTests')]
|
||||
public function testRotationWithFolderByDate($createFile, $dateFormat, $timeCallback)
|
||||
{
|
||||
$old1 = $this->createDeep(__DIR__.'/Fixtures/'.date($dateFormat, $timeCallback(-1)).'/foo.rot');
|
||||
@@ -238,9 +235,7 @@ class RotatingFileHandlerTest extends TestCase
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider dateFormatProvider
|
||||
*/
|
||||
#[DataProvider('dateFormatProvider')]
|
||||
public function testAllowOnlyFixedDefinedDateFormats($dateFormat, $valid)
|
||||
{
|
||||
$handler = new RotatingFileHandler(__DIR__.'/Fixtures/foo.rot', 2);
|
||||
@@ -279,9 +274,7 @@ class RotatingFileHandlerTest extends TestCase
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider filenameFormatProvider
|
||||
*/
|
||||
#[DataProvider('filenameFormatProvider')]
|
||||
public function testDisallowFilenameFormatsWithoutDate($filenameFormat, $valid)
|
||||
{
|
||||
$handler = new RotatingFileHandler(__DIR__.'/Fixtures/foo.rot', 2);
|
||||
@@ -307,9 +300,7 @@ class RotatingFileHandlerTest extends TestCase
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider rotationWhenSimilarFilesExistTests
|
||||
*/
|
||||
#[DataProvider('rotationWhenSimilarFilesExistTests')]
|
||||
public function testRotationWhenSimilarFileNamesExist($dateFormat)
|
||||
{
|
||||
touch($old1 = __DIR__.'/Fixtures/foo-foo-'.date($dateFormat).'.rot');
|
||||
|
@@ -13,10 +13,10 @@ namespace Monolog\Handler\Slack;
|
||||
|
||||
use Monolog\Level;
|
||||
use Monolog\Test\TestCase;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass Monolog\Handler\Slack\SlackRecord
|
||||
*/
|
||||
#[CoversClass(SlackRecord::class)]
|
||||
class SlackRecordTest extends TestCase
|
||||
{
|
||||
public static function dataGetAttachmentColor()
|
||||
@@ -33,10 +33,7 @@ class SlackRecordTest extends TestCase
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider dataGetAttachmentColor
|
||||
* @covers ::getAttachmentColor
|
||||
*/
|
||||
#[DataProvider('dataGetAttachmentColor')]
|
||||
public function testGetAttachmentColor(Level $logLevel, string $expectedColour)
|
||||
{
|
||||
$slackRecord = new SlackRecord();
|
||||
@@ -78,9 +75,7 @@ class SlackRecordTest extends TestCase
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider dataStringify
|
||||
*/
|
||||
#[DataProvider('dataStringify')]
|
||||
public function testStringify($fields, $expectedResult)
|
||||
{
|
||||
$slackRecord = new SlackRecord(
|
||||
@@ -162,17 +157,17 @@ class SlackRecordTest extends TestCase
|
||||
$formatter
|
||||
->expects($this->any())
|
||||
->method('format')
|
||||
->will($this->returnCallback(function ($record) {
|
||||
->willReturnCallback(function ($record) {
|
||||
return $record->message . 'test';
|
||||
}));
|
||||
});
|
||||
|
||||
$formatter2 = $this->createMock('Monolog\\Formatter\\FormatterInterface');
|
||||
$formatter2
|
||||
->expects($this->any())
|
||||
->method('format')
|
||||
->will($this->returnCallback(function ($record) {
|
||||
->willReturnCallback(function ($record) {
|
||||
return $record->message . 'test1';
|
||||
}));
|
||||
});
|
||||
|
||||
$message = 'Test message';
|
||||
$record = new SlackRecord(null, null, false, null, false, false, [], $formatter);
|
||||
|
@@ -15,6 +15,7 @@ use Monolog\Test\TestCase;
|
||||
use Monolog\Level;
|
||||
use Monolog\Formatter\LineFormatter;
|
||||
use Monolog\Handler\Slack\SlackRecord;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
|
||||
/**
|
||||
* @author Greg Kedzierski <greg@gregkedzierski.com>
|
||||
@@ -93,9 +94,7 @@ class SlackHandlerTest extends TestCase
|
||||
$this->assertMatchesRegularExpression('/icon_emoji=%3Aalien%3A/', $content);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideLevelColors
|
||||
*/
|
||||
#[DataProvider('provideLevelColors')]
|
||||
public function testWriteContentWithColors($level, $expectedColor)
|
||||
{
|
||||
$this->createHandler();
|
||||
@@ -145,13 +144,12 @@ class SlackHandlerTest extends TestCase
|
||||
|
||||
$this->handler->expects($this->any())
|
||||
->method('fsockopen')
|
||||
->will($this->returnValue($this->res));
|
||||
->willReturn($this->res);
|
||||
$this->handler->expects($this->any())
|
||||
->method('streamSetTimeout')
|
||||
->will($this->returnValue(true));
|
||||
->willReturn(true);
|
||||
$this->handler->expects($this->any())
|
||||
->method('closeSocket')
|
||||
->will($this->returnValue(true));
|
||||
->method('closeSocket');
|
||||
|
||||
$this->handler->setFormatter($this->getIdentityFormatter());
|
||||
}
|
||||
|
@@ -97,7 +97,7 @@ class SocketHandlerTest extends TestCase
|
||||
$this->setMockHandler(['fsockopen']);
|
||||
$this->handler->expects($this->once())
|
||||
->method('fsockopen')
|
||||
->will($this->returnValue(false));
|
||||
->willReturn(false);
|
||||
|
||||
$this->expectException(\UnexpectedValueException::class);
|
||||
|
||||
@@ -109,7 +109,7 @@ class SocketHandlerTest extends TestCase
|
||||
$this->setMockHandler(['pfsockopen']);
|
||||
$this->handler->expects($this->once())
|
||||
->method('pfsockopen')
|
||||
->will($this->returnValue(false));
|
||||
->willReturn(false);
|
||||
|
||||
$this->handler->setPersistent(true);
|
||||
|
||||
@@ -123,7 +123,7 @@ class SocketHandlerTest extends TestCase
|
||||
$this->setMockHandler(['streamSetTimeout']);
|
||||
$this->handler->expects($this->once())
|
||||
->method('streamSetTimeout')
|
||||
->will($this->returnValue(false));
|
||||
->willReturn(false);
|
||||
|
||||
$this->expectException(\UnexpectedValueException::class);
|
||||
|
||||
@@ -136,7 +136,7 @@ class SocketHandlerTest extends TestCase
|
||||
$this->handler->setChunkSize(8192);
|
||||
$this->handler->expects($this->once())
|
||||
->method('streamSetChunkSize')
|
||||
->will($this->returnValue(false));
|
||||
->willReturn(false);
|
||||
|
||||
$this->expectException(\UnexpectedValueException::class);
|
||||
|
||||
@@ -158,7 +158,7 @@ class SocketHandlerTest extends TestCase
|
||||
|
||||
$this->handler->expects($this->exactly(2))
|
||||
->method('fwrite')
|
||||
->will($this->returnCallback($callback));
|
||||
->willReturnCallback($callback);
|
||||
|
||||
$this->expectException(\RuntimeException::class);
|
||||
|
||||
@@ -180,10 +180,10 @@ class SocketHandlerTest extends TestCase
|
||||
|
||||
$this->handler->expects($this->exactly(1))
|
||||
->method('fwrite')
|
||||
->will($this->returnCallback($callback));
|
||||
->willReturnCallback($callback);
|
||||
$this->handler->expects($this->exactly(1))
|
||||
->method('streamGetMetadata')
|
||||
->will($this->returnValue(['timed_out' => true]));
|
||||
->willReturn(['timed_out' => true]);
|
||||
|
||||
$this->expectException(\RuntimeException::class);
|
||||
|
||||
@@ -203,10 +203,10 @@ class SocketHandlerTest extends TestCase
|
||||
|
||||
$this->handler->expects($this->exactly(1))
|
||||
->method('fwrite')
|
||||
->will($this->returnCallback($callback));
|
||||
->willReturnCallback($callback);
|
||||
$this->handler->expects($this->exactly(1))
|
||||
->method('streamGetMetadata')
|
||||
->will($this->returnValue(['timed_out' => false]));
|
||||
->willReturn(['timed_out' => false]);
|
||||
|
||||
$this->expectException(\RuntimeException::class);
|
||||
|
||||
@@ -238,7 +238,7 @@ class SocketHandlerTest extends TestCase
|
||||
|
||||
$this->handler->expects($this->exactly(2))
|
||||
->method('fwrite')
|
||||
->will($this->returnCallback($callback));
|
||||
->willReturnCallback($callback);
|
||||
|
||||
$this->writeRecord('Hello world');
|
||||
}
|
||||
@@ -268,11 +268,11 @@ class SocketHandlerTest extends TestCase
|
||||
|
||||
$this->handler->expects($this->any())
|
||||
->method('fwrite')
|
||||
->will($this->returnValue(0));
|
||||
->willReturn(0);
|
||||
|
||||
$this->handler->expects($this->any())
|
||||
->method('streamGetMetadata')
|
||||
->will($this->returnValue(['timed_out' => false]));
|
||||
->willReturn(['timed_out' => false]);
|
||||
|
||||
$this->handler->setWritingTimeout(1);
|
||||
|
||||
@@ -311,25 +311,25 @@ class SocketHandlerTest extends TestCase
|
||||
if (!in_array('fsockopen', $methods)) {
|
||||
$this->handler->expects($this->any())
|
||||
->method('fsockopen')
|
||||
->will($this->returnValue($this->res));
|
||||
->willReturn($this->res);
|
||||
}
|
||||
|
||||
if (!in_array('pfsockopen', $methods)) {
|
||||
$this->handler->expects($this->any())
|
||||
->method('pfsockopen')
|
||||
->will($this->returnValue($this->res));
|
||||
->willReturn($this->res);
|
||||
}
|
||||
|
||||
if (!in_array('streamSetTimeout', $methods)) {
|
||||
$this->handler->expects($this->any())
|
||||
->method('streamSetTimeout')
|
||||
->will($this->returnValue(true));
|
||||
->willReturn(true);
|
||||
}
|
||||
|
||||
if (!in_array('streamSetChunkSize', $methods)) {
|
||||
$this->handler->expects($this->any())
|
||||
->method('streamSetChunkSize')
|
||||
->will($this->returnValue(8192));
|
||||
->willReturn(8192);
|
||||
}
|
||||
|
||||
$this->handler->setFormatter($this->getIdentityFormatter());
|
||||
|
@@ -13,6 +13,7 @@ namespace Monolog\Handler;
|
||||
|
||||
use Monolog\Test\TestCase;
|
||||
use Monolog\Level;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
|
||||
class StreamHandlerTest extends TestCase
|
||||
{
|
||||
@@ -127,9 +128,9 @@ class StreamHandlerTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider invalidArgumentProvider
|
||||
* @covers Monolog\Handler\StreamHandler::__construct
|
||||
*/
|
||||
#[DataProvider('invalidArgumentProvider')]
|
||||
public function testWriteInvalidArgument($invalidArgument)
|
||||
{
|
||||
$this->expectException(\InvalidArgumentException::class);
|
||||
@@ -207,8 +208,8 @@ STRING;
|
||||
/**
|
||||
* @covers Monolog\Handler\StreamHandler::__construct
|
||||
* @covers Monolog\Handler\StreamHandler::write
|
||||
* @dataProvider provideNonExistingAndNotCreatablePath
|
||||
*/
|
||||
#[DataProvider('provideNonExistingAndNotCreatablePath')]
|
||||
public function testWriteNonExistingAndNotCreatablePath($nonExistingAndNotCreatablePath)
|
||||
{
|
||||
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
|
||||
@@ -259,9 +260,7 @@ STRING;
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideMemoryValues
|
||||
*/
|
||||
#[DataProvider('provideMemoryValues')]
|
||||
public function testPreventOOMError($phpMemory, $expectedChunkSize): void
|
||||
{
|
||||
$previousValue = ini_set('memory_limit', $phpMemory);
|
||||
|
@@ -13,15 +13,14 @@ namespace Monolog\Handler;
|
||||
|
||||
use Monolog\Level;
|
||||
use Monolog\Test\TestCase;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
|
||||
/**
|
||||
* @covers Monolog\Handler\TestHandler
|
||||
*/
|
||||
class TestHandlerTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider methodProvider
|
||||
*/
|
||||
#[DataProvider('methodProvider')]
|
||||
public function testHandler($method, Level $level)
|
||||
{
|
||||
$handler = new TestHandler;
|
||||
|
@@ -49,11 +49,11 @@ class ZendMonitorHandlerTest extends TestCase
|
||||
|
||||
$formatterMock->expects($this->once())
|
||||
->method('format')
|
||||
->will($this->returnValue($formatterResult));
|
||||
->willReturn($formatterResult);
|
||||
|
||||
$zendMonitor->expects($this->once())
|
||||
->method('getDefaultFormatter')
|
||||
->will($this->returnValue($formatterMock));
|
||||
->willReturn($formatterMock);
|
||||
|
||||
$zendMonitor->expects($this->once())
|
||||
->method('writeZendMonitorCustomEvent')
|
||||
|
@@ -15,6 +15,7 @@ use Monolog\Handler\HandlerInterface;
|
||||
use Monolog\Processor\WebProcessor;
|
||||
use Monolog\Handler\TestHandler;
|
||||
use Monolog\Test\TestCase;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
|
||||
class LoggerTest extends TestCase
|
||||
{
|
||||
@@ -161,7 +162,7 @@ class LoggerTest extends TestCase
|
||||
$logger = new Logger(__METHOD__);
|
||||
|
||||
$handler = $this->getMockBuilder('Monolog\Handler\HandlerInterface')->getMock();
|
||||
$handler->expects($this->once())->method('isHandling')->will($this->returnValue(false));
|
||||
$handler->expects($this->once())->method('isHandling')->willReturn(false);
|
||||
$handler->expects($this->never())->method('handle');
|
||||
|
||||
$logger->pushProcessor(fn (LogRecord $record) => $record);
|
||||
@@ -283,11 +284,11 @@ class LoggerTest extends TestCase
|
||||
$handler = $this->createMock('Monolog\Handler\HandlerInterface');
|
||||
$handler->expects($this->any())
|
||||
->method('isHandling')
|
||||
->will($this->returnValue(true))
|
||||
->willReturn(true);
|
||||
;
|
||||
$handler->expects($this->any())
|
||||
->method('handle')
|
||||
->will($this->returnValue(true))
|
||||
->willReturn(true);
|
||||
;
|
||||
$logger->pushHandler($handler);
|
||||
|
||||
@@ -298,7 +299,7 @@ class LoggerTest extends TestCase
|
||||
;
|
||||
$processor->expects($this->once())
|
||||
->method('__invoke')
|
||||
->will($this->returnArgument(0))
|
||||
->willReturnArgument(0)
|
||||
;
|
||||
$logger->pushProcessor($processor);
|
||||
|
||||
@@ -314,7 +315,7 @@ class LoggerTest extends TestCase
|
||||
$handler = $this->createMock('Monolog\Handler\HandlerInterface');
|
||||
$handler->expects($this->once())
|
||||
->method('isHandling')
|
||||
->will($this->returnValue(false))
|
||||
->willReturn(false);
|
||||
;
|
||||
$logger->pushHandler($handler);
|
||||
$that = $this;
|
||||
@@ -335,29 +336,29 @@ class LoggerTest extends TestCase
|
||||
$handler1 = $this->createMock('Monolog\Handler\HandlerInterface');
|
||||
$handler1->expects($this->never())
|
||||
->method('isHandling')
|
||||
->will($this->returnValue(false))
|
||||
->willReturn(false);
|
||||
;
|
||||
$handler1->expects($this->once())
|
||||
->method('handle')
|
||||
->will($this->returnValue(false))
|
||||
->willReturn(false);
|
||||
;
|
||||
$logger->pushHandler($handler1);
|
||||
|
||||
$handler2 = $this->createMock('Monolog\Handler\HandlerInterface');
|
||||
$handler2->expects($this->once())
|
||||
->method('isHandling')
|
||||
->will($this->returnValue(true))
|
||||
->willReturn(true);
|
||||
;
|
||||
$handler2->expects($this->once())
|
||||
->method('handle')
|
||||
->will($this->returnValue(false))
|
||||
->willReturn(false);
|
||||
;
|
||||
$logger->pushHandler($handler2);
|
||||
|
||||
$handler3 = $this->createMock('Monolog\Handler\HandlerInterface');
|
||||
$handler3->expects($this->once())
|
||||
->method('isHandling')
|
||||
->will($this->returnValue(false))
|
||||
->willReturn(false);
|
||||
;
|
||||
$handler3->expects($this->never())
|
||||
->method('handle')
|
||||
@@ -375,27 +376,27 @@ class LoggerTest extends TestCase
|
||||
$handler1 = $this->createMock('Monolog\Handler\HandlerInterface');
|
||||
$handler1->expects($this->never())
|
||||
->method('isHandling')
|
||||
->will($this->returnValue(false))
|
||||
->willReturn(false);
|
||||
;
|
||||
$handler1->expects($this->once())
|
||||
->method('handle')
|
||||
->will($this->returnValue(false))
|
||||
->willReturn(false);
|
||||
;
|
||||
|
||||
$handler2 = $this->createMock('Monolog\Handler\HandlerInterface');
|
||||
$handler2->expects($this->once())
|
||||
->method('isHandling')
|
||||
->will($this->returnValue(true))
|
||||
->willReturn(true);
|
||||
;
|
||||
$handler2->expects($this->once())
|
||||
->method('handle')
|
||||
->will($this->returnValue(false))
|
||||
->willReturn(false);
|
||||
;
|
||||
|
||||
$handler3 = $this->createMock('Monolog\Handler\HandlerInterface');
|
||||
$handler3->expects($this->once())
|
||||
->method('isHandling')
|
||||
->will($this->returnValue(false))
|
||||
->willReturn(false);
|
||||
;
|
||||
$handler3->expects($this->never())
|
||||
->method('handle')
|
||||
@@ -417,22 +418,22 @@ class LoggerTest extends TestCase
|
||||
$handler1 = $this->createMock('Monolog\Handler\HandlerInterface');
|
||||
$handler1->expects($this->any())
|
||||
->method('isHandling')
|
||||
->will($this->returnValue(true))
|
||||
->willReturn(true);
|
||||
;
|
||||
$handler1->expects($this->once())
|
||||
->method('handle')
|
||||
->will($this->returnValue(false))
|
||||
->willReturn(false);
|
||||
;
|
||||
$logger->pushHandler($handler1);
|
||||
|
||||
$handler2 = $this->createMock('Monolog\Handler\HandlerInterface');
|
||||
$handler2->expects($this->any())
|
||||
->method('isHandling')
|
||||
->will($this->returnValue(true))
|
||||
->willReturn(true);
|
||||
;
|
||||
$handler2->expects($this->once())
|
||||
->method('handle')
|
||||
->will($this->returnValue(false))
|
||||
->willReturn(false);
|
||||
;
|
||||
$logger->pushHandler($handler2);
|
||||
|
||||
@@ -449,7 +450,7 @@ class LoggerTest extends TestCase
|
||||
$handler1 = $this->createMock('Monolog\Handler\HandlerInterface');
|
||||
$handler1->expects($this->any())
|
||||
->method('isHandling')
|
||||
->will($this->returnValue(true))
|
||||
->willReturn(true);
|
||||
;
|
||||
$handler1->expects($this->never())
|
||||
->method('handle')
|
||||
@@ -459,11 +460,11 @@ class LoggerTest extends TestCase
|
||||
$handler2 = $this->createMock('Monolog\Handler\HandlerInterface');
|
||||
$handler2->expects($this->any())
|
||||
->method('isHandling')
|
||||
->will($this->returnValue(true))
|
||||
->willReturn(true);
|
||||
;
|
||||
$handler2->expects($this->once())
|
||||
->method('handle')
|
||||
->will($this->returnValue(true))
|
||||
->willReturn(true);
|
||||
;
|
||||
$logger->pushHandler($handler2);
|
||||
|
||||
@@ -480,7 +481,7 @@ class LoggerTest extends TestCase
|
||||
$handler1 = $this->createMock('Monolog\Handler\HandlerInterface');
|
||||
$handler1->expects($this->any())
|
||||
->method('isHandling')
|
||||
->will($this->returnValue(false))
|
||||
->willReturn(false);
|
||||
;
|
||||
|
||||
$logger->pushHandler($handler1);
|
||||
@@ -489,7 +490,7 @@ class LoggerTest extends TestCase
|
||||
$handler2 = $this->createMock('Monolog\Handler\HandlerInterface');
|
||||
$handler2->expects($this->any())
|
||||
->method('isHandling')
|
||||
->will($this->returnValue(true))
|
||||
->willReturn(true);
|
||||
;
|
||||
|
||||
$logger->pushHandler($handler2);
|
||||
@@ -497,7 +498,6 @@ class LoggerTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider logMethodProvider
|
||||
* @covers Level::Debug
|
||||
* @covers Level::Info
|
||||
* @covers Level::Notice
|
||||
@@ -507,6 +507,7 @@ class LoggerTest extends TestCase
|
||||
* @covers Level::Alert
|
||||
* @covers Level::Emergency
|
||||
*/
|
||||
#[DataProvider('logMethodProvider')]
|
||||
public function testLogMethods(string $method, Level $expectedLevel)
|
||||
{
|
||||
$logger = new Logger('foo');
|
||||
@@ -533,9 +534,9 @@ class LoggerTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider setTimezoneProvider
|
||||
* @covers Logger::setTimezone
|
||||
*/
|
||||
#[DataProvider('setTimezoneProvider')]
|
||||
public function testSetTimezone($tz)
|
||||
{
|
||||
$logger = new Logger('foo');
|
||||
@@ -608,10 +609,10 @@ class LoggerTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider useMicrosecondTimestampsProvider
|
||||
* @covers Logger::useMicrosecondTimestamps
|
||||
* @covers Logger::addRecord
|
||||
*/
|
||||
#[DataProvider('useMicrosecondTimestampsProvider')]
|
||||
public function testUseMicrosecondTimestamps($micro, $assert, $assertFormat)
|
||||
{
|
||||
if (PHP_VERSION_ID === 70103) {
|
||||
@@ -675,7 +676,7 @@ class LoggerTest extends TestCase
|
||||
$handler = $this->getMockBuilder('Monolog\Handler\HandlerInterface')->getMock();
|
||||
$handler->expects($this->any())
|
||||
->method('isHandling')
|
||||
->will($this->returnValue(true))
|
||||
->willReturn(true);
|
||||
;
|
||||
$handler->expects($this->any())
|
||||
->method('handle')
|
||||
@@ -704,7 +705,7 @@ class LoggerTest extends TestCase
|
||||
$handler = $this->getMockBuilder('Monolog\Handler\HandlerInterface')->getMock();
|
||||
$handler->expects($this->any())
|
||||
->method('isHandling')
|
||||
->will($this->returnValue(true))
|
||||
->willReturn(true);
|
||||
;
|
||||
$handler->expects($this->any())
|
||||
->method('handle')
|
||||
|
@@ -12,6 +12,7 @@
|
||||
namespace Monolog\Processor;
|
||||
|
||||
use Monolog\Test\TestCase;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
|
||||
class ClosureContextProcessorTest extends TestCase
|
||||
{
|
||||
@@ -24,9 +25,7 @@ class ClosureContextProcessorTest extends TestCase
|
||||
$this->assertSame($context, $record->context);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getContexts
|
||||
*/
|
||||
#[DataProvider('getContexts')]
|
||||
public function testSkip(array $context)
|
||||
{
|
||||
$processor = new ClosureContextProcessor();
|
||||
|
@@ -13,12 +13,11 @@ namespace Monolog\Processor;
|
||||
|
||||
use Monolog\Level;
|
||||
use Monolog\Test\TestCase;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
|
||||
class PsrLogMessageProcessorTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider getPairs
|
||||
*/
|
||||
#[DataProvider('getPairs')]
|
||||
public function testReplacement($val, $expected)
|
||||
{
|
||||
$proc = new PsrLogMessageProcessor;
|
||||
|
@@ -15,6 +15,7 @@ use DateTimeZone;
|
||||
use Monolog\Handler\TestHandler;
|
||||
use Monolog\Formatter\LineFormatter;
|
||||
use Monolog\Processor\PsrLogMessageProcessor;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Psr\Log\InvalidArgumentException;
|
||||
@@ -63,9 +64,7 @@ class PsrLogCompatTest extends TestCase
|
||||
$this->assertInstanceOf(LoggerInterface::class, $this->getLogger());
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideLevelsAndMessages
|
||||
*/
|
||||
#[DataProvider('provideLevelsAndMessages')]
|
||||
public function testLogsAtAllLevels($level, $message)
|
||||
{
|
||||
$logger = $this->getLogger();
|
||||
@@ -170,7 +169,7 @@ class PsrLogCompatTest extends TestCase
|
||||
->getMock();
|
||||
|
||||
$mock->method('__toString')
|
||||
->will($this->returnValue($string));
|
||||
->willReturn($string);
|
||||
|
||||
return $mock;
|
||||
}
|
||||
|
@@ -11,6 +11,8 @@
|
||||
|
||||
namespace Monolog;
|
||||
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
|
||||
class RegistryTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
protected function setUp(): void
|
||||
@@ -19,9 +21,9 @@ class RegistryTest extends \PHPUnit\Framework\TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider hasLoggerProvider
|
||||
* @covers Monolog\Registry::hasLogger
|
||||
*/
|
||||
#[DataProvider('hasLoggerProvider')]
|
||||
public function testHasLogger(array $loggersToAdd, array $loggersToCheck, array $expectedResult)
|
||||
{
|
||||
foreach ($loggersToAdd as $loggerToAdd) {
|
||||
@@ -73,10 +75,10 @@ class RegistryTest extends \PHPUnit\Framework\TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider removedLoggerProvider
|
||||
* @covers Monolog\Registry::addLogger
|
||||
* @covers Monolog\Registry::removeLogger
|
||||
*/
|
||||
#[DataProvider('removedLoggerProvider')]
|
||||
public function testRemovesLogger($loggerToAdd, $remove)
|
||||
{
|
||||
Registry::addLogger($loggerToAdd);
|
||||
|
@@ -13,6 +13,7 @@ namespace Monolog;
|
||||
|
||||
use Monolog\Handler\StreamHandler;
|
||||
use Monolog\Handler\TestHandler;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use Psr\Log\LogLevel;
|
||||
use Monolog\Test\TestCase;
|
||||
|
||||
@@ -122,12 +123,12 @@ class SignalHandlerTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider defaultPreviousProvider
|
||||
* @depends testRegisterSignalHandler
|
||||
* @requires function pcntl_fork
|
||||
* @requires function pcntl_sigprocmask
|
||||
* @requires function pcntl_waitpid
|
||||
*/
|
||||
#[DataProvider('defaultPreviousProvider')]
|
||||
public function testRegisterDefaultPreviousSignalHandler($signo, $callPrevious, $expected)
|
||||
{
|
||||
$this->setSignalHandler($signo, SIG_DFL);
|
||||
@@ -174,10 +175,10 @@ class SignalHandlerTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider callablePreviousProvider
|
||||
* @depends testRegisterSignalHandler
|
||||
* @requires function pcntl_signal_get_handler
|
||||
*/
|
||||
#[DataProvider('callablePreviousProvider')]
|
||||
public function testRegisterCallablePreviousSignalHandler($callPrevious)
|
||||
{
|
||||
$this->setSignalHandler(SIGURG, SIG_IGN);
|
||||
@@ -205,11 +206,11 @@ class SignalHandlerTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider restartSyscallsProvider
|
||||
* @depends testRegisterDefaultPreviousSignalHandler
|
||||
* @requires function pcntl_fork
|
||||
* @requires function pcntl_waitpid
|
||||
*/
|
||||
#[DataProvider('restartSyscallsProvider')]
|
||||
public function testRegisterSyscallRestartingSignalHandler($restartSyscalls)
|
||||
{
|
||||
$this->setSignalHandler(SIGURG, SIG_IGN);
|
||||
@@ -259,10 +260,10 @@ class SignalHandlerTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider asyncProvider
|
||||
* @depends testRegisterDefaultPreviousSignalHandler
|
||||
* @requires function pcntl_async_signals
|
||||
*/
|
||||
#[DataProvider('asyncProvider')]
|
||||
public function testRegisterAsyncSignalHandler($initialAsync, $desiredAsync, $expectedBefore, $expectedAfter)
|
||||
{
|
||||
$this->setSignalHandler(SIGURG, SIG_IGN);
|
||||
|
@@ -11,11 +11,11 @@
|
||||
|
||||
namespace Monolog;
|
||||
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
|
||||
class UtilsTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider provideObjects
|
||||
*/
|
||||
#[DataProvider('provideObjects')]
|
||||
public function testGetClass(string $expected, object $object)
|
||||
{
|
||||
$this->assertSame($expected, Utils::getClass($object));
|
||||
@@ -32,9 +32,7 @@ class UtilsTest extends \PHPUnit_Framework_TestCase
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providePathsToCanonicalize
|
||||
*/
|
||||
#[DataProvider('providePathsToCanonicalize')]
|
||||
public function testCanonicalizePath(string $expected, string $input)
|
||||
{
|
||||
$this->assertSame($expected, Utils::canonicalizePath($input));
|
||||
@@ -53,9 +51,7 @@ class UtilsTest extends \PHPUnit_Framework_TestCase
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providesHandleJsonErrorFailure
|
||||
*/
|
||||
#[DataProvider('providesHandleJsonErrorFailure')]
|
||||
public function testHandleJsonErrorFailure(int $code, string $msg)
|
||||
{
|
||||
$this->expectException('RuntimeException', $msg);
|
||||
@@ -76,8 +72,8 @@ class UtilsTest extends \PHPUnit_Framework_TestCase
|
||||
* @param mixed $in Input
|
||||
* @param mixed $expect Expected output
|
||||
* @covers Monolog\Formatter\NormalizerFormatter::detectAndCleanUtf8
|
||||
* @dataProvider providesDetectAndCleanUtf8
|
||||
*/
|
||||
#[DataProvider('providesDetectAndCleanUtf8')]
|
||||
public function testDetectAndCleanUtf8($in, $expect)
|
||||
{
|
||||
$reflMethod = new \ReflectionMethod(Utils::class, 'detectAndCleanUtf8');
|
||||
@@ -106,9 +102,7 @@ class UtilsTest extends \PHPUnit_Framework_TestCase
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providesPcreLastErrorMessage
|
||||
*/
|
||||
#[DataProvider('providesPcreLastErrorMessage')]
|
||||
public function testPcreLastErrorMessage(int $code, string $msg)
|
||||
{
|
||||
if (PHP_VERSION_ID >= 80000) {
|
||||
@@ -171,12 +165,8 @@ class UtilsTest extends \PHPUnit_Framework_TestCase
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideIniValuesToConvertToBytes
|
||||
* @param mixed $input
|
||||
* @param int|false $expected
|
||||
*/
|
||||
public function testExpandIniShorthandBytes($input, $expected)
|
||||
#[DataProvider('provideIniValuesToConvertToBytes')]
|
||||
public function testExpandIniShorthandBytes(string|null|bool $input, int|false $expected)
|
||||
{
|
||||
$result = Utils::expandIniShorthandBytes($input);
|
||||
$this->assertEquals($expected, $result);
|
||||
|
Reference in New Issue
Block a user