Skip to content

Commit

Permalink
test: Refactor the e2e_035 test to clarify the desired behaviour
Browse files Browse the repository at this point in the history
  • Loading branch information
theofidry committed Oct 14, 2023
1 parent 6aa83da commit 3b9211f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
14 changes: 7 additions & 7 deletions fixtures/set035-composer-files-autoload/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use Throwable;
use const PHP_EOL;

// Autoload the scoped vendor guzzle. This is to mimick a scoped code that would
// Autoload the scoped vendor guzzle. This is to mimic a scoped code that would
// load this code.
// Triggering the autoloading will autoload the Guzzle `functions.php` file which
// declares the _scoped_ functions.
Expand All @@ -19,9 +19,9 @@
echo 'Autoload code.'.PHP_EOL;
require __DIR__.'/vendor/autoload.php';

// Will fail to find the function
try {
\GuzzleHttp\describe_type('hello');
} catch (Throwable $throwable) {
echo $throwable->getMessage().PHP_EOL;
}
// This is the test: it should have autoloaded the function file from the regular autoload
// despite the scoped file having been loaded previously.
\GuzzleHttp\describe_type('hello');

// Mimic PHPStan that uses some autoloaded code

8 changes: 7 additions & 1 deletion fixtures/set035-composer-files-autoload/test.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,11 @@
'#PHP Fatal error: Uncaught Error: Call to undefined function GuzzleHttp\\describe_type\(\)#',
$output,
);
$expectedResult = false;
exit($functionAutoloadFailed ? 1 : 0);
if ($functionAutoloadFailed) {
echo $output;
echo PHP_EOL;
}
exit($functionAutoloadFailed === $expectedResult ? 0 : 1);

0 comments on commit 3b9211f

Please sign in to comment.