Skip to content

Commit 1df009d

Browse files
MauricioFauthsebastianbergmann
authored andcommitted
Add e2e tests for separate process and unmet requirements
Signed-off-by: Maurício Meneghini Fauth <[email protected]>
1 parent 778e7d1 commit 1df009d

12 files changed

+370
-0
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
--TEST--
2+
https://github.com/sebastianbergmann/phpunit/issues/4391
3+
--INI--
4+
disable_functions=proc_open
5+
--FILE--
6+
<?php declare(strict_types=1);
7+
$_SERVER['argv'][] = '--do-not-cache-result';
8+
$_SERVER['argv'][] = '--no-configuration';
9+
$_SERVER['argv'][] = __DIR__ . '/4391/RunClassInSeparateProcessClassTest.php';
10+
11+
require_once __DIR__ . '/../../bootstrap.php';
12+
13+
$buffer = \file_get_contents(__DIR__ . '/../../../src/Runner/Version.php');
14+
$start = \strpos($buffer, 'new VersionId(\'') + \strlen('new VersionId(\'');
15+
$end = \strpos($buffer, '\'', $start);
16+
$version = \substr($buffer, $start, $end - $start);
17+
18+
// Version::$version requires the proc_open function
19+
(new ReflectionProperty(PHPUnit\Runner\Version::class, 'version'))->setValue(null, $version);
20+
(new PHPUnit\TextUI\Application)->run($_SERVER['argv']);
21+
--EXPECTF--
22+
PHPUnit %s by Sebastian Bergmann and contributors.
23+
24+
Runtime: %s
25+
26+
27+
28+
An error occurred inside PHPUnit.
29+
30+
Message: Call to undefined function proc_open()
31+
Location: %s:%d
32+
33+
%a
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
--TEST--
2+
https://github.com/sebastianbergmann/phpunit/issues/4391
3+
--INI--
4+
disable_functions=proc_open
5+
--FILE--
6+
<?php declare(strict_types=1);
7+
$_SERVER['argv'][] = '--do-not-cache-result';
8+
$_SERVER['argv'][] = '--no-configuration';
9+
$_SERVER['argv'][] = __DIR__ . '/4391/RunClassInSeparateProcessMethodTest.php';
10+
11+
require_once __DIR__ . '/../../bootstrap.php';
12+
13+
$buffer = \file_get_contents(__DIR__ . '/../../../src/Runner/Version.php');
14+
$start = \strpos($buffer, 'new VersionId(\'') + \strlen('new VersionId(\'');
15+
$end = \strpos($buffer, '\'', $start);
16+
$version = \substr($buffer, $start, $end - $start);
17+
18+
// Version::$version requires the proc_open function
19+
(new ReflectionProperty(PHPUnit\Runner\Version::class, 'version'))->setValue(null, $version);
20+
(new PHPUnit\TextUI\Application)->run($_SERVER['argv']);
21+
--EXPECTF--
22+
PHPUnit %s by Sebastian Bergmann and contributors.
23+
24+
Runtime: %s
25+
26+
27+
28+
An error occurred inside PHPUnit.
29+
30+
Message: Call to undefined function proc_open()
31+
Location: %s:%d
32+
33+
%a
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
--TEST--
2+
https://github.com/sebastianbergmann/phpunit/issues/4391
3+
--INI--
4+
disable_functions=proc_open
5+
--FILE--
6+
<?php declare(strict_types=1);
7+
$_SERVER['argv'][] = '--do-not-cache-result';
8+
$_SERVER['argv'][] = '--no-configuration';
9+
$_SERVER['argv'][] = __DIR__ . '/4391/RunInSeparateProcessClassTest.php';
10+
11+
require_once __DIR__ . '/../../bootstrap.php';
12+
13+
$buffer = \file_get_contents(__DIR__ . '/../../../src/Runner/Version.php');
14+
$start = \strpos($buffer, 'new VersionId(\'') + \strlen('new VersionId(\'');
15+
$end = \strpos($buffer, '\'', $start);
16+
$version = \substr($buffer, $start, $end - $start);
17+
18+
// Version::$version requires the proc_open function
19+
(new ReflectionProperty(PHPUnit\Runner\Version::class, 'version'))->setValue(null, $version);
20+
(new PHPUnit\TextUI\Application)->run($_SERVER['argv']);
21+
--EXPECTF--
22+
PHPUnit %s by Sebastian Bergmann and contributors.
23+
24+
Runtime: %s
25+
26+
27+
28+
An error occurred inside PHPUnit.
29+
30+
Message: Call to undefined function proc_open()
31+
Location: %s:%d
32+
33+
%a
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
--TEST--
2+
https://github.com/sebastianbergmann/phpunit/issues/4391
3+
--INI--
4+
disable_functions=proc_open
5+
--FILE--
6+
<?php declare(strict_types=1);
7+
$_SERVER['argv'][] = '--do-not-cache-result';
8+
$_SERVER['argv'][] = '--no-configuration';
9+
$_SERVER['argv'][] = __DIR__ . '/4391/RunInSeparateProcessMethodTest.php';
10+
11+
require_once __DIR__ . '/../../bootstrap.php';
12+
13+
$buffer = \file_get_contents(__DIR__ . '/../../../src/Runner/Version.php');
14+
$start = \strpos($buffer, 'new VersionId(\'') + \strlen('new VersionId(\'');
15+
$end = \strpos($buffer, '\'', $start);
16+
$version = \substr($buffer, $start, $end - $start);
17+
18+
// Version::$version requires the proc_open function
19+
(new ReflectionProperty(PHPUnit\Runner\Version::class, 'version'))->setValue(null, $version);
20+
(new PHPUnit\TextUI\Application)->run($_SERVER['argv']);
21+
--EXPECTF--
22+
PHPUnit %s by Sebastian Bergmann and contributors.
23+
24+
Runtime: %s
25+
26+
27+
28+
An error occurred inside PHPUnit.
29+
30+
Message: Call to undefined function proc_open()
31+
Location: %s:%d
32+
33+
%a
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
--TEST--
2+
https://github.com/sebastianbergmann/phpunit/issues/4391
3+
--INI--
4+
disable_functions=proc_open
5+
--FILE--
6+
<?php declare(strict_types=1);
7+
$_SERVER['argv'][] = '--do-not-cache-result';
8+
$_SERVER['argv'][] = '--no-configuration';
9+
$_SERVER['argv'][] = __DIR__ . '/4391/RunTestsInSeparateProcessesClassTest.php';
10+
11+
require_once __DIR__ . '/../../bootstrap.php';
12+
13+
$buffer = \file_get_contents(__DIR__ . '/../../../src/Runner/Version.php');
14+
$start = \strpos($buffer, 'new VersionId(\'') + \strlen('new VersionId(\'');
15+
$end = \strpos($buffer, '\'', $start);
16+
$version = \substr($buffer, $start, $end - $start);
17+
18+
// Version::$version requires the proc_open function
19+
(new ReflectionProperty(PHPUnit\Runner\Version::class, 'version'))->setValue(null, $version);
20+
(new PHPUnit\TextUI\Application)->run($_SERVER['argv']);
21+
--EXPECTF--
22+
PHPUnit %s by Sebastian Bergmann and contributors.
23+
24+
Runtime: %s
25+
26+
27+
28+
An error occurred inside PHPUnit.
29+
30+
Message: Call to undefined function proc_open()
31+
Location: %s:%d
32+
33+
%a
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
--TEST--
2+
https://github.com/sebastianbergmann/phpunit/issues/4391
3+
--INI--
4+
disable_functions=proc_open
5+
--FILE--
6+
<?php declare(strict_types=1);
7+
$_SERVER['argv'][] = '--do-not-cache-result';
8+
$_SERVER['argv'][] = '--no-configuration';
9+
$_SERVER['argv'][] = __DIR__ . '/4391/RunTestsInSeparateProcessesMethodTest.php';
10+
11+
require_once __DIR__ . '/../../bootstrap.php';
12+
13+
$buffer = \file_get_contents(__DIR__ . '/../../../src/Runner/Version.php');
14+
$start = \strpos($buffer, 'new VersionId(\'') + \strlen('new VersionId(\'');
15+
$end = \strpos($buffer, '\'', $start);
16+
$version = \substr($buffer, $start, $end - $start);
17+
18+
// Version::$version requires the proc_open function
19+
(new ReflectionProperty(PHPUnit\Runner\Version::class, 'version'))->setValue(null, $version);
20+
(new PHPUnit\TextUI\Application)->run($_SERVER['argv']);
21+
--EXPECTF--
22+
PHPUnit %s by Sebastian Bergmann and contributors.
23+
24+
Runtime: %s
25+
26+
27+
28+
An error occurred inside PHPUnit.
29+
30+
Message: Call to undefined function proc_open()
31+
Location: %s:%d
32+
33+
%a
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+
* 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\Issue4391;
11+
12+
use Exception;
13+
use PHPUnit\Framework\Attributes\RequiresPhpunit;
14+
use PHPUnit\Framework\Attributes\RunClassInSeparateProcess;
15+
use PHPUnit\Framework\TestCase;
16+
17+
#[RunClassInSeparateProcess]
18+
#[RequiresPhpunit('< 10')]
19+
final class RunClassInSeparateProcessClassTest extends TestCase
20+
{
21+
public function testOne(): void
22+
{
23+
throw new Exception('message');
24+
}
25+
26+
public function testTwo(): void
27+
{
28+
throw new Exception('message');
29+
}
30+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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\Issue4391;
11+
12+
use Exception;
13+
use PHPUnit\Framework\Attributes\RequiresPhpunit;
14+
use PHPUnit\Framework\Attributes\RunClassInSeparateProcess;
15+
use PHPUnit\Framework\TestCase;
16+
17+
#[RunClassInSeparateProcess]
18+
final class RunClassInSeparateProcessMethodTest extends TestCase
19+
{
20+
#[RequiresPhpunit('< 10')]
21+
public function testOne(): void
22+
{
23+
throw new Exception('message');
24+
}
25+
26+
#[RequiresPhpunit('< 10')]
27+
public function testTwo(): void
28+
{
29+
throw new Exception('message');
30+
}
31+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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\Issue4391;
11+
12+
use Exception;
13+
use PHPUnit\Framework\Attributes\RequiresPhpunit;
14+
use PHPUnit\Framework\Attributes\RunInSeparateProcess;
15+
use PHPUnit\Framework\TestCase;
16+
17+
#[RequiresPhpunit('< 10')]
18+
final class RunInSeparateProcessClassTest extends TestCase
19+
{
20+
#[RunInSeparateProcess]
21+
public function testOne(): void
22+
{
23+
throw new Exception('message');
24+
}
25+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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\Issue4391;
11+
12+
use Exception;
13+
use PHPUnit\Framework\Attributes\RequiresPhpunit;
14+
use PHPUnit\Framework\Attributes\RunInSeparateProcess;
15+
use PHPUnit\Framework\TestCase;
16+
17+
final class RunInSeparateProcessMethodTest extends TestCase
18+
{
19+
#[RunInSeparateProcess]
20+
#[RequiresPhpunit('< 10')]
21+
public function testOne(): void
22+
{
23+
throw new Exception('message');
24+
}
25+
}

0 commit comments

Comments
 (0)