Skip to content

Commit 86d6932

Browse files
authored
Merge pull request #614 from deguif/phpunit-attributes
Use phpunit attributes
2 parents 4c7e5de + f3a9d31 commit 86d6932

File tree

11 files changed

+26
-47
lines changed

11 files changed

+26
-47
lines changed

Tests/DependencyInjection/Compiler/MountDumpersPassTest.php

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

77
use JMS\TranslationBundle\DependencyInjection\Compiler\MountDumpersPass;
88
use Matthias\SymfonyDependencyInjectionTest\PhpUnit\AbstractCompilerPassTestCase;
9+
use PHPUnit\Framework\Attributes\Test;
910
use Symfony\Component\DependencyInjection\ContainerBuilder;
1011
use Symfony\Component\DependencyInjection\Definition;
1112
use Symfony\Component\DependencyInjection\Reference;
@@ -20,9 +21,7 @@ protected function registerCompilerPass(ContainerBuilder $container): void
2021
$container->addCompilerPass(new MountDumpersPass());
2122
}
2223

23-
/**
24-
* @test
25-
*/
24+
#[Test()]
2625
public function ifCompilerPassCollectsServicesByArgumentTheseWillExist(): void
2726
{
2827
$collectingService = new Definition();

Tests/DependencyInjection/Compiler/MountExtractorsPassTest.php

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

77
use JMS\TranslationBundle\DependencyInjection\Compiler\MountExtractorsPass;
88
use Matthias\SymfonyDependencyInjectionTest\PhpUnit\AbstractCompilerPassTestCase;
9+
use PHPUnit\Framework\Attributes\Test;
910
use Symfony\Component\DependencyInjection\ContainerBuilder;
1011
use Symfony\Component\DependencyInjection\Definition;
1112
use Symfony\Component\DependencyInjection\Reference;
@@ -20,9 +21,7 @@ protected function registerCompilerPass(ContainerBuilder $container): void
2021
$container->addCompilerPass(new MountExtractorsPass());
2122
}
2223

23-
/**
24-
* @test
25-
*/
24+
#[Test()]
2625
public function ifCompilerPassCollectsServicesByArgumentTheseWillExist(): void
2726
{
2827
$collectingService = new Definition();

Tests/DependencyInjection/Compiler/MountFileVisitorsPassTest.php

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

77
use JMS\TranslationBundle\DependencyInjection\Compiler\MountFileVisitorsPass;
88
use Matthias\SymfonyDependencyInjectionTest\PhpUnit\AbstractCompilerPassTestCase;
9+
use PHPUnit\Framework\Attributes\Test;
910
use Symfony\Component\DependencyInjection\ContainerBuilder;
1011
use Symfony\Component\DependencyInjection\Definition;
1112
use Symfony\Component\DependencyInjection\Reference;
@@ -20,9 +21,7 @@ protected function registerCompilerPass(ContainerBuilder $container): void
2021
$container->addCompilerPass(new MountFileVisitorsPass());
2122
}
2223

23-
/**
24-
* @test
25-
*/
24+
#[Test()]
2625
public function ifCompilerPassCollectsServicesByArgumentTheseWillExist(): void
2726
{
2827
$collectingService = new Definition();

Tests/DependencyInjection/Compiler/MountLoadersPassTest.php

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

77
use JMS\TranslationBundle\DependencyInjection\Compiler\MountLoadersPass;
88
use Matthias\SymfonyDependencyInjectionTest\PhpUnit\AbstractCompilerPassTestCase;
9+
use PHPUnit\Framework\Attributes\Test;
910
use Symfony\Component\DependencyInjection\ContainerBuilder;
1011
use Symfony\Component\DependencyInjection\Definition;
1112
use Symfony\Component\DependencyInjection\Reference;
@@ -20,9 +21,7 @@ protected function registerCompilerPass(ContainerBuilder $container): void
2021
$container->addCompilerPass(new MountLoadersPass());
2122
}
2223

