Skip to content

Commit f116f61

Browse files
authored
Merge pull request #571 from FriendsOfSymfony/phpunit-data-provider-attribute
convert annotations to attributes
2 parents e7106a6 + 64275fd commit f116f61

File tree

6 files changed

+16
-27
lines changed

6 files changed

+16
-27
lines changed

tests/Unit/CacheInvalidatorTest.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
use Http\Client\Exception\NetworkException;
2828
use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
2929
use Mockery\MockInterface;
30+
use PHPUnit\Framework\Attributes as PHPUnit;
3031
use PHPUnit\Framework\TestCase;
3132
use Psr\Http\Message\RequestInterface;
3233
use Psr\Http\Message\ResponseInterface;
@@ -168,9 +169,7 @@ public static function provideOperations(): iterable
168169
];
169170
}
170171

171-
/**
172-
* @dataProvider provideOperations
173-
*/
172+
#[PHPUnit\DataProvider('provideOperations')]
174173
public function testMethodException(string $method, $arg): void
175174
{
176175
/** @var MockInterface&ProxyClient $proxyClient */

tests/Unit/ProxyClient/HttpDispatcherTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
use Http\Mock\Client;
2626
use Http\Promise\Promise;
2727
use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
28+
use PHPUnit\Framework\Attributes as PHPUnit;
2829
use PHPUnit\Framework\TestCase;
2930
use Psr\Http\Message\RequestFactoryInterface;
3031
use Psr\Http\Message\RequestInterface;
@@ -49,12 +50,11 @@ protected function setUp(): void
4950
}
5051

5152
/**
52-
* @dataProvider exceptionProvider
53-
*
5453
* @param \Exception $exception Exception thrown by HTTP client
5554
* @param string $type The returned exception class to be expected
5655
* @param string|null $message Optional exception message to match against
5756
*/
57+
#[PHPUnit\DataProvider('exceptionProvider')]
5858
public function testExceptions(\Exception $exception, string $type, ?string $message = null): void
5959
{
6060
$this->doTestException($exception, $type, $message);

tests/Unit/ProxyClient/MultiplexerClientTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
use FOS\HttpCache\ProxyClient\MultiplexerClient;
2121
use FOS\HttpCache\ProxyClient\ProxyClient;
2222
use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
23+
use PHPUnit\Framework\Attributes as PHPUnit;
2324
use PHPUnit\Framework\TestCase;
2425

2526
class MultiplexerClientTest extends TestCase
@@ -173,9 +174,8 @@ public static function provideInvalidClient(): array
173174

174175
/**
175176
* @param ProxyClient[] $clients
176-
*
177-
* @dataProvider provideInvalidClient
178177
*/
178+
#[PHPUnit\DataProvider('provideInvalidClient')]
179179
public function testInvalidClientTest(array $clients): void
180180
{
181181
$this->expectException(InvalidArgumentException::class);

tests/Unit/SymfonyCache/UserContextListenerTest.php

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use FOS\HttpCache\SymfonyCache\UserContextListener;
1717
use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
1818
use Mockery\MockInterface;
19+
use PHPUnit\Framework\Attributes as PHPUnit;
1920
use PHPUnit\Framework\MockObject\MockObject;
2021
use PHPUnit\Framework\TestCase;
2122
use Symfony\Component\HttpFoundation\Request;
@@ -55,9 +56,7 @@ public static function provideConfigOptions(): array
5556
];
5657
}
5758

58-
/**
59-
* @dataProvider provideConfigOptions
60-
*/
59+
#[PHPUnit\DataProvider('provideConfigOptions')]
6160
public function testGenerateUserHashNotAllowed(array $arg, array $options): void
6261
{
6362
$userContextListener = new UserContextListener($arg);
@@ -74,9 +73,7 @@ public function testGenerateUserHashNotAllowed(array $arg, array $options): void
7473
$this->assertSame('Bad Request', $response->getContent());
7574
}
7675

77-
/**
78-
* @dataProvider provideConfigOptions
79-
*/
76+
#[PHPUnit\DataProvider('provideConfigOptions')]
8077
public function testPassingUserHashNotAllowed(array $arg, array $options): void
8178
{
8279
$userContextListener = new UserContextListener($arg);
@@ -93,9 +90,7 @@ public function testPassingUserHashNotAllowed(array $arg, array $options): void
9390
$this->assertSame('Bad Request', $response->getContent());
9491
}
9592

96-
/**
97-
* @dataProvider provideConfigOptions
98-
*/
93+
#[PHPUnit\DataProvider('provideConfigOptions')]
9994
public function testUserHashAnonymous(array $arg, array $options): void
10095
{
10196
$userContextListener = new UserContextListener($arg);
@@ -160,9 +155,7 @@ static function (Request $request) use ($that, $hashRequest) {
160155
$this->assertNull($response);
161156
}
162157

163-
/**
164-
* @dataProvider provideConfigOptions
165-
*/
158+
#[PHPUnit\DataProvider('provideConfigOptions')]
166159
public function testUserHashUserWithSession(array $arg, array $options): void
167160
{
168161
$userContextListener = new UserContextListener($arg);
@@ -256,9 +249,7 @@ public function testUserHashUserIgnoreCookies(): void
256249
$this->assertSame('38015b703d82206ebc01d17a39c727e5', $request->headers->get('X-User-Context-Hash'));
257250
}
258251

259-
/**
260-
* @dataProvider provideConfigOptions
261-
*/
252+
#[PHPUnit\DataProvider('provideConfigOptions')]
262253
public function testUserHashUserWithAuthorizationHeader(array $arg, array $options): void
263254
{
264255
$userContextListener = new UserContextListener($arg);

tests/Unit/TagHeaderFormatter/MaxHeaderValueLengthFormatterTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use FOS\HttpCache\Exception\InvalidTagException;
1515
use FOS\HttpCache\TagHeaderFormatter\CommaSeparatedTagHeaderFormatter;
1616
use FOS\HttpCache\TagHeaderFormatter\MaxHeaderValueLengthFormatter;
17+
use PHPUnit\Framework\Attributes as PHPUnit;
1718
use PHPUnit\Framework\TestCase;
1819

1920
class MaxHeaderValueLengthFormatterTest extends TestCase
@@ -33,10 +34,9 @@ public function testNotTooLong(): void
3334
}
3435

3536
/**
36-
* @dataProvider tooLongProvider
37-
*
3837
* @param string[] $tags
3938
*/
39+
#[PHPUnit\DataProvider('tooLongProvider')]
4040
public function testTooLong(int $maxLength, array $tags, string|array $expectedHeaderValue): void
4141
{
4242
$formatter = $this->getFormatter($maxLength);

tests/Unit/Test/Proxy/VarnishProxyTest.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace FOS\HttpCache\Tests\Unit\Test\Proxy;
1313

1414
use FOS\HttpCache\Test\Proxy\VarnishProxy;
15+
use PHPUnit\Framework\Attributes as PHPUnit;
1516
use PHPUnit\Framework\TestCase;
1617

1718
class VarnishProxyTest extends TestCase
@@ -29,9 +30,7 @@ public static function allowInlineFlagProvider(): array
2930
return [[true], [false]];
3031
}
3132

32-
/**
33-
* @dataProvider allowInlineFlagProvider
34-
*/
33+
#[PHPUnit\DataProvider('allowInlineFlagProvider')]
3534
public function testStart(bool $inlineC): void
3635
{
3736
$proxy = new VarnishProxyMock('config.vcl');

0 commit comments

Comments
 (0)