Skip to content

Commit 8262ab5

Browse files
committed
replace PHPUnit annotations with attributes
1 parent 090eb38 commit 8262ab5

20 files changed

+61
-107
lines changed

Tests/AppVariableTest.php

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

1212
namespace Symfony\Bridge\Twig\Tests;
1313

14+
use PHPUnit\Framework\Attributes\DataProvider;
15+
use PHPUnit\Framework\Attributes\RunInSeparateProcess;
1416
use PHPUnit\Framework\TestCase;
1517
use Symfony\Bridge\Twig\AppVariable;
1618
use Symfony\Component\HttpFoundation\Request;
@@ -31,9 +33,7 @@ protected function setUp(): void
3133
$this->appVariable = new AppVariable();
3234
}
3335

34-
/**
35-
* @dataProvider debugDataProvider
36-
*/
36+
#[DataProvider('debugDataProvider')]
3737
public function testDebug($debugFlag)
3838
{
3939
$this->appVariable->setDebug($debugFlag);
@@ -56,9 +56,7 @@ public function testEnvironment()
5656
$this->assertEquals('dev', $this->appVariable->getEnvironment());
5757
}
5858

59-
/**
60-
* @runInSeparateProcess
61-
*/
59+
#[RunInSeparateProcess]
6260
public function testGetSession()
6361
{
6462
$request = $this->createMock(Request::class);
@@ -192,18 +190,14 @@ public function testGetFlashesWithNoRequest()
192190
$this->assertEquals([], $this->appVariable->getFlashes());
193191
}
194192

195-
/**
196-
* @runInSeparateProcess
197-
*/
193+
#[RunInSeparateProcess]
198194
public function testGetFlashesWithNoSessionStarted()
199195
{
200196
$flashMessages = $this->setFlashMessages(false);
201197
$this->assertEquals($flashMessages, $this->appVariable->getFlashes());
202198
}
203199

204-
/**
205-
* @runInSeparateProcess
206-
*/
200+
#[RunInSeparateProcess]
207201
public function testGetFlashes()
208202
{
209203
$flashMessages = $this->setFlashMessages();

Tests/Command/DebugCommandTest.php

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

1212
namespace Symfony\Bridge\Twig\Tests\Command;
1313

14+
use PHPUnit\Framework\Attributes\DataProvider;
1415
use PHPUnit\Framework\TestCase;
1516
use Symfony\Bridge\Twig\Command\DebugCommand;
1617
use Symfony\Component\Console\Application;
@@ -72,9 +73,7 @@ public function testMalformedTemplateName()
7273
$this->createCommandTester()->execute(['name' => '@foo']);
7374
}
7475

75-
/**
76-
* @dataProvider getDebugTemplateNameTestData
77-
*/
76+
#[DataProvider('getDebugTemplateNameTestData')]
7877
public function testDebugTemplateName(array $input, string $output, array $paths)
7978
{
8079
$tester = $this->createCommandTester($paths);
@@ -294,9 +293,7 @@ public function testWithFilter()
294293
$this->assertNotSame($display1, $display2);
295294
}
296295

297-
/**
298-
* @dataProvider provideCompletionSuggestions
299-
*/
296+
#[DataProvider('provideCompletionSuggestions')]
300297
public function testComplete(array $input, array $expectedSuggestions)
301298
{
302299
$projectDir = \dirname(__DIR__).\DIRECTORY_SEPARATOR.'Fixtures';

Tests/Command/LintCommandTest.php

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

1212
namespace Symfony\Bridge\Twig\Tests\Command;
1313

14+
use PHPUnit\Framework\Attributes\DataProvider;
1415
use PHPUnit\Framework\Attributes\Group;
1516
use PHPUnit\Framework\Attributes\IgnoreDeprecations;
1617
use PHPUnit\Framework\TestCase;
@@ -113,9 +114,7 @@ public function testLintFileWithMultipleReportedDeprecation()
113114
$this->assertStringContainsString('Filter "deprecated_filter" is deprecated', trim($tester->getDisplay()));
114115
}
115116

116-
/**
117-
* @group tty
118-
*/
117+
#[Group('tty')]
119118
public function testLintDefaultPaths()
120119
{
121120
$tester = $this->createCommandTester();
@@ -152,9 +151,7 @@ public function testLintAutodetectsGithubActionEnvironment()
152151
}
153152
}
154153

