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

Wrong file order in tests/bootstrap.php #211

Closed
enumag opened this issue Jul 25, 2023 · 2 comments · Fixed by #213
Closed

Wrong file order in tests/bootstrap.php #211

enumag opened this issue Jul 25, 2023 · 2 comments · Fixed by #213

Comments

@enumag
Copy link
Contributor

enumag commented Jul 25, 2023

Hi I'm experimenting with this package locally and ran into a problem:

> vendor/bin/phpunit --colors=always
PHP Fatal error:  Trait "Traits\TestTrait" not found in /home/enumag/Projects/spaze/phpstan-disallowed-calls/tests/libs/Traits.php on line 27
PHP Stack trace:
PHP   1. {main}() /home/enumag/Projects/spaze/phpstan-disallowed-calls/vendor/bin/phpunit:0
PHP   2. include() /home/enumag/Projects/spaze/phpstan-disallowed-calls/vendor/bin/phpunit:123
PHP   3. PHPUnit\TextUI\Application->run($argv = [0 => 'vendor/bin/phpunit', 1 => '--colors=always']) /home/enumag/Projects/spaze/phpstan-disallowed-calls/vendor/phpunit/phpunit/phpunit:99
PHP   4. PHPUnit\TextUI\Application->loadBootstrapScript($filename = '/home/enumag/Projects/spaze/phpstan-disallowed-calls/tests/bootstrap.php') /home/enumag/Projects/spaze/phpstan-disallowed-calls/vendor/phpunit/phpunit/src/TextUI/Application.php:97
PHP   5. include_once() /home/enumag/Projects/spaze/phpstan-disallowed-calls/vendor/phpunit/phpunit/src/TextUI/Application.php:291
PHP   6. require_once() /home/enumag/Projects/spaze/phpstan-disallowed-calls/tests/bootstrap.php:9
Script vendor/bin/phpunit --colors=always handling the phpunit event returned with error code 255

The cause of this is that RecursiveDirectoryIterator doesn't return the filed ordered alphabetically on linux so it tried to load Traits.php before TestTrait.php.

@spaze
Copy link
Owner

spaze commented Jul 25, 2023

Hmm, interesting :-) I've added the autoloading using the iterator in #204 and it works on my Linux (WSL2) and also in CI. But I guess the order the items are returned in is some kind of "disk order" which generally could be random. Sorting wouldn't in cases like class B extends A so I'll probably revert to manual bootstrap.php updates.

spaze added a commit that referenced this issue Jul 25, 2023
…s loaded

Alphabetical order, coincidentally.

Partially reverts #204 commit 6bf2f2b

Close #211
spaze added a commit that referenced this issue Jul 25, 2023
…s loaded

Alphabetical order, coincidentally.

Partially reverts #204 commit 6bf2f2b

Close #211
spaze added a commit that referenced this issue Jul 25, 2023
…s loaded

Alphabetical order, coincidentally.

Partially reverts #204 commit 6bf2f2b

Close #211
spaze added a commit that referenced this issue Jul 25, 2023
…s loaded (#213)

Alphabetical order, coincidentally.

Partially reverts #204 commit 6bf2f2b

Close #211
@spaze
Copy link
Owner

spaze commented Jul 26, 2023

The fix for this has now been released in 2.16.0. I've reverted to listing the required files manually and created a test to test that they're all there :-) I like this even better than the autoloading.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants