Skip to content

Commit 16a1871

Browse files
minor #61299 replace PHPUnit annotations with attributes (xabbuh)
This PR was merged into the 7.4 branch. Discussion ---------- replace PHPUnit annotations with attributes | Q | A | ------------- | --- | Branch? | 7.4 | Bug fix? | no | New feature? | no | Deprecations? | no | Issues | | License | MIT Commits ------- 982f89c61b9 replace PHPUnit annotations with attributes
2 parents c18a6a4 + 7095ef5 commit 16a1871

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+208
-342
lines changed

Tests/CacheWarmer/SerializerCacheWarmerTest.php

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

1212
namespace Symfony\Bundle\FrameworkBundle\Tests\CacheWarmer;
1313

14+
use PHPUnit\Framework\Attributes\DataProvider;
1415
use Symfony\Bundle\FrameworkBundle\CacheWarmer\SerializerCacheWarmer;
1516
use Symfony\Bundle\FrameworkBundle\Tests\TestCase;
1617
use Symfony\Component\Cache\Adapter\NullAdapter;
@@ -38,9 +39,7 @@ private function getArrayPool(string $file): PhpArrayAdapter
3839
return $this->arrayPool = new PhpArrayAdapter($file, new NullAdapter());
3940
}
4041

41-
/**
42-
* @dataProvider loaderProvider
43-
*/
42+
#[DataProvider('loaderProvider')]
4443
public function testWarmUp(array $loaders)
4544
{
4645
$file = sys_get_temp_dir().'/cache-serializer.php';
@@ -57,9 +56,7 @@ public function testWarmUp(array $loaders)
5756
$this->assertTrue($arrayPool->getItem('Symfony_Bundle_FrameworkBundle_Tests_Fixtures_Serialization_Author')->isHit());
5857
}
5958

60-
/**
61-
* @dataProvider loaderProvider
62-
*/
59+
#[DataProvider('loaderProvider')]
6360
public function testWarmUpAbsoluteFilePath(array $loaders)
6461
{
6562
$file = sys_get_temp_dir().'/0/cache-serializer.php';
@@ -79,9 +76,7 @@ public function testWarmUpAbsoluteFilePath(array $loaders)
7976
$this->assertTrue($arrayPool->getItem('Symfony_Bundle_FrameworkBundle_Tests_Fixtures_Serialization_Author')->isHit());
8077
}
8178

82-
/**
83-
* @dataProvider loaderProvider
84-
*/
79+
#[DataProvider('loaderProvider')]
8580
public function testWarmUpWithoutBuildDir(array $loaders)
8681
{
8782
$file = sys_get_temp_dir().'/cache-serializer.php';

Tests/Command/CachePoolClearCommandTest.php

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

1212
namespace Symfony\Bundle\FrameworkBundle\Tests\Command;
1313

14+
use PHPUnit\Framework\Attributes\DataProvider;
1415
use PHPUnit\Framework\MockObject\MockObject;
1516
use Psr\Cache\CacheItemPoolInterface;
1617
use Symfony\Bundle\FrameworkBundle\Command\CachePoolClearCommand;
@@ -30,9 +31,7 @@ protected function setUp(): void
3031
$this->cachePool = $this->createMock(CacheItemPoolInterface::class);
3132
}
3233

33-
/**
34-
* @dataProvider provideCompletionSuggestions
35-
*/
34+
#[DataProvider('provideCompletionSuggestions')]
3635
public function testComplete(array $input, array $expectedSuggestions)
3736
{
3837
$application = new Application($this->getKernel());

Tests/Command/CachePoolDeleteCommandTest.php

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

1212
namespace Symfony\Bundle\FrameworkBundle\Tests\Command;
1313

14+
use PHPUnit\Framework\Attributes\DataProvider;
1415
use PHPUnit\Framework\MockObject\MockObject;
1516
use Psr\Cache\CacheItemPoolInterface;
1617
use Symfony\Bundle\FrameworkBundle\Command\CachePoolDeleteCommand;
@@ -84,9 +85,7 @@ public function testCommandDeleteFailed()
8485
$tester->execute(['pool' => 'foo', 'key' => 'bar']);
8586
}
8687

