Skip to content

Commit 68efdbb

Browse files
Prevent a problem that occurs when PHPUnit is invoked from a PHAR for a project that also installs PHPUnit via Composer
1 parent 40bebaa commit 68efdbb

File tree

2 files changed

+2538
-2530
lines changed

2 files changed

+2538
-2530
lines changed

build/scripts/generate-global-assert-wrappers.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@
7575
}
7676

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

7980
foreach ($class->getMethods() as $method) {
8081
if (\strpos($method->getName(), 'assert') !== 0) {
@@ -86,6 +87,7 @@
8687
["*\n * @see Assert::" . $method->getName() . "\n */", ' *'],
8788
$method->getDocComment()
8889
);
90+
8991
$signature = \str_replace('public static ', '', \trim($lines[$method->getStartLine() - 1]));
9092
$body = "{\n Assert::" . $method->getName() . "(...\\func_get_args());\n}";
9193
$buffer .= "$docComment\n$signature\n$body\n\n";
@@ -213,4 +215,6 @@ function onConsecutiveCalls(): ConsecutiveCallsStub
213215
}
214216
';
215217

218+
$buffer .= "\ndefine('__PHPUNIT_GLOBAL_ASSERT_WRAPPERS__', true);\n}";
219+
216220
\file_put_contents(__DIR__ . '/../../src/Framework/Assert/Functions.php', $buffer);

0 commit comments

Comments
 (0)