155-
/**
156-
* @dataProvider provideCompletionSuggestions
157-
*/
154+
#[DataProvider('provideCompletionSuggestions')]
158155
public function testComplete(array $input, array $expectedSuggestions)
159156
{
160157
$tester = new CommandCompletionTester($this->createCommand());

Tests/Extension/AbstractDivLayoutTestCase.php

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

1212
namespace Symfony\Bridge\Twig\Tests\Extension;
1313

14+
use PHPUnit\Framework\Attributes\DataProvider;
1415
use Symfony\Component\Form\FormError;
1516
use Symfony\Component\Security\Csrf\CsrfToken;
1617

@@ -601,9 +602,7 @@ public function testLabelIsNotRenderedWhenSetToFalse()
601602
);
602603
}
603604

604-
/**
605-
* @dataProvider themeBlockInheritanceProvider
606-
*/
605+
#[DataProvider('themeBlockInheritanceProvider')]
607606
public function testThemeBlockInheritance($theme)
608607
{
609608
$view = $this->factory
@@ -626,9 +625,7 @@ public static function themeBlockInheritanceProvider(): array
626625
];
627626
}
628627

629-
/**
630-
* @dataProvider themeInheritanceProvider
631-
*/
628+
#[DataProvider('themeInheritanceProvider')]
632629
public function testThemeInheritance($parentTheme, $childTheme)
633630
{
634631
$child = $this->factory->createNamedBuilder('child', 'Symfony\Component\Form\Extension\Core\Type\FormType')

Tests/Extension/AbstractLayoutTestCase.php

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

1212
namespace Symfony\Bridge\Twig\Tests\Extension;
1313

14+
use PHPUnit\Framework\Attributes\DataProvider;
1415
use PHPUnit\Framework\MockObject\MockObject;
1516
use Symfony\Bridge\Twig\Test\FormLayoutTestCase;
1617
use Symfony\Component\Form\Extension\Core\Type\PercentType;
@@ -2711,9 +2712,7 @@ public function testButtonWithTranslationParameters()
27112712
);
27122713
}
27132714

