Skip to content

Commit

Permalink
test: Add regression test for sebastianbergmannGH-5595
Browse files Browse the repository at this point in the history
Signed-off-by: Natsuki Ikeguchi <[email protected]>
  • Loading branch information
siketyan committed Jan 23, 2024
1 parent 0bd6637 commit 92cc4f1
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 0 deletions.
50 changes: 50 additions & 0 deletions tests/end-to-end/regression/5595.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
--TEST--
https://github.com/sebastianbergmann/phpunit/issues/5595
--SKIPIF--
<?php declare(strict_types=1);
if (version_compare('8.3.0-dev', PHP_VERSION, '>')) {
print 'skip: PHP 8.3 is required.';
}
--FILE--
<?php declare(strict_types=1);
$_SERVER['argv'][] = '--do-not-cache-result';
$_SERVER['argv'][] = '--no-configuration';
$_SERVER['argv'][] = '--process-isolation';
$_SERVER['argv'][] = __DIR__ . '/5595/Issue5595Test.php';

require_once __DIR__ . '/../../bootstrap.php';
(new PHPUnit\TextUI\Application)->run($_SERVER['argv']);
--EXPECTF--
PHPUnit %s by Sebastian Bergmann and contributors.

Runtime: %s

E 1 / 1 (100%)

Time: %s, Memory: %s

There was 1 error:

1) PHPUnit\TestFixture\Issue5595Test::test
PHPUnit\Framework\Exception: PHP Fatal error: Uncaught PHPUnit\Event\Code\NoTestCaseObjectOnCallStackException: Cannot find TestCase object on call stack in %s%esrc%eEvent%eValue%eTest%eTestMethodBuilder.php:%d
Stack trace:
#0 %s%esrc%eRunner%eErrorHandler.php(%d): PHPUnit\Event\Code\TestMethodBuilder::fromCallStack()
#1 [internal function]: PHPUnit\Runner\ErrorHandler->__invoke(2, 'rewind(): Strea...', 'Standard input ...', %d)
#2 Standard input code(%d): rewind(Resource id #2)
#3 Standard input code(%d): __phpunit_run_isolated_test()
#4 {main}
thrown in %s%esrc%eEvent%eValue%eTest%eTestMethodBuilder.php on line %d

Fatal error: Uncaught PHPUnit\Event\Code\NoTestCaseObjectOnCallStackException: Cannot find TestCase object on call stack in %s%esrc%eEvent%eValue%eTest%eTestMethodBuilder.php on line %d

PHPUnit\Event\Code\NoTestCaseObjectOnCallStackException: Cannot find TestCase object on call stack in %s%esrc%eEvent%eValue%eTest%eTestMethodBuilder.php on line %d

Call Stack:
%s
%s
%s
%s
%s

ERRORS!
Tests: 1, Assertions: 0, Errors: 1.
29 changes: 29 additions & 0 deletions tests/end-to-end/regression/5595/Issue5595Test.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php declare(strict_types=1);
/*
* This file is part of PHPUnit.
*
* (c) Sebastian Bergmann <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace PHPUnit\TestFixture;

use PHPUnit\Framework\Attributes\RunInSeparateProcess;
use PHPUnit\Framework\TestCase;

class Issue5595Test extends TestCase
{
public function setUp(): void
{
set_error_handler(function (): bool {
return true;
});
}

#[RunInSeparateProcess]
public function test(): void
{
$this->assertTrue(true);
}
}

0 comments on commit 92cc4f1

Please sign in to comment.