Skip to content

Commit

Permalink
Prevent a problem that occurs when PHPUnit is invoked from a PHAR for…
Browse files Browse the repository at this point in the history
… a project that also installs PHPUnit via Composer
  • Loading branch information
sebastianbergmann committed Aug 5, 2020
1 parent 40bebaa commit 68efdbb
Show file tree
Hide file tree
Showing 2 changed files with 2,538 additions and 2,530 deletions.
4 changes: 4 additions & 0 deletions build/scripts/generate-global-assert-wrappers.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
}

$buffer .= "\n";
$buffer .= "if (!\defined('__PHPUNIT_GLOBAL_ASSERT_WRAPPERS__')) {\n";

foreach ($class->getMethods() as $method) {
if (\strpos($method->getName(), 'assert') !== 0) {
Expand All @@ -86,6 +87,7 @@
["*\n * @see Assert::" . $method->getName() . "\n */", ' *'],
$method->getDocComment()
);

$signature = \str_replace('public static ', '', \trim($lines[$method->getStartLine() - 1]));
$body = "{\n Assert::" . $method->getName() . "(...\\func_get_args());\n}";
$buffer .= "$docComment\n$signature\n$body\n\n";
Expand Down Expand Up @@ -213,4 +215,6 @@ function onConsecutiveCalls(): ConsecutiveCallsStub
}
';

$buffer .= "\ndefine('__PHPUNIT_GLOBAL_ASSERT_WRAPPERS__', true);\n}";

\file_put_contents(__DIR__ . '/../../src/Framework/Assert/Functions.php', $buffer);
Loading

0 comments on commit 68efdbb

Please sign in to comment.