Skip to content

Implement TestCase->expectProcessExit($exitCode) #6275

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

staabm
Copy link
Contributor

@staabm staabm commented Jul 15, 2025

POC for #6234

public function testOne(?int $expectedExit, int $actualExitCode): void
{
if ($expectedExit !== null) {
$this->expectProcessExit($expectedExit);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should add a PHPUnit error/warning when expectProcessExit is called in a test, which does not use process-isolation

Comment on lines +77 to +85
if ($childResult->expectedProcessExit !== null && $childResult->testCalledExit === true) {
assert($test instanceof TestCase);

$test->assertSame($childResult->expectedProcessExit, $exitCode, 'Process exit-code expectation failed');
} elseif ($childResult->expectedProcessExit !== null && $childResult->testCalledExit === false) {
$test->fail('Process expected exit() to be called but test did not call it');
} elseif ($childResult->expectedProcessExit === null && $childResult->testCalledExit === false) {
$test->fail('Process called exit() but the test did not expect it');
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need something here which allows us to combine parent-process level assertions with the child process results into a overall result

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant