1
0
mirror of https://github.com/Seldaek/monolog.git synced 2025-08-23 21:33:25 +02:00

Upgrade to phpunit 10 (#1806)

Co-authored-by: Christopher Georg <christopher.georg@sr-travel.de>
This commit is contained in:
chris
2023-06-20 15:56:11 +02:00
committed by GitHub
parent 50409b8169
commit 8561130215
28 changed files with 106 additions and 85 deletions

View File

@@ -146,7 +146,7 @@ class ElasticaHandlerTest extends TestCase
}
}
public function providerTestConnectionErrors(): array
public static function providerTestConnectionErrors(): array
{
return [
[false, ['RuntimeException', 'Error sending messages to Elasticsearch']],

View File

@@ -128,7 +128,7 @@ class ElasticsearchHandlerTest extends TestCase
}
}
public function providerTestConnectionErrors(): array
public static function providerTestConnectionErrors(): array
{
return [
[false, ['RuntimeException', 'Error sending messages to Elasticsearch']],

View File

@@ -37,7 +37,7 @@ class HandlerWrapperTest extends TestCase
unset($this->wrapper);
}
public function trueFalseDataProvider(): array
public static function trueFalseDataProvider(): array
{
return [
[true],

View File

@@ -37,7 +37,7 @@ class NoopHandlerTest extends TestCase
$this->assertFalse($handler->handle($this->getRecord($level)));
}
public function logLevelsProvider()
public static function logLevelsProvider()
{
return array_map(
fn ($level) => [$level],

View File

@@ -46,9 +46,16 @@ class ProcessHandlerTest extends TestCase
$handler = $mockBuilder->getMock();
$handler->expects($this->exactly(2))
$matcher = $this->exactly(2);
$handler->expects($matcher)
->method('writeProcessInput')
->withConsecutive([$this->stringContains($fixtures[0])], [$this->stringContains($fixtures[1])]);
->willReturnCallback(function () use ($matcher, $fixtures) {
match ($matcher->numberOfInvocations()) {
1 => $this->stringContains($fixtures[0]),
2 => $this->stringContains($fixtures[1]),
};
})
;
/** @var ProcessHandler $handler */
$handler->handle($this->getRecord(Level::Warning, $fixtures[0]));
@@ -58,7 +65,7 @@ class ProcessHandlerTest extends TestCase
/**
* Data provider for invalid commands.
*/
public function invalidCommandProvider(): array
public static function invalidCommandProvider(): array
{
return [
[1337, 'TypeError'],
@@ -82,7 +89,7 @@ class ProcessHandlerTest extends TestCase
/**
* Data provider for invalid CWDs.
*/
public function invalidCwdProvider(): array
public static function invalidCwdProvider(): array
{
return [
[1337, 'TypeError'],

View File

@@ -20,7 +20,7 @@ use Monolog\Formatter\LineFormatter;
*/
class PsrHandlerTest extends TestCase
{
public function logLevelProvider()
public static function logLevelProvider()
{
return array_map(
fn (Level $level) => [$level->toPsrLogLevel(), $level],

View File

@@ -47,7 +47,7 @@ class RotatingFileHandlerTest extends TestCase
unlink($file);
}
if ('testRotationWithFolderByDate' === $this->getName(false)) {
if ('testRotationWithFolderByDate' === $this->name()) {
foreach (glob(__DIR__.'/Fixtures/[0-9]*') as $folder) {
$this->rrmdir($folder);
}
@@ -137,7 +137,7 @@ class RotatingFileHandlerTest extends TestCase
$this->assertEquals('test', file_get_contents($log));
}
public function rotationTests()
public static function rotationTests()
{
$now = time();
$dayCallback = function ($ago) use ($now) {
@@ -207,7 +207,7 @@ class RotatingFileHandlerTest extends TestCase
$this->assertEquals('test', file_get_contents($log));
}
public function rotationWithFolderByDateTests()
public static function rotationWithFolderByDateTests()
{
$now = time();
$dayCallback = function ($ago) use ($now) {
@@ -252,7 +252,7 @@ class RotatingFileHandlerTest extends TestCase
$this->assertTrue(true);
}
public function dateFormatProvider()
public static function dateFormatProvider()
{
return [
[RotatingFileHandler::FILE_PER_DAY, true],
@@ -293,7 +293,7 @@ class RotatingFileHandlerTest extends TestCase
$handler->setFilenameFormat($filenameFormat, RotatingFileHandler::FILE_PER_DAY);
}
public function filenameFormatProvider()
public static function filenameFormatProvider()
{
return [
['{filename}', false],
@@ -326,7 +326,7 @@ class RotatingFileHandlerTest extends TestCase
$this->assertTrue(file_exists($log));
}
public function rotationWhenSimilarFilesExistTests()
public static function rotationWhenSimilarFilesExistTests()
{
return [
'Rotation is triggered when the file of the current day is not present but similar exists'

View File

@@ -19,7 +19,7 @@ use Monolog\Test\TestCase;
*/
class SlackRecordTest extends TestCase
{
public function dataGetAttachmentColor()
public static function dataGetAttachmentColor()
{
return [
[Level::Debug, SlackRecord::COLOR_DEFAULT],
@@ -64,7 +64,7 @@ class SlackRecordTest extends TestCase
$this->assertArrayNotHasKey('username', $data);
}
public function dataStringify(): array
public static function dataStringify(): array
{
$multipleDimensions = [[1, 2]];
$numericKeys = ['library' => 'monolog'];

View File

@@ -116,7 +116,7 @@ class SlackHandlerTest extends TestCase
$this->assertMatchesRegularExpression('/text=test1/', $content);
}
public function provideLevelColors()
public static function provideLevelColors()
{
return [
[Level::Debug, urlencode(SlackRecord::COLOR_DEFAULT)],

View File

@@ -117,7 +117,7 @@ class StreamHandlerTest extends TestCase
$handler->handle($this->getRecord());
}
public function invalidArgumentProvider()
public static function invalidArgumentProvider()
{
return [
[1],
@@ -232,7 +232,7 @@ STRING;
$handler->handle($this->getRecord());
}
public function provideNonExistingAndNotCreatablePath()
public static function provideNonExistingAndNotCreatablePath()
{
return [
'/foo/bar/…' => [
@@ -244,7 +244,7 @@ STRING;
];
}
public function provideMemoryValues()
public static function provideMemoryValues()
{
return [
['1M', (int) (1024*1024/10)],

View File

@@ -39,12 +39,18 @@ class SyslogUdpHandlerTest extends TestCase
->onlyMethods(['write'])
->setConstructorArgs(['lol'])
->getMock();
$socket->expects($this->atLeast(2))
$matcher = $this->atLeast(2);
$socket->expects($matcher)
->method('write')
->withConsecutive(
[$this->equalTo("lol"), $this->equalTo("<".(LOG_AUTHPRIV + LOG_WARNING).">1 $time $host php $pid - - ")],
[$this->equalTo("hej"), $this->equalTo("<".(LOG_AUTHPRIV + LOG_WARNING).">1 $time $host php $pid - - ")],
);
->willReturnCallback(function () use ($matcher, $time, $host, $pid) {
match ($matcher->numberOfInvocations()) {
1 => $this->equalTo("lol") && $this->equalTo("<".(LOG_AUTHPRIV + LOG_WARNING).">1 $time $host php $pid - - "),
2 => $this->equalTo("hej") && $this->equalTo("<".(LOG_AUTHPRIV + LOG_WARNING).">1 $time $host php $pid - - "),
default => $this->assertTrue(true)
};
});
$handler->setSocket($socket);
@@ -85,12 +91,18 @@ class SyslogUdpHandlerTest extends TestCase
->setConstructorArgs(['lol', 999])
->onlyMethods(['write'])
->getMock();
$socket->expects($this->atLeast(2))
$matcher = $this->atLeast(2);
$socket->expects($matcher)
->method('write')
->withConsecutive(
[$this->equalTo("lol"), $this->equalTo("<".(LOG_AUTHPRIV + LOG_WARNING).">$time $host php[$pid]: ")],
[$this->equalTo("hej"), $this->equalTo("<".(LOG_AUTHPRIV + LOG_WARNING).">$time $host php[$pid]: ")],
);
->willReturnCallback(function () use ($matcher, $time, $host, $pid) {
match ($matcher->numberOfInvocations()) {
1 => $this->equalTo("lol") && $this->equalTo("<".(LOG_AUTHPRIV + LOG_WARNING).">$time $host php[$pid]: "),
2 => $this->equalTo("hej") && $this->equalTo("<".(LOG_AUTHPRIV + LOG_WARNING).">$time $host php[$pid]: "),
default => $this->assertTrue(true)
};
});
$handler->setSocket($socket);

View File

@@ -102,7 +102,7 @@ class TestHandlerTest extends TestCase
]));
}
public function methodProvider()
public static function methodProvider()
{
return [
['Emergency', Level::Emergency],