File tree Expand file tree Collapse file tree 4 files changed +53
-4
lines changed
_files/Metadata/Attribute/tests Expand file tree Collapse file tree 4 files changed +53
-4
lines changed Original file line number Diff line number Diff line change @@ -413,7 +413,7 @@ public static function testDoxOnMethod(string $text): TestDox
413413 return new TestDox (self ::METHOD_LEVEL , $ text );
414414 }
415415
416- public static function testWith (array $ data ): TestWith
416+ public static function testWith (mixed $ data ): TestWith
417417 {
418418 return new TestWith (self ::METHOD_LEVEL , $ data );
419419 }
Original file line number Diff line number Diff line change 1616 */
1717final class TestWith extends Metadata
1818{
19- private readonly array $ data ;
19+ private readonly mixed $ data ;
2020
2121 /**
2222 * @psalm-param 0|1 $level
2323 */
24- protected function __construct (int $ level , array $ data )
24+ protected function __construct (int $ level , mixed $ data )
2525 {
2626 parent ::__construct ($ level );
2727
@@ -36,7 +36,7 @@ public function isTestWith(): bool
3636 return true ;
3737 }
3838
39- public function data (): array
39+ public function data (): mixed
4040 {
4141 return $ this ->data ;
4242 }
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+ Test Triggered PHPUnit Error (PHPUnit \TestFixture \Metadata \Attribute \TestWithInvalidValueTest::testOne)
17+ The data provider specified for PHPUnit \TestFixture \Metadata \Attribute \TestWithInvalidValueTest::testOne is invalid
18+ Data set #0 is invalid
19+ Test Runner Triggered Warning (No tests found in class "PHPUnit\TestFixture\Metadata\Attribute\TestWithInvalidValueTest " .)
20+ Test Suite Loaded (0 tests)
21+ Event Facade Sealed
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