2714-
/**
2715-
* @dataProvider submitFormNoValidateProvider
2716-
*/
2715+
#[DataProvider('submitFormNoValidateProvider')]
27172716
public function testSubmitFormNoValidate(bool $validate)
27182717
{
27192718
$form = $this->factory->create(SubmitType::class, null, [

Tests/Extension/DumpExtensionTest.php

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

1212
namespace Symfony\Bridge\Twig\Tests\Extension;
1313

14+
use PHPUnit\Framework\Attributes\DataProvider;
1415
use PHPUnit\Framework\TestCase;
1516
use Symfony\Bridge\Twig\Extension\DumpExtension;
1617
use Symfony\Component\VarDumper\Cloner\VarCloner;
@@ -22,9 +23,7 @@
2223

2324
class DumpExtensionTest extends TestCase
2425
{
25-
/**
26-
* @dataProvider getDumpTags
27-
*/
26+
#[DataProvider('getDumpTags')]
2827
public function testDumpTag($template, $debug, $expectedOutput, $expectedDumped)
2928
{
3029
$extension = new DumpExtension(new VarCloner());
@@ -62,9 +61,7 @@ public static function getDumpTags()
6261
];
6362
}
6463

65-
/**
66-
* @dataProvider getDumpArgs
67-
*/
64+
#[DataProvider('getDumpArgs')]
6865
public function testDump($context, $args, $expectedOutput, $debug = true)
6966
{
7067
$extension = new DumpExtension(new VarCloner());

Tests/Extension/EmojiExtensionTest.php

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

1212
namespace Symfony\Bridge\Twig\Tests\Extension;
1313

14+
use PHPUnit\Framework\Attributes\RequiresPhpExtension;
15+
use PHPUnit\Framework\Attributes\TestWith;
1416
use PHPUnit\Framework\TestCase;
1517
use Symfony\Bridge\Twig\Extension\EmojiExtension;
1618

17-
/**
18-
* @requires extension intl
19-
*/
19+
#[RequiresPhpExtension('intl')]
2020
class EmojiExtensionTest extends TestCase
2121
{
22-
/**
23-
* @testWith ["🅰️", ":a:"]
24-
* ["🅰️", ":a:", "slack"]
25-
* ["🅰", ":a:", "github"]
26-
*/
22+
#[TestWith(['🅰️', ':a:'])]
23+
#[TestWith(['🅰️', ':a:', 'slack'])]
24+
#[TestWith(['🅰', ':a:', 'github'])]
2725
public function testEmojify(string $expected, string $string, ?string $catalog = null)
2826
{
2927
$extension = new EmojiExtension();

Tests/Extension/FormExtensionDivLayoutTest.php

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

1212
namespace Symfony\Bridge\Twig\Tests\Extension;
1313

14+
use PHPUnit\Framework\Attributes\DataProvider;
1415
use Symfony\Bridge\Twig\Extension\FormExtension;
1516
use Symfony\Bridge\Twig\Extension\TranslationExtension;
1617
use Symfony\Bridge\Twig\Form\TwigRendererEngine;
@@ -84,9 +85,7 @@ public static function isSelectedChoiceProvider(): array
8485
];
8586
}
8687

87-
/**
88-
* @dataProvider isSelectedChoiceProvider
89-
*/
88+
#[DataProvider('isSelectedChoiceProvider')]
9089
public function testIsChoiceSelected($expected, $choice, $value)
9190
{
9291
$choice = new ChoiceView($choice, $choice, $choice.' label');
@@ -126,9 +125,7 @@ public static function isRootFormProvider(): array
126125
];
127126
}
128127

129-
/**
130-
* @dataProvider isRootFormProvider
131-
*/
128+
#[DataProvider('isRootFormProvider')]
132129
public function testIsRootForm($expected, FormView $formView)
133130
{
134131
$this->assertSame($expected, \Symfony\Bridge\Twig\Extension\twig_is_root_form($formView));

Tests/Extension/HttpFoundationExtensionTest.php

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

1212
namespace Symfony\Bridge\Twig\Tests\Extension;
1313

14+
use PHPUnit\Framework\Attributes\DataProvider;
1415
use PHPUnit\Framework\TestCase;
1516
use Symfony\Bridge\Twig\Extension\HttpFoundationExtension;
1617
use Symfony\Component\HttpFoundation\Request;
@@ -20,9 +21,7 @@
2021

2122
class HttpFoundationExtensionTest extends TestCase
2223
{
23-
/**
24-
* @dataProvider getGenerateAbsoluteUrlData
25-
*/
24+
#[DataProvider('getGenerateAbsoluteUrlData')]
2625
public function testGenerateAbsoluteUrl($expected, $path, $pathinfo)
2726
{
2827
$stack = new RequestStack();
@@ -55,9 +54,7 @@ public static function getGenerateAbsoluteUrlData()
5554
];
5655
}
5756

58-
/**
59-
* @dataProvider getGenerateAbsoluteUrlRequestContextData
60-
*/
57+
#[DataProvider('getGenerateAbsoluteUrlRequestContextData')]
6158
public function testGenerateAbsoluteUrlWithRequestContext($path, $baseUrl, $host, $scheme, $httpPort, $httpsPort, $expected)
6259
{
6360
$requestContext = new RequestContext($baseUrl, 'GET', $host, $scheme, $httpPort, $httpsPort, $path);
@@ -66,9 +63,7 @@ public function testGenerateAbsoluteUrlWithRequestContext($path, $baseUrl, $host
6663
$this->assertEquals($expected, $extension->generateAbsoluteUrl($path));
6764
}
6865

69-
/**
70-
* @dataProvider getGenerateAbsoluteUrlRequestContextData
71-
*/
66+
#[DataProvider('getGenerateAbsoluteUrlRequestContextData')]
7267
public function testGenerateAbsoluteUrlWithoutRequestAndRequestContext($path)
7368
{
7469
$extension = new HttpFoundationExtension(new UrlHelper(new RequestStack()));
@@ -105,9 +100,7 @@ public function testGenerateAbsoluteUrlWithScriptFileName()
105100
);
106101
}
107102

108-
/**
109-
* @dataProvider getGenerateRelativePathData
110-
*/
103+
#[DataProvider('getGenerateRelativePathData')]
111104
public function testGenerateRelativePath($expected, $path, $pathinfo)
112105
{
113106
$stack = new RequestStack();

Tests/Extension/RoutingExtensionTest.php

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

1212
namespace Symfony\Bridge\Twig\Tests\Extension;
1313

14+
use PHPUnit\Framework\Attributes\DataProvider;
1415
use PHPUnit\Framework\TestCase;
1516
use Symfony\Bridge\Twig\Extension\RoutingExtension;
1617
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
@@ -21,9 +22,7 @@
2122

2223
class RoutingExtensionTest extends TestCase
2324
{
24-
/**
25-
* @dataProvider getEscapingTemplates
26-
*/
25+
#[DataProvider('getEscapingTemplates')]
2726
public function testEscaping($template, $mustBeEscaped)
2827
{
2928
$twig = new Environment($this->createMock(LoaderInterface::class), ['debug' => true, 'cache' => false, 'autoescape' => 'html', 'optimizations' => 0]);

0 commit comments

Comments
 (0)