87-
/**
88-
* @dataProvider provideCompletionSuggestions
89-
*/
88+
#[DataProvider('provideCompletionSuggestions')]
9089
public function testComplete(array $input, array $expectedSuggestions)
9190
{
9291
$application = new Application($this->getKernel());

Tests/Command/EventDispatcherDebugCommandTest.php

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

1212
namespace Symfony\Bundle\FrameworkBundle\Tests\Command;
1313

14+
use PHPUnit\Framework\Attributes\DataProvider;
1415
use PHPUnit\Framework\TestCase;
1516
use Symfony\Bundle\FrameworkBundle\Command\EventDispatcherDebugCommand;
1617
use Symfony\Component\Console\Tester\CommandCompletionTester;
@@ -20,9 +21,7 @@
2021

2122
class EventDispatcherDebugCommandTest extends TestCase
2223
{
23-
/**
24-
* @dataProvider provideCompletionSuggestions
25-
*/
24+
#[DataProvider('provideCompletionSuggestions')]
2625
public function testComplete(array $input, array $expectedSuggestions)
2726
{
2827
$tester = $this->createCommandCompletionTester();

Tests/Command/SecretsListCommandTest.php

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

1212
namespace Symfony\Bundle\FrameworkBundle\Tests\Command;
1313

14+
use PHPUnit\Framework\Attributes\BackupGlobals;
1415
use PHPUnit\Framework\TestCase;
1516
use Symfony\Bundle\FrameworkBundle\Command\SecretsListCommand;
1617
use Symfony\Bundle\FrameworkBundle\Secrets\AbstractVault;
@@ -19,9 +20,7 @@
1920

2021
class SecretsListCommandTest extends TestCase
2122
{
22-
/**
23-
* @backupGlobals enabled
24-
*/
23+
#[BackupGlobals(true)]
2524
public function testExecute()
2625
{
2726
$vault = $this->createMock(AbstractVault::class);

Tests/Command/SecretsRemoveCommandTest.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,15 @@
1111

1212
namespace Symfony\Bundle\FrameworkBundle\Tests\Command;
1313

14+
use PHPUnit\Framework\Attributes\DataProvider;
1415
use PHPUnit\Framework\TestCase;
1516
use Symfony\Bundle\FrameworkBundle\Command\SecretsRemoveCommand;
1617
use Symfony\Bundle\FrameworkBundle\Secrets\AbstractVault;
1718
use Symfony\Component\Console\Tester\CommandCompletionTester;
1819

1920
class SecretsRemoveCommandTest extends TestCase
2021
{
21-
/**
22-
* @dataProvider provideCompletionSuggestions
23-
*/
22+
#[DataProvider('provideCompletionSuggestions')]
2423
public function testComplete(bool $withLocalVault, array $input, array $expectedSuggestions)
2524
{
2625
$vault = $this->createMock(AbstractVault::class);

Tests/Command/SecretsRevealCommandTest.php

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

1212
namespace Symfony\Bundle\FrameworkBundle\Tests\Command;
1313

14+
use PHPUnit\Framework\Attributes\BackupGlobals;
1415
use PHPUnit\Framework\TestCase;
1516
use Symfony\Bundle\FrameworkBundle\Command\SecretsRevealCommand;
1617
use Symfony\Bundle\FrameworkBundle\Secrets\AbstractVault;
@@ -59,9 +60,7 @@ public function testFailedDecrypt()
5960
$this->assertStringContainsString('The secret "secretKey" could not be decrypted.', trim($tester->getDisplay(true)));
6061
}
6162

62-
/**
63-
* @backupGlobals enabled
64-
*/
63+
#[BackupGlobals(true)]
6564
public function testLocalVaultOverride()
6665
{
6766
$vault = $this->createMock(AbstractVault::class);
@@ -78,9 +77,7 @@ public function testLocalVaultOverride()
7877
$this->assertEquals('newSecretValue', trim($tester->getDisplay(true)));
7978
}
8079

81-
/**
82-
* @backupGlobals enabled
83-
*/
80+
#[BackupGlobals(true)]
8481
public function testOnlyLocalVaultContainsName()
8582
{
8683
$vault = $this->createMock(AbstractVault::class);

Tests/Command/SecretsSetCommandTest.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,15 @@
1111

1212
namespace Symfony\Bundle\FrameworkBundle\Tests\Command;
1313

14+
use PHPUnit\Framework\Attributes\DataProvider;
1415
use PHPUnit\Framework\TestCase;
1516
use Symfony\Bundle\FrameworkBundle\Command\SecretsSetCommand;
1617
use Symfony\Bundle\FrameworkBundle\Secrets\AbstractVault;
1718
use Symfony\Component\Console\Tester\CommandCompletionTester;
1819

1920
class SecretsSetCommandTest extends TestCase
2021
{
21-
/**
22-
* @dataProvider provideCompletionSuggestions
23-
*/
22+
#[DataProvider('provideCompletionSuggestions')]
2423
public function testComplete(array $input, array $expectedSuggestions)
2524
{
2625
$vault = $this->createMock(AbstractVault::class);

Tests/Command/TranslationDebugCommandTest.php

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

1212
namespace Symfony\Bundle\FrameworkBundle\Tests\Command;
1313

14+
use PHPUnit\Framework\Attributes\DataProvider;
1415
use PHPUnit\Framework\TestCase;
1516
use Symfony\Bundle\FrameworkBundle\Command\TranslationDebugCommand;
1617
use Symfony\Bundle\FrameworkBundle\Console\Application;
@@ -240,9 +241,7 @@ private function getBundle($path)
240241
return $bundle;
241242
}
242243

243-
/**
244-
* @dataProvider provideCompletionSuggestions
245-
*/
244+
#[DataProvider('provideCompletionSuggestions')]
246245
public function testComplete(array $input, array $expectedSuggestions)
247246
{
248247
$extractedMessagesWithDomains = [

Tests/Command/TranslationExtractCommandCompletionTest.php

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

1212
namespace Symfony\Bundle\FrameworkBundle\Tests\Command;
1313

14+
use PHPUnit\Framework\Attributes\DataProvider;
1415
use PHPUnit\Framework\TestCase;
1516
use Symfony\Bundle\FrameworkBundle\Command\TranslationExtractCommand;
1617
use Symfony\Bundle\FrameworkBundle\Console\Application;
@@ -30,9 +31,7 @@ class TranslationExtractCommandCompletionTest extends TestCase
3031
private Filesystem $fs;
3132
private string $translationDir;
3233

33-
/**
34-
* @dataProvider provideCompletionSuggestions
35-
*/
34+
#[DataProvider('provideCompletionSuggestions')]
3635
public function testComplete(array $input, array $expectedSuggestions)
3736
{
3837
$tester = $this->createCommandCompletionTester(['messages' => ['foo' => 'foo']]);

0 commit comments

Comments
 (0)