File tree Expand file tree Collapse file tree 4 files changed +56
-15
lines changed
_files/Metadata/Attribute/tests Expand file tree Collapse file tree 4 files changed +56
-15
lines changed Original file line number Diff line number Diff line change @@ -444,10 +444,9 @@ public static function testDoxOnMethod(string $text): TestDox
444444 }
445445
446446 /**
447- * @param array<array<mixed>> $data
448- * @param ?non-empty-string $name
447+ * @param ?non-empty-string $name
449448 */
450- public static function testWith (array $ data , ?string $ name = null ): TestWith
449+ public static function testWith (mixed $ data , ?string $ name = null ): TestWith
451450 {
452451 return new TestWith (self ::METHOD_LEVEL , $ data , $ name );
453452 }
Original file line number Diff line number Diff line change 1616 */
1717final readonly class TestWith extends Metadata
1818{
19- /**
20- * @var array<array<mixed>>
21- */
22- private array $ data ;
19+ private mixed $ data ;
2320
2421 /**
2522 * @var ?non-empty-string
2623 */
2724 private ?string $ name ;
2825
2926 /**
30- * @param 0|1 $level
31- * @param array<array<mixed>> $data
32- * @param ?non-empty-string $name
27+ * @param 0|1 $level
28+ * @param ?non-empty-string $name
3329 */
34- protected function __construct (int $ level , array $ data , ?string $ name = null )
30+ protected function __construct (int $ level , mixed $ data , ?string $ name = null )
3531 {
3632 parent ::__construct ($ level );
3733
@@ -44,10 +40,7 @@ public function isTestWith(): true
4440 return true ;
4541 }
4642
47- /**
48- * @return array<array<mixed>>
49- */
50- public function data (): array
43+ public function data (): mixed
5144 {
5245 return $ this ->data ;
5346 }
Original file line number Diff line number Diff line change 1+ <?php declare (strict_types=1 );
2+ /*
3+ * This file is part of PHPUnit.
4+ *
5+ * (c) Sebastian Bergmann <sebastian@phpunit.de>
6+ *
7+ * For the full copyright and license information, please view the LICENSE
8+ * file that was distributed with this source code.
9+ */
10+ namespace PHPUnit \TestFixture \Metadata \Attribute ;
11+
12+ use PHPUnit \Framework \Attributes \TestWithJson ;
13+ use PHPUnit \Framework \TestCase ;
14+
15+ final class TestWithInvalidValueTest extends TestCase
16+ {
17+ #[TestWithJson('false ' )]
18+ public function testOne ($ one , $ two ): void
19+ {
20+ $ this ->assertTrue (true );
21+ }
22+ }
Original file line number Diff line number Diff line change 1+ --TEST--
2+ The right events are emitted in the right order for a test that uses a TestWithJson attribute which provides an invalid value
3+ --FILE--
4+ <?php declare (strict_types=1 );
5+ $ _SERVER ['argv ' ][] = '--do-not-cache-result ' ;
6+ $ _SERVER ['argv ' ][] = '--no-configuration ' ;
7+ $ _SERVER ['argv ' ][] = '--debug ' ;
8+ $ _SERVER ['argv ' ][] = __DIR__ . '/../../_files/Metadata/Attribute/tests/TestWithInvalidValueTest.php ' ;
9+
10+ require __DIR__ . '/../../bootstrap.php ' ;
11+
12+ (new PHPUnit \TextUI \Application )->run ($ _SERVER ['argv ' ]);
13+ --EXPECTF --
14+ PHPUnit Started (PHPUnit %s using %s)
15+ Test Runner Configured
16+ Event Facade Sealed
17+ Test Triggered PHPUnit Error (PHPUnit \TestFixture \Metadata \Attribute \TestWithInvalidValueTest::testOne)
18+ The data provider specified for PHPUnit \TestFixture \Metadata \Attribute \TestWithInvalidValueTest::testOne is invalid
19+ Data set #0 is invalid, expected array but got bool
20+ Test Runner Triggered Warning (No tests found in class "PHPUnit\TestFixture\Metadata\Attribute\TestWithInvalidValueTest " .)
21+ Test Suite Loaded (0 tests)
22+ Test Runner Started
23+ Test Suite Sorted
24+ Test Runner Execution Started (0 tests)
25+ Test Runner Execution Finished
26+ Test Runner Finished
27+ PHPUnit Finished (Shell Exit Code: 2 )
You can’t perform that action at this time.
0 commit comments