23-
/**
24-
* @test
25-
*/
24+
#[Test()]
2625
public function ifCompilerPassCollectsServicesByArgumentTheseWillExist(): void
2726
{
2827
$collectingService = new Definition();

Tests/DependencyInjection/JMSTranslationExtensionTest.php

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

77
use JMS\TranslationBundle\DependencyInjection\JMSTranslationExtension;
88
use Matthias\SymfonyDependencyInjectionTest\PhpUnit\AbstractExtensionTestCase;
9+
use PHPUnit\Framework\Attributes\Test;
910

1011
/**
1112
* @author Tobias Nyholm <tobias.nyholm@gmail.com>
@@ -19,19 +20,15 @@ protected function getContainerExtensions(): array
1920
];
2021
}
2122

22-
/**
23-
* @test
24-
*/
23+
#[Test()]
2524
public function defaultParametersAfterLoading(): void
2625
{
2726
$this->load();
2827

2928
$this->assertContainerBuilderHasParameter('jms_translation.source_language', 'en');
3029
}
3130

32-
/**
33-
* @test
34-
*/
31+
#[Test()]
3532
public function basicParametersAfterLoading(): void
3633
{
3734
$locales = ['en', 'fr', 'es'];

Tests/Functional/ServiceInstantiationTest.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use JMS\TranslationBundle\Translation\ConfigFactory;
88
use JMS\TranslationBundle\Translation\Updater;
99
use JMS\TranslationBundle\Twig\TranslationExtension;
10+
use PHPUnit\Framework\Attributes\DataProvider;
1011

1112
/**
1213
* Make sure we instantiate services.
@@ -29,9 +30,7 @@ public static function provider(): array
2930
];
3031
}
3132

32-
/**
33-
* @dataProvider provider
34-
*/
33+
#[DataProvider('provider')]
3534
public function testServiceExists(string $serviceId, string $class): void
3635
{
3736
$container = static::$kernel->getContainer();

Tests/Model/FileSourceTest.php

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

2323
use JMS\TranslationBundle\Model\FileSource;
2424
use JMS\TranslationBundle\Model\SourceInterface;
25+
use PHPUnit\Framework\Attributes\DataProvider;
2526
use PHPUnit\Framework\TestCase;
2627

2728
class FileSourceTest extends TestCase
@@ -56,9 +57,7 @@ public function testGetColumnWhenSet(): void
5657
$this->assertEquals(2, $r->getColumn());
5758
}
5859

59-
/**
60-
* @dataProvider getEqualityTests
61-
*/
60+
#[DataProvider('getEqualityTests')]
6261
public function testEquals($r1, $r2, $expected): void
6362
{
6463
$this->assertSame($expected, $r1->equals($r2));
@@ -124,9 +123,7 @@ public function __toString(): string
124123
return $tests;
125124
}
126125

127-
/**
128-
* @dataProvider getToStringTests
129-
*/
126+
#[DataProvider('getToStringTests')]
130127
public function testToString(FileSource $r, string $expected): void
131128
{
132129
$this->assertEquals($expected, (string) $r);

Tests/Model/MessageCollectionTest.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
use JMS\TranslationBundle\Model\FileSource;
2424
use JMS\TranslationBundle\Model\Message;
2525
use JMS\TranslationBundle\Model\MessageCollection;
26+
use PHPUnit\Framework\Attributes\DoesNotPerformAssertions;
2627
use PHPUnit\Framework\TestCase;
2728

2829
class MessageCollectionTest extends TestCase
@@ -154,9 +155,7 @@ public function testAddChecksConsistency(): void
154155
$col->add($msg2);
155156
}
156157

157-
/**
158-
* @doesNotPerformAssertions
159-
*/
158+
#[DoesNotPerformAssertions()]
160159
public function testAddChecksConsistencyButAllowsEmptyDescs(): void
161160
{
162161
$col = new MessageCollection();
@@ -220,9 +219,7 @@ public function testSetChecksConsistency(): void
220219
$col->set($msg2);
221220
}
222221

223-
/**
224-
* @doesNotPerformAssertions
225-
*/
222+
#[DoesNotPerformAssertions()]
226223
public function testSetChecksConsistencyButAllowsEmptyDescs(): void
227224
{
228225
$col = new MessageCollection();

Tests/Translation/Extractor/File/FormExtractorTest.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,11 @@
2323
use JMS\TranslationBundle\Model\Message;
2424
use JMS\TranslationBundle\Model\MessageCatalogue;
2525
use JMS\TranslationBundle\Translation\Extractor\File\FormExtractor;
26+
use PHPUnit\Framework\Attributes\Group;
2627

2728
class FormExtractorTest extends PhpFileExtractorTestCase
2829
{
29-
/**
30-
* @group placeholder
31-
*/
30+
#[Group('placeholder')]
3231
public function testPlaceholderExtract(): void
3332
{
3433
$expected = new MessageCatalogue();
@@ -62,9 +61,7 @@ public function testPlaceholderExtract(): void
6261
$this->assertEquals($expected, $this->extract('MyPlaceholderFormType.php'));
6362
}
6463

65-
/**
66-
* @group testExtract
67-
*/
64+
#[Group('testExtract')]
6865
public function testExtract(): void
6966
{
7067
$expected = new MessageCatalogue();

Tests/Translation/FileSourceFactoryTest.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,12 @@
66

77
use JMS\TranslationBundle\Translation\FileSourceFactory;
88
use Nyholm\NSA;
9+
use PHPUnit\Framework\Attributes\DataProvider;
910
use PHPUnit\Framework\TestCase;
1011

1112
class FileSourceFactoryTest extends TestCase
1213
{
13-
/**
14-
* Test many different path to make sure we find the relative one.
15-
*
16-
* @dataProvider pathProvider
17-
*/
14+
#[DataProvider('pathProvider')]
1815
public function testGetRelativePath($root, $projectRoot, $file, $expected, $message = ''): void
1916
{
2017
$factory = new FileSourceFactory($root, $projectRoot);

0 commit comments

Comments
 (0)