Skip to content
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

test: Refactor the e2e_035 test to clarify the desired behaviour #860

Merged
merged 1 commit into from
Oct 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);