Skip to content

Commit 9d30cf3

Browse files
committed
replace PHPUnit annotations with attributes
1 parent fef029c commit 9d30cf3

File tree

3 files changed

+11
-16
lines changed

3 files changed

+11
-16
lines changed

Tests/Command/UserPasswordHashCommandTest.php

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

1212
namespace Symfony\Component\PasswordHasher\Tests\Command;
1313

14+
use PHPUnit\Framework\Attributes\DataProvider;
1415
use PHPUnit\Framework\TestCase;
1516
use Symfony\Component\Console\Tester\CommandCompletionTester;
1617
use Symfony\Component\Console\Tester\CommandTester;
@@ -287,9 +288,7 @@ public function testThrowsExceptionOnNoConfiguredHashers()
287288
], ['interactive' => false]);
288289
}
289290

290-
/**
291-
* @dataProvider provideCompletionSuggestions
292-
*/
291+
#[DataProvider('provideCompletionSuggestions')]
293292
public function testCompletionSuggestions(array $input, array $expectedSuggestions)
294293
{
295294
$command = new UserPasswordHashCommand($this->createMock(PasswordHasherFactoryInterface::class), ['App\Entity\User']);

Tests/Hasher/NativePasswordHasherTest.php

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

1212
namespace Symfony\Component\PasswordHasher\Tests\Hasher;
1313

14+
use PHPUnit\Framework\Attributes\DataProvider;
15+
use PHPUnit\Framework\Attributes\RequiresPhp;
16+
use PHPUnit\Framework\Attributes\TestWith;
1417
use PHPUnit\Framework\TestCase;
1518
use Symfony\Component\PasswordHasher\Exception\InvalidPasswordException;
1619
use Symfony\Component\PasswordHasher\Hasher\NativePasswordHasher;
@@ -32,9 +35,7 @@ public function testCostAboveRange()
3235
new NativePasswordHasher(null, null, 32);
3336
}
3437

35-
/**
36-
* @dataProvider validRangeData
37-
*/
38+
#[DataProvider('validRangeData')]
3839
public function testCostInRange($cost)
3940
{
4041
$this->assertInstanceOf(NativePasswordHasher::class, new NativePasswordHasher(null, null, $cost));
@@ -99,9 +100,7 @@ public function testBcryptWithLongPassword()
99100
$this->assertTrue($hasher->verify($hasher->hash($plainPassword), $plainPassword));
100101
}
101102

102-
/**
103-
* @requires PHP < 8.4
104-
*/
103+
#[RequiresPhp('<8.4')]
105104
public function testBcryptWithNulByteWithNativePasswordHash()
106105
{
107106
$hasher = new NativePasswordHasher(null, null, 4, \PASSWORD_BCRYPT);
@@ -169,10 +168,8 @@ public function testLowMemLimitThrows()
169168
new NativePasswordHasher(3, 9999);
170169
}
171170

172-
/**
173-
* @testWith [1]
174-
* [40]
175-
*/
171+
#[TestWith([1])]
172+
#[TestWith([40])]
176173
public function testInvalidCostThrows(int $cost)
177174
{
178175
$this->expectException(\InvalidArgumentException::class);

Tests/Hasher/SodiumPasswordHasherTest.php

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

1212
namespace Symfony\Component\PasswordHasher\Tests\Hasher;
1313

14+
use PHPUnit\Framework\Attributes\RequiresPhp;
1415
use PHPUnit\Framework\TestCase;
1516
use Symfony\Component\PasswordHasher\Exception\InvalidPasswordException;
1617
use Symfony\Component\PasswordHasher\Hasher\NativePasswordHasher;
@@ -73,9 +74,7 @@ public function testBcryptWithLongPassword()
7374
$this->assertTrue($hasher->verify((new NativePasswordHasher(null, null, 4, \PASSWORD_BCRYPT))->hash($plainPassword), $plainPassword));
7475
}
7576

76-
/**
77-
* @requires PHP < 8.4
78-
*/
77+
#[RequiresPhp('<8.4')]
7978
public function testBcryptWithNulByteWithNativePasswordHash()
8079
{
8180
$hasher = new SodiumPasswordHasher(null, null);

0 commit comments

Comments
 (0)