Skip to content

Commit aaf2edb

Browse files
Merge branch '10.5' into 11.5
2 parents e31113a + 0aed983 commit aaf2edb

File tree

2 files changed

+84
-0
lines changed

2 files changed

+84
-0
lines changed
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
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\Event;
11+
12+
use Iterator;
13+
use PHPUnit\Framework\Attributes\DataProvider;
14+
use PHPUnit\Framework\TestCase;
15+
16+
final class DataProviderInvalidKeyTest extends TestCase
17+
{
18+
public static function provider(): Iterator
19+
{
20+
return new class implements Iterator
21+
{
22+
private int $position;
23+
24+
public function current(): string
25+
{
26+
return 'value';
27+
}
28+
29+
public function next(): void
30+
{
31+
$this->position++;
32+
}
33+
34+
public function key(): float
35+
{
36+
return 0.1;
37+
}
38+
39+
public function valid(): bool
40+
{
41+
return $this->position === 0;
42+
}
43+
44+
public function rewind(): void
45+
{
46+
$this->position = 0;
47+
}
48+
};
49+
}
50+
51+
#[DataProvider('provider')]
52+
public function testOne(): void
53+
{
54+
$this->assertTrue(true);
55+
}
56+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
--TEST--
2+
The right events are emitted in the right order for a test that uses a data provider that provides data with invalid keys
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/DataProviderInvalidKeyTest.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+
Data Provider Method Called (PHPUnit\TestFixture\Event\DataProviderInvalidKeyTest::provider for test method PHPUnit\TestFixture\Event\DataProviderInvalidKeyTest::testOne)
18+
Test Triggered PHPUnit Error (PHPUnit\TestFixture\Event\DataProviderInvalidKeyTest::testOne)
19+
The data provider specified for PHPUnit\TestFixture\Event\DataProviderInvalidKeyTest::testOne is invalid
20+
The key must be an integer or a string, float given
21+
Test Runner Triggered Warning (No tests found in class "PHPUnit\TestFixture\Event\DataProviderInvalidKeyTest".)
22+
Test Suite Loaded (0 tests)
23+
Test Runner Started
24+
Test Suite Sorted
25+
Test Runner Execution Started (0 tests)
26+
Test Runner Execution Finished
27+
Test Runner Finished
28+
PHPUnit Finished (Shell Exit Code: 2)

0 commit comments

Comments
 (0)