Skip to content

Commit 729b5e1

Browse files
staabmsebastianbergmann
authored andcommitted
Test #[DataProvider] with process isolation
1 parent 8a28de3 commit 729b5e1

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php declare(strict_types=1);
2+
3+
/*
4+
* This file is part of PHPUnit.
5+
*
6+
* (c) Sebastian Bergmann <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
namespace PHPUnit\TestFixture;
12+
13+
use PHPUnit\Framework\Attributes\DataProvider;
14+
use PHPUnit\Framework\Attributes\RunInSeparateProcess;
15+
use PHPUnit\Framework\TestCase;
16+
17+
final class TestProcessIsolationWithDataProvider extends TestCase
18+
{
19+
public static function greetDataProvider(): iterable
20+
{
21+
yield ['Hello world!'];
22+
}
23+
24+
#[RunInSeparateProcess]
25+
#[DataProvider('greetDataProvider')]
26+
public function testInIsolationWithProvider(string $expected): void
27+
{
28+
$this->assertSame($expected, 'Hello world!');
29+
}
30+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
--TEST--
2+
phpunit ../_files/TestProcessIsolationWithDataProvider.php
3+
--FILE--
4+
<?php declare(strict_types=1);
5+
$_SERVER['argv'][] = '--do-not-cache-result';
6+
$_SERVER['argv'][] = '--no-configuration';
7+
$_SERVER['argv'][] = __DIR__ . '/../_files/TestProcessIsolationWithDataProvider.php';
8+
9+
require_once __DIR__ . '/../../bootstrap.php';
10+
(new PHPUnit\TextUI\Application)->run($_SERVER['argv']);
11+
--EXPECTF--
12+
PHPUnit %s by Sebastian Bergmann and contributors.
13+
14+
Runtime: %s
15+
16+
. 1 / 1 (100%)
17+
18+
Time: %s, Memory: %s
19+
20+
OK (1 test, 1 assertion)

0 commit comments

Comments
 (0)