66
77use Exception ;
88use OutOfRangeException ;
9+ use PHPUnit \Framework \Attributes \DataProvider ;
910use PHPUnit \Framework \TestCase ;
1011use Visus \Cuid2 \Cuid2 ;
1112
@@ -119,9 +120,8 @@ public function testStringRepresentationsAreConsistent(): void
119120
120121 /**
121122 * @throws Exception
122- *
123- * @dataProvider invalidLengthProvider
124123 */
124+ #[DataProvider('invalidLengthProvider ' )]
125125 public function testThrowsExceptionForInvalidLength (int $ length ): void
126126 {
127127 $ this ->expectException (OutOfRangeException::class);
@@ -200,9 +200,8 @@ public function testGeneratesUniqueValuesInLargeSample(): void
200200
201201 /**
202202 * @throws Exception
203- *
204- * @dataProvider validLengthProvider
205203 */
204+ #[DataProvider('validLengthProvider ' )]
206205 public function testGeneratesCorrectLength (int $ length ): void
207206 {
208207 $ cuid = new Cuid2 ($ length );
@@ -226,9 +225,8 @@ public function testStaticGenerateCreatesDefaultLength(): void
226225
227226 /**
228227 * @throws Exception
229- *
230- * @dataProvider validLengthProvider
231228 */
229+ #[DataProvider('validLengthProvider ' )]
232230 public function testStaticGenerateCreatesCustomLength (int $ length ): void
233231 {
234232 $ cuid = Cuid2::generate ($ length );
@@ -240,9 +238,8 @@ public function testStaticGenerateCreatesCustomLength(int $length): void
240238
241239 /**
242240 * @throws Exception
243- *
244- * @dataProvider invalidLengthProvider
245241 */
242+ #[DataProvider('invalidLengthProvider ' )]
246243 public function testStaticGenerateThrowsExceptionForInvalidLength (int $ length ): void
247244 {
248245 $ this ->expectException (OutOfRangeException::class);
@@ -262,17 +259,13 @@ public function testStaticGenerateProducesUniqueValues(): void
262259 $ this ->assertNotEquals ((string ) $ cuid1 , (string ) $ cuid2 );
263260 }
264261
265- /**
266- * @dataProvider validCuidProvider
267- */
262+ #[DataProvider('validCuidProvider ' )]
268263 public function testIsValidAcceptsValidCuids (string $ cuid , ?int $ expectedLength = null ): void
269264 {
270265 $ this ->assertTrue (Cuid2::isValid ($ cuid , $ expectedLength ));
271266 }
272267
273- /**
274- * @dataProvider invalidCuidProvider
275- */
268+ #[DataProvider('invalidCuidProvider ' )]
276269 public function testIsValidRejectsInvalidCuids (string $ cuid , ?int $ expectedLength = null ): void
277270 {
278271 $ this ->assertFalse (Cuid2::isValid ($ cuid , $ expectedLength ));
0 commit comments