1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240
|
From: =?utf-8?q?David_Pr=C3=A9vot?= <taffit@debian.org>
Date: Fri, 28 Feb 2025 13:19:29 +0100
Subject: Modernize PHPUnit syntax
---
tests/Monolog/Formatter/GoogleCloudLoggingFormatterTest.php | 7 +++----
tests/Monolog/Handler/DeduplicationHandlerTest.php | 5 +++--
tests/Monolog/Handler/FlowdockHandlerTest.php | 5 ++---
tests/Monolog/Handler/OverflowHandlerTest.php | 9 +++------
tests/Monolog/Handler/PushoverHandlerTest.php | 5 ++---
tests/Monolog/SignalHandlerTest.php | 11 ++++++-----
6 files changed, 19 insertions(+), 23 deletions(-)
diff --git a/tests/Monolog/Formatter/GoogleCloudLoggingFormatterTest.php b/tests/Monolog/Formatter/GoogleCloudLoggingFormatterTest.php
index 29c776e..b52b2c9 100644
--- a/tests/Monolog/Formatter/GoogleCloudLoggingFormatterTest.php
+++ b/tests/Monolog/Formatter/GoogleCloudLoggingFormatterTest.php
@@ -13,16 +13,16 @@ namespace Monolog\Formatter;
use DateTimeInterface;
use Monolog\Test\MonologTestCase;
+use PHPUnit\Framework\Attributes\Test;
use function json_decode;
class GoogleCloudLoggingFormatterTest extends MonologTestCase
{
/**
- * @test
- *
* @covers \Monolog\Formatter\JsonFormatter
* @covers \Monolog\Formatter\GoogleCloudLoggingFormatter::normalizeRecord
*/
+ #[Test]
public function formatProvidesRfc3339Timestamps(): void
{
$formatter = new GoogleCloudLoggingFormatter();
@@ -35,11 +35,10 @@ class GoogleCloudLoggingFormatterTest extends MonologTestCase
}
/**
- * @test
- *
* @covers \Monolog\Formatter\JsonFormatter
* @covers \Monolog\Formatter\GoogleCloudLoggingFormatter::normalizeRecord
*/
+ #[Test]
public function formatIntroducesLogSeverity(): void
{
$formatter = new GoogleCloudLoggingFormatter();
diff --git a/tests/Monolog/Handler/DeduplicationHandlerTest.php b/tests/Monolog/Handler/DeduplicationHandlerTest.php
index 100bbd5..207f5a0 100644
--- a/tests/Monolog/Handler/DeduplicationHandlerTest.php
+++ b/tests/Monolog/Handler/DeduplicationHandlerTest.php
@@ -12,6 +12,7 @@
namespace Monolog\Handler;
use Monolog\Level;
+use PHPUnit\Framework\Attributes\Depends;
class DeduplicationHandlerTest extends \Monolog\Test\MonologTestCase
{
@@ -58,8 +59,8 @@ class DeduplicationHandlerTest extends \Monolog\Test\MonologTestCase
* @covers Monolog\Handler\DeduplicationHandler::flush
* @covers Monolog\Handler\DeduplicationHandler::appendRecord
* @covers Monolog\Handler\DeduplicationHandler::isDuplicate
- * @depends testFlushPassthruIfEmptyLog
*/
+ #[Depends('testFlushPassthruIfEmptyLog')]
public function testFlushSkipsIfLogExists()
{
$test = new TestHandler();
@@ -79,8 +80,8 @@ class DeduplicationHandlerTest extends \Monolog\Test\MonologTestCase
* @covers Monolog\Handler\DeduplicationHandler::flush
* @covers Monolog\Handler\DeduplicationHandler::appendRecord
* @covers Monolog\Handler\DeduplicationHandler::isDuplicate
- * @depends testFlushPassthruIfEmptyLog
*/
+ #[Depends('testFlushPassthruIfEmptyLog')]
public function testFlushPassthruIfLogTooOld()
{
$test = new TestHandler();
diff --git a/tests/Monolog/Handler/FlowdockHandlerTest.php b/tests/Monolog/Handler/FlowdockHandlerTest.php
index 2fa7927..9eed100 100644
--- a/tests/Monolog/Handler/FlowdockHandlerTest.php
+++ b/tests/Monolog/Handler/FlowdockHandlerTest.php
@@ -13,6 +13,7 @@ namespace Monolog\Handler;
use Monolog\Formatter\FlowdockFormatter;
use Monolog\Level;
+use PHPUnit\Framework\Attributes\Depends;
/**
* @author Dominik Liebler <liebler.dominik@gmail.com>
@@ -54,9 +55,7 @@ class FlowdockHandlerTest extends \Monolog\Test\MonologTestCase
return $content;
}
- /**
- * @depends testWriteHeader
- */
+ #[Depends('testWriteHeader')]
public function testWriteContent($content)
{
$this->assertMatchesRegularExpression('/"source":"test_source"/', $content);
diff --git a/tests/Monolog/Handler/OverflowHandlerTest.php b/tests/Monolog/Handler/OverflowHandlerTest.php
index cb62ba4..4f7fe4f 100644
--- a/tests/Monolog/Handler/OverflowHandlerTest.php
+++ b/tests/Monolog/Handler/OverflowHandlerTest.php
@@ -12,6 +12,7 @@
namespace Monolog\Handler;
use Monolog\Level;
+use PHPUnit\Framework\Attributes\Test;
/**
* @author Kris Buist <krisbuist@gmail.com>
@@ -41,9 +42,7 @@ class OverflowHandlerTest extends \Monolog\Test\MonologTestCase
$this->assertTrue($testHandler->hasWarningThatContains('Warning 1'));
}
- /**
- * @test
- */
+ #[Test]
public function testHoldingMessagesBeneathThreshold()
{
$testHandler = new TestHandler();
@@ -67,9 +66,7 @@ class OverflowHandlerTest extends \Monolog\Test\MonologTestCase
}
}
- /**
- * @test
- */
+ #[Test]
public function testCombinedThresholds()
{
$testHandler = new TestHandler();
diff --git a/tests/Monolog/Handler/PushoverHandlerTest.php b/tests/Monolog/Handler/PushoverHandlerTest.php
index e2ed1dd..a84f1da 100644
--- a/tests/Monolog/Handler/PushoverHandlerTest.php
+++ b/tests/Monolog/Handler/PushoverHandlerTest.php
@@ -12,6 +12,7 @@
namespace Monolog\Handler;
use Monolog\Level;
+use PHPUnit\Framework\Attributes\Depends;
use PHPUnit\Framework\MockObject\MockObject;
/**
@@ -47,9 +48,7 @@ class PushoverHandlerTest extends \Monolog\Test\MonologTestCase
return $content;
}
- /**
- * @depends testWriteHeader
- */
+ #[Depends('testWriteHeader')]
public function testWriteContent($content)
{
$this->assertMatchesRegularExpression('/token=myToken&user=myUser&message=test1&title=Monolog×tamp=\d{10}$/', $content);
diff --git a/tests/Monolog/SignalHandlerTest.php b/tests/Monolog/SignalHandlerTest.php
index b7c6cae..d7a19bc 100644
--- a/tests/Monolog/SignalHandlerTest.php
+++ b/tests/Monolog/SignalHandlerTest.php
@@ -15,6 +15,7 @@ use Monolog\Handler\StreamHandler;
use Monolog\Handler\TestHandler;
use Monolog\Test\MonologTestCase;
use PHPUnit\Framework\Attributes\DataProvider;
+use PHPUnit\Framework\Attributes\Depends;
use Psr\Log\LogLevel;
/**
@@ -84,7 +85,6 @@ class SignalHandlerTest extends MonologTestCase
}
/**
- * @depends testHandleSignal
* @requires extension pcntl
* @requires extension posix
* @requires function pcntl_signal
@@ -92,6 +92,7 @@ class SignalHandlerTest extends MonologTestCase
* @requires function posix_getpid
* @requires function posix_kill
*/
+ #[Depends('testHandleSignal')]
public function testRegisterSignalHandler()
{
// SIGCONT and SIGURG should be ignored by default.
@@ -123,12 +124,12 @@ class SignalHandlerTest extends MonologTestCase
}
/**
- * @depends testRegisterSignalHandler
* @requires function pcntl_fork
* @requires function pcntl_sigprocmask
* @requires function pcntl_waitpid
*/
#[DataProvider('defaultPreviousProvider')]
+ #[Depends('testRegisterSignalHandler')]
public function testRegisterDefaultPreviousSignalHandler($signo, $callPrevious, $expected)
{
$this->setSignalHandler($signo, SIG_DFL);
@@ -175,10 +176,10 @@ class SignalHandlerTest extends MonologTestCase
}
/**
- * @depends testRegisterSignalHandler
* @requires function pcntl_signal_get_handler
*/
#[DataProvider('callablePreviousProvider')]
+ #[Depends('testRegisterSignalHandler')]
public function testRegisterCallablePreviousSignalHandler($callPrevious)
{
$this->setSignalHandler(SIGURG, SIG_IGN);
@@ -206,11 +207,11 @@ class SignalHandlerTest extends MonologTestCase
}
/**
- * @depends testRegisterDefaultPreviousSignalHandler
* @requires function pcntl_fork
* @requires function pcntl_waitpid
*/
#[DataProvider('restartSyscallsProvider')]
+ #[Depends('testRegisterDefaultPreviousSignalHandler')]
public function testRegisterSyscallRestartingSignalHandler($restartSyscalls)
{
$this->setSignalHandler(SIGURG, SIG_IGN);
@@ -260,10 +261,10 @@ class SignalHandlerTest extends MonologTestCase
}
/**
- * @depends testRegisterDefaultPreviousSignalHandler
* @requires function pcntl_async_signals
*/
#[DataProvider('asyncProvider')]
+ #[Depends('testRegisterDefaultPreviousSignalHandler')]
public function testRegisterAsyncSignalHandler($initialAsync, $desiredAsync, $expectedBefore, $expectedAfter)
{
$this->setSignalHandler(SIGURG, SIG_IGN);
|