From 64275fdd1ee1a1b2c865ea82ea6e0b415a27e056 Mon Sep 17 00:00:00 2001 From: David Buchmann Date: Thu, 28 Mar 2024 11:12:30 +0100 Subject: [PATCH] convert annotations to attributes --- tests/Unit/CacheInvalidatorTest.php | 5 ++--- tests/Unit/ProxyClient/HttpDispatcherTest.php | 4 ++-- .../ProxyClient/MultiplexerClientTest.php | 4 ++-- .../SymfonyCache/UserContextListenerTest.php | 21 ++++++------------- .../MaxHeaderValueLengthFormatterTest.php | 4 ++-- tests/Unit/Test/Proxy/VarnishProxyTest.php | 5 ++--- 6 files changed, 16 insertions(+), 27 deletions(-) diff --git a/tests/Unit/CacheInvalidatorTest.php b/tests/Unit/CacheInvalidatorTest.php index 4fe02c46..71becd08 100644 --- a/tests/Unit/CacheInvalidatorTest.php +++ b/tests/Unit/CacheInvalidatorTest.php @@ -27,6 +27,7 @@ use Http\Client\Exception\NetworkException; use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration; use Mockery\MockInterface; +use PHPUnit\Framework\Attributes as PHPUnit; use PHPUnit\Framework\TestCase; use Psr\Http\Message\RequestInterface; use Psr\Http\Message\ResponseInterface; @@ -168,9 +169,7 @@ public static function provideOperations(): iterable ]; } - /** - * @dataProvider provideOperations - */ + #[PHPUnit\DataProvider('provideOperations')] public function testMethodException(string $method, $arg): void { /** @var MockInterface&ProxyClient $proxyClient */ diff --git a/tests/Unit/ProxyClient/HttpDispatcherTest.php b/tests/Unit/ProxyClient/HttpDispatcherTest.php index 840d079d..b6918b27 100644 --- a/tests/Unit/ProxyClient/HttpDispatcherTest.php +++ b/tests/Unit/ProxyClient/HttpDispatcherTest.php @@ -25,6 +25,7 @@ use Http\Mock\Client; use Http\Promise\Promise; use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration; +use PHPUnit\Framework\Attributes as PHPUnit; use PHPUnit\Framework\TestCase; use Psr\Http\Message\RequestFactoryInterface; use Psr\Http\Message\RequestInterface; @@ -49,12 +50,11 @@ protected function setUp(): void } /** - * @dataProvider exceptionProvider - * * @param \Exception $exception Exception thrown by HTTP client * @param string $type The returned exception class to be expected * @param string|null $message Optional exception message to match against */ + #[PHPUnit\DataProvider('exceptionProvider')] public function testExceptions(\Exception $exception, string $type, ?string $message = null): void { $this->doTestException($exception, $type, $message); diff --git a/tests/Unit/ProxyClient/MultiplexerClientTest.php b/tests/Unit/ProxyClient/MultiplexerClientTest.php index dbd9880a..c88e966d 100644 --- a/tests/Unit/ProxyClient/MultiplexerClientTest.php +++ b/tests/Unit/ProxyClient/MultiplexerClientTest.php @@ -20,6 +20,7 @@ use FOS\HttpCache\ProxyClient\MultiplexerClient; use FOS\HttpCache\ProxyClient\ProxyClient; use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration; +use PHPUnit\Framework\Attributes as PHPUnit; use PHPUnit\Framework\TestCase; class MultiplexerClientTest extends TestCase @@ -173,9 +174,8 @@ public static function provideInvalidClient(): array /** * @param ProxyClient[] $clients - * - * @dataProvider provideInvalidClient */ + #[PHPUnit\DataProvider('provideInvalidClient')] public function testInvalidClientTest(array $clients): void { $this->expectException(InvalidArgumentException::class); diff --git a/tests/Unit/SymfonyCache/UserContextListenerTest.php b/tests/Unit/SymfonyCache/UserContextListenerTest.php index 1bb73339..17e9caa8 100644 --- a/tests/Unit/SymfonyCache/UserContextListenerTest.php +++ b/tests/Unit/SymfonyCache/UserContextListenerTest.php @@ -16,6 +16,7 @@ use FOS\HttpCache\SymfonyCache\UserContextListener; use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration; use Mockery\MockInterface; +use PHPUnit\Framework\Attributes as PHPUnit; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use Symfony\Component\HttpFoundation\Request; @@ -55,9 +56,7 @@ public static function provideConfigOptions(): array ]; } - /** - * @dataProvider provideConfigOptions - */ + #[PHPUnit\DataProvider('provideConfigOptions')] public function testGenerateUserHashNotAllowed(array $arg, array $options): void { $userContextListener = new UserContextListener($arg); @@ -74,9 +73,7 @@ public function testGenerateUserHashNotAllowed(array $arg, array $options): void $this->assertSame('Bad Request', $response->getContent()); } - /** - * @dataProvider provideConfigOptions - */ + #[PHPUnit\DataProvider('provideConfigOptions')] public function testPassingUserHashNotAllowed(array $arg, array $options): void { $userContextListener = new UserContextListener($arg); @@ -93,9 +90,7 @@ public function testPassingUserHashNotAllowed(array $arg, array $options): void $this->assertSame('Bad Request', $response->getContent()); } - /** - * @dataProvider provideConfigOptions - */ + #[PHPUnit\DataProvider('provideConfigOptions')] public function testUserHashAnonymous(array $arg, array $options): void { $userContextListener = new UserContextListener($arg); @@ -160,9 +155,7 @@ static function (Request $request) use ($that, $hashRequest) { $this->assertNull($response); } - /** - * @dataProvider provideConfigOptions - */ + #[PHPUnit\DataProvider('provideConfigOptions')] public function testUserHashUserWithSession(array $arg, array $options): void { $userContextListener = new UserContextListener($arg); @@ -256,9 +249,7 @@ public function testUserHashUserIgnoreCookies(): void $this->assertSame('38015b703d82206ebc01d17a39c727e5', $request->headers->get('X-User-Context-Hash')); } - /** - * @dataProvider provideConfigOptions - */ + #[PHPUnit\DataProvider('provideConfigOptions')] public function testUserHashUserWithAuthorizationHeader(array $arg, array $options): void { $userContextListener = new UserContextListener($arg); diff --git a/tests/Unit/TagHeaderFormatter/MaxHeaderValueLengthFormatterTest.php b/tests/Unit/TagHeaderFormatter/MaxHeaderValueLengthFormatterTest.php index bcb970ce..da55a236 100644 --- a/tests/Unit/TagHeaderFormatter/MaxHeaderValueLengthFormatterTest.php +++ b/tests/Unit/TagHeaderFormatter/MaxHeaderValueLengthFormatterTest.php @@ -14,6 +14,7 @@ use FOS\HttpCache\Exception\InvalidTagException; use FOS\HttpCache\TagHeaderFormatter\CommaSeparatedTagHeaderFormatter; use FOS\HttpCache\TagHeaderFormatter\MaxHeaderValueLengthFormatter; +use PHPUnit\Framework\Attributes as PHPUnit; use PHPUnit\Framework\TestCase; class MaxHeaderValueLengthFormatterTest extends TestCase @@ -33,10 +34,9 @@ public function testNotTooLong(): void } /** - * @dataProvider tooLongProvider - * * @param string[] $tags */ + #[PHPUnit\DataProvider('tooLongProvider')] public function testTooLong(int $maxLength, array $tags, string|array $expectedHeaderValue): void { $formatter = $this->getFormatter($maxLength); diff --git a/tests/Unit/Test/Proxy/VarnishProxyTest.php b/tests/Unit/Test/Proxy/VarnishProxyTest.php index 44178fd4..e43dd356 100644 --- a/tests/Unit/Test/Proxy/VarnishProxyTest.php +++ b/tests/Unit/Test/Proxy/VarnishProxyTest.php @@ -12,6 +12,7 @@ namespace FOS\HttpCache\Tests\Unit\Test\Proxy; use FOS\HttpCache\Test\Proxy\VarnishProxy; +use PHPUnit\Framework\Attributes as PHPUnit; use PHPUnit\Framework\TestCase; class VarnishProxyTest extends TestCase @@ -29,9 +30,7 @@ public static function allowInlineFlagProvider(): array return [[true], [false]]; } - /** - * @dataProvider allowInlineFlagProvider - */ + #[PHPUnit\DataProvider('allowInlineFlagProvider')] public function testStart(bool $inlineC): void { $proxy = new VarnishProxyMock('config.vcl');