Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

convert annotations to attributes #571

Merged
merged 1 commit into from Mar 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 2 additions & 3 deletions tests/Unit/CacheInvalidatorTest.php
Expand Up @@ -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;
Expand Down Expand Up @@ -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 */
Expand Down
4 changes: 2 additions & 2 deletions tests/Unit/ProxyClient/HttpDispatcherTest.php
Expand Up @@ -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;
Expand All @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions tests/Unit/ProxyClient/MultiplexerClientTest.php
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down
21 changes: 6 additions & 15 deletions tests/Unit/SymfonyCache/UserContextListenerTest.php
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
Expand Up @@ -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
Expand All @@ -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);
Expand Down
5 changes: 2 additions & 3 deletions tests/Unit/Test/Proxy/VarnishProxyTest.php
Expand Up @@ -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
Expand All @@ -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');
Expand Down