Skip to content

Commit e4b6e97

Browse files
Merge branch '12.3'
2 parents 93f0abc + 7f1b593 commit e4b6e97

File tree

4 files changed

+56
-15
lines changed

4 files changed

+56
-15
lines changed

src/Metadata/Metadata.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -473,10 +473,9 @@ public static function testDoxFormatter(string $className, string $methodName):
473473
}
474474

475475
/**
476-
* @param array<array<mixed>> $data
477-
* @param ?non-empty-string $name
476+
* @param ?non-empty-string $name
478477
*/
479-
public static function testWith(array $data, ?string $name = null): TestWith
478+
public static function testWith(mixed $data, ?string $name = null): TestWith
480479
{
481480
return new TestWith(self::METHOD_LEVEL, $data, $name);
482481
}

src/Metadata/TestWith.php

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,18 @@
1616
*/
1717
final 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 int<0, 1> $level
31-
* @param array<array<mixed>> $data
32-
* @param ?non-empty-string $name
27+
* @param int<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
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php declare(strict_types=1);
2+
/*
3+
* This file is part of PHPUnit.
4+
*
5+
* (c) Sebastian Bergmann <[email protected]>
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+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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 provided by TestWith#0 attribute 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)

0 commit comments

Comments
 (0)