8000 make test case classes compatible with PHPUnit 10+ · symfony/symfony@2be6c8c · GitHub
[go: up one dir, main page]

Skip to content

Commit 2be6c8c

Browse files
committed
make test case classes compatible with PHPUnit 10+
1 parent 09ee80c commit 2be6c8c

File tree

9 files changed

+44
-0
lines changed

9 files changed

+44
-0
lines changed

src/Symfony/Component/Mailer/Test/TransportFactoryTestCase.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Component\Mailer\Test;
1313

14+
use PHPUnit\Framework\Attributes\DataProvider;
1415
use PHPUnit\Framework\TestCase;
1516
use Psr\Log\LoggerInterface;
1617
use Symfony\Component\Mailer\Exception\IncompleteDsnException;
@@ -66,6 +67,7 @@ public static function incompleteDsnProvider(): iterable
6667
/**
6768
* @dataProvider supportsProvider
6869
*/
70+
#[DataProvider('supportsProvider')]
6971
public function testSupports(Dsn $dsn, bool $supports)
7072
{
7173
$factory = $this->getFactory();
@@ -76,6 +78,7 @@ public function testSupports(Dsn $dsn, bool $supports)
7678
/**
7779
* @dataProvider createProvider
7880
*/
81+
#[DataProvider('createProvider')]
7982
public function testCreate(Dsn $dsn, TransportInterface $transport)
8083
{
8184
$factory = $this->getFactory();
@@ -89,6 +92,7 @@ public function testCreate(Dsn $dsn, TransportInterface $transport)
8992
/**
9093
* @dataProvider unsupportedSchemeProvider
9194
*/
95+
#[DataProvider('unsupportedSchemeProvider')]
9296
public function testUnsupportedSchemeException(Dsn $dsn, ?string $message = null)
9397
{
9498
$factory = $this->getFactory();
@@ -104,6 +108,7 @@ public function testUnsupportedSchemeException(Dsn $dsn, ?string $message = null
104108
/**
105109
* @dataProvider incompleteDsnProvider
106110
*/
111+
#[DataProvider('incompleteDsnProvider')]
107112
public function testIncompleteDsnException(Dsn $dsn)
108113
{
109114
$factory = $this->getFactory();

src/Symfony/Component/Notifier/Test/TransportFactoryTestCase.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Component\Notifier\Test;
1313

14+
use PHPUnit\Framework\Attributes\DataProvider;
1415
use PHPUnit\Framework\TestCase;
1516
use Symfony\Component\Notifier\Exception\IncompleteDsnException;
1617
use Symfony\Component\Notifier\Exception\MissingRequiredOptionException;
@@ -65,6 +66,7 @@ public static function missingRequiredOptionProvider(): iterable
6566
/**
6667
* @dataProvider supportsProvider
6768
*/
69+
#[DataProvider('supportsProvider')]
6870
public function testSupports(bool $expected, string $dsn)
6971
{
7072
$factory = $this->createFactory();
@@ -75,6 +77,7 @@ public function testSupports(bool $expected, string $dsn)
7577
/**
7678
* @dataProvider createProvider
7779
*/
80+
#[DataProvider('createProvider')]
7881
public function testCreate(string $expected, string $dsn)
7982
{
8083
$factory = $this->createFactory();
@@ -86,6 +89,7 @@ public function testCreate(string $expected, string $dsn)
8689
/**
8790
* @dataProvider unsupportedSchemeProvider
8891
*/
92+
#[DataProvider('unsupportedSchemeProvider')]
8993
public function testUnsupportedSchemeException(string $dsn, ?string $message = null)
9094
{
9195
$factory = $this->createFactory();
@@ -103,6 +107,7 @@ public function testUnsupportedSchemeException(string $dsn, ?string $message = n
103107
/**
104108
* @dataProvider incompleteDsnProvider
105109
*/
110+
#[DataProvider('incompleteDsnProvider')]
106111
public function testIncompleteDsnException(string $dsn, ?string $message = null)
107112
{
108113
$factory = $this->createFactory();
@@ -120,6 +125,7 @@ public function testIncompleteDsnException(string $dsn, ?string $message = null)
120125
/**
121126
* @dataProvider missingRequiredOptionProvider
122127
*/
128+
#[DataProvider('missingRequiredOptionProvider')]
123129
public function testMissingRequiredOptionException(string $dsn, ?string $message = null)
124130
{
125131
$factory = $this->createFactory();

src/Symfony/Component/Notifier/Test/TransportTestCase.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Component\Notifier\Test;
1313

14+
use PHPUnit\Framework\Attributes\DataProvider;
1415
use PHPUnit\Framework\TestCase;
1516
use Symfony\Component\Notifier\Exception\UnsupportedMessageTypeException;
1617
use Symfony\Component\Notifier\Message\MessageInterface;
@@ -47,6 +48,7 @@ abstract public static function unsupportedMessagesProvider(): iterable;
4748
/**
4849
* @dataProvider toStringProvider
4950
*/
51+
#[DataProvider('toStringProvider')]
5052
public function testToString(string $expected, TransportInterface $transport)
5153
{
5254
$this->assertSame($expected, (string) $transport);
@@ -55,6 +57,7 @@ public function testToString(string $expected, TransportInterface $transport)
5557
/**
5658
* @dataProvider supportedMessagesProvider
5759
*/
60+
#[DataProvider('supportedMessagesProvider')]
5861
public function testSupportedMessages(MessageInterface $message, ?TransportInterface $transport = null)
5962
{
6063
$transport ??= $this->createTransport();
@@ -65,6 +68,7 @@ public function testSupportedMessages(MessageInterface $message, ?TransportInter
6568
/**
6669
* @dataProvider unsupportedMessagesProvider
6770
*/
71+
#[DataProvider('unsupportedMessagesProvider')]
6872
public function testUnsupportedMessages(MessageInterface $message, ?TransportInterface $transport = null)
6973
{
7074
$transport ??= $this->createTransport();
@@ -75,6 +79,7 @@ public function testUnsupportedMessages(MessageInterface $message, ?TransportInt
7579
/**
7680
* @dataProvider unsupportedMessagesProvider
7781
*/
82+
#[DataProvider('unsupportedMessagesProvider')]
7883
public function testUnsupportedMessagesTrowUnsupportedMessageTypeExceptionWhenSend(MessageInterface $message, ?TransportInterface $transport = null)
7984
{
8085
$transport ??= $this->createTransport();

src/Symfony/Component/Security/Core/Test/AccessDecisionStrategyTestCase.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Component\Security\Core\Test;
1313

14+
use PHPUnit\Framework\Attributes\DataProvider;
1415
use PHPUnit\Framework\TestCase;
1516
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
1617
use Symfony\Component\Security\Core\Authorization\AccessDecisionManager;
@@ -29,6 +30,7 @@ abstract class AccessDecisionStrategyTestCase extends TestCase
2930
*
3031
* @param VoterInterface[] $voters
3132
*/
33+
#[DataProvider('provideStrategyTests')]
3234
final public function testDecide(AccessDecisionStrategyInterface $strategy, array $voters, bool $expected)
3335
{
3436
$token = $this->createMock(TokenInterface::class);

src/Symfony/Component/Translation/Test/ProviderFactoryTestCase.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Component\Translation\Test;
1313

14+
use PHPUnit\Framework\Attributes\DataProvider;
1415
use PHPUnit\Framework\MockObject\MockObject;
1516
use PHPUnit\Framework\TestCase;
1617
use Psr\Log\LoggerInterface;
@@ -69,6 +70,7 @@ public static function incompleteDsnProvider(): iterable
6970
/**
7071
* @dataProvider supportsProvider
7172
*/
73+
#[DataProvider('supportsProvider')]
7274
public function testSupports(bool $expected, string $dsn)
7375
{
7476
$factory = $this->createFactory();
@@ -79,6 +81,7 @@ public function testSupports(bool $expected, string $dsn)
7981
/**
8082
* @dataProvider createProvider
8183
*/
84+
#[DataProvider('createProvider')]
8285
public function testCreate(string $expected, string $dsn)
8386
{
8487
$factory = $this->createFactory();
@@ -90,6 +93,7 @@ public function testCreate(string $expected, string $dsn)
9093
/**
9194
* @dataProvider unsupportedSchemeProvider
9295
*/
96+
#[DataProvider('unsupportedSchemeProvider')]
9397
public function testUnsupportedSchemeException(string $dsn, ?string $message = null)
9498
{
9599
$factory = $this->createFactory();
@@ -107,6 +111,7 @@ public function testUnsupportedSchemeException(string $dsn, ?string $message = n
107111
/**
108112
* @dataProvider incompleteDsnProvider
109113
*/
114+
#[DataProvider('incompleteDsnProvider')]
110115
public function testIncompleteDsnException(string $dsn, ?string $message = null)
111116
{
112117
$factory = $this->createFactory();

src/Symfony/Component/Translation/Test/ProviderTestCase.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Component\Translation\Test;
1313

14+
use PHPUnit\Framework\Attributes\DataProvider;
1415
use PHPUnit\Framework\MockObject\MockObject;
1516
use PHPUnit\Framework\TestCase;
1617
use Psr\Log\LoggerInterface;
@@ -45,6 +46,7 @@ abstract public static function toStringProvider(): iterable;
4546
/**
4647
* @dataProvider toStringProvider
4748
*/
49+
#[DataProvider('toStringProvider')]
4850
public function testToString(ProviderInterface $provider, string $expected)
4951
{
5052
$this->assertSame($expected, (string) $provider);

src/Symfony/Component/Webhook/Test/AbstractRequestParserTestCase.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Component\Webhook\Test;
1313

14+
use PHPUnit\Framework\Attributes\DataProvider;
1415
use PHPUnit\Framework\TestCase;
1516
use Symfony\Component\HttpFoundation\Request;
1617
use Symfony\Component\RemoteEvent\RemoteEvent;
@@ -24,6 +25,7 @@ abstract class AbstractRequestParserTestCase extends TestCase
2425
/**
2526
* @dataProvider getPayloads
2627
*/
28+
#[DataProvider('getPayloads')]
2729
public function testParse(string $payload, RemoteEvent $expected)
2830
{
2931
$request = $this->createRequest($payload);

src/Symfony/Contracts/HttpClient/Test/HttpClientTestCase.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Contracts\HttpClient\Test;
1313

14+
use PHPUnit\Framework\Attributes\RequiresPhpExtension;
1415
use PHPUnit\Framework\TestCase;
1516
use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface;
1617
use Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface;
@@ -1013,6 +1014,7 @@ public function testNoProxy()
10131014
/**
10141015
* @requires extension zlib
10151016
*/
1017+
#[RequiresPhpExtension('zlib')]
10161018
public function testAutoEncodingRequest()
10171019
{
10181020
$client = $this->getHttpClient(__FUNCTION__);
@@ -1086,6 +1088,7 @@ public function testInformationalResponseStream()
10861088
/**
10871089
* @requires extension zlib
10881090
*/
1091+
#[RequiresPhpExtension('zlib')]
10891092
public function testUserlandEncodingRequest()
10901093
{
10911094
$client = $this->getHttpClient(__FUNCTION__);
@@ -1108,6 +1111,7 @@ public function testUserlandEncodingRequest()
11081111
/**
11091112
* @requires extension zlib
11101113
*/
1114+
#[RequiresPhpExtension('zlib')]
11111115
public function testGzipBroken()
11121116
{
11131117
$client = $this->getHttpClient(__FUNCTION__);

src/Symfony/Contracts/Translation/Test/TranslatorTest.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
namespace Symfony\Contracts\Translation\Test;
1313

14+
use PHPUnit\Framework\Attributes\DataProvider;
15+
use PHPUnit\Framework\Attributes\RequiresPhpExtension;
1416
use PHPUnit\Framework\TestCase;
1517
use Symfony\Contracts\Translation\TranslatorInterface;
1618
use Symfony\Contracts\Translation\TranslatorTrait;
@@ -53,6 +55,7 @@ public function getTranslator(): TranslatorInterface
5355
/**
5456
* @dataProvider getTransTests
5557
*/
58+
#[DataProvider('getTransTests')]
5659
public function testTrans($expected, $id, $parameters)
5760
{
5861
$translator = $this->getTranslator();
@@ -63,6 +66,7 @@ public function testTrans($expected, $id, $parameters)
6366
/**
6467
* @dataProvider getTransChoiceTests
6568
*/
69+
#[DataProvider('getTransChoiceTests')]
6670
public function testTransChoiceWithExplicitLocale($expected, $id, $number)
6771
{
6872
$translator = $this->getTranslator();
@@ -75,6 +79,8 @@ public function testTransChoiceWithExplicitLocale($expected, $id, $number)
7579
*
7680
* @dataProvider getTransChoiceTests
7781
*/
82+
#[DataProvider('getTransChoiceTests')]
83+
#[RequiresPhpExtension('intl')]
7884
public function testTransChoiceWithDefaultLocale($expected, $id, $number)
7985
{
8086
$translator = $this->getTranslator();
@@ -85,6 +91,7 @@ public function testTransChoiceWithDefaultLocale($expected, $id, $number)
8591
/**
8692
* @dataProvider getTransChoiceTests
8793
*/
94+
#[DataProvider('getTransChoiceTests')]
8895
public function testTransChoiceWithEnUsPosix($expected, $id, $number)
8996
{
9097
$translator = $this->getTranslator();
@@ -103,6 +110,7 @@ public function testGetSetLocale()
103110
/**
104111
* @requires extension intl
105112
*/
113+
#[RequiresPhpExtension('intl')]
106114
public function testGetLocaleReturnsDefaultLocaleIfNotSet()
107115
{
108116
$translator = $this->getTranslator();
@@ -139,6 +147,7 @@ public static function getTransChoiceTests()
139147
/**
140148
* @dataProvider getInterval
141149
*/
150+
#[DataProvider('getInterval')]
142151
public function testInterval($expected, $number, $interval)
143152
{
144153
$translator = $this->getTranslator();
@@ -164,6 +173,7 @@ public static function getInterval()
164173
/**
165174
* @dataProvider getChooseTests
166175
*/
176+
#[DataProvider('getChooseTests')]
167177
public function testChoose($expected, $id, $number, $locale = null)
168178
{
169179
$translator = $this->getTranslator();
@@ -181,6 +191,7 @@ public function testReturnMessageIfExactlyOneStandardRuleIsGiven()
181191
/**
182192
* @dataProvider getNonMatchingMessages
183193
*/
194+
#[DataProvider('getNonMatchingMessages')]
184195
public function testThrowExceptionIfMatchingMessageCannotBeFound($id, $number)
185196
{
186197
$translator = $this->getTranslator();
@@ -296,6 +307,7 @@ public static function getChooseTests()
296307
/**
297308
* @dataProvider failingLangcodes
298309
*/
310+
#[DataProvider('failingLangcodes')]
299311
public function testFailedLangcodes($nplural, $langCodes)
300312
{
301313
$matrix = $this->generateTestData($langCodes);
@@ -305,6 +317,7 @@ public function testFailedLangcodes($nplural, $langCodes)
305317
/**
306318
* @dataProvider successLangcodes
307319
*/
320+
#[DataProvider('successLangcodes')]
308321
public function testLangcodes($nplural, $langCodes)
309322
{
310323
$matrix = $this->generateTestData($langCodes);

0 commit comments

Comments
 (0)
0