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

PHPUnit throws a TypeError exception if called with a filename without extension #3893

Closed
morozov opened this issue Oct 10, 2019 · 0 comments
Labels
type/bug Something is broken

Comments

@morozov
Copy link
Contributor

morozov commented Oct 10, 2019

Q A
PHPUnit version 8.4.1
PHP version 7.3.10
Installation Method Composer

Summary

PHPUnit called with the name of a file that doesn't have an extension throws an unhandled TypeError exception.

How to reproduce

Assume there is a file without extension in the current directory (e.g. LICENSE).

$ phpunit LICENSE

Fatal error: Uncaught TypeError: substr() expects parameter 3 to be int, bool given in /home/morozov/Projects/dbal/vendor/phpunit/phpunit/src/TextUI/Command.php on line 808

TypeError: substr() expects parameter 3 to be int, bool given in /home/morozov/Projects/dbal/vendor/phpunit/phpunit/src/TextUI/Command.php on line 808

Call Stack:
    0.0002     491064   1. {main}() /home/morozov/Projects/dbal/vendor/phpunit/phpunit/phpunit:0
    0.0037    1047904   2. PHPUnit\TextUI\Command::main() /home/morozov/Projects/dbal/vendor/phpunit/phpunit/phpunit:61
    0.0037    1048016   3. PHPUnit\TextUI\Command->run() /home/morozov/Projects/dbal/vendor/phpunit/phpunit/src/TextUI/Command.php:159
    0.0037    1048016   4. PHPUnit\TextUI\Command->handleArguments() /home/morozov/Projects/dbal/vendor/phpunit/phpunit/src/TextUI/Command.php:167
    0.0047    1217712   5. substr() /home/morozov/Projects/dbal/vendor/phpunit/phpunit/src/TextUI/Command.php:808

Expected behavior

According to the usage, the first passed parameter is the test class. Since the class does not exist in the suite, PHPUnit should not run any tests and report a human-readable error.

@morozov morozov added the type/bug Something is broken label Oct 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/bug Something is broken
Projects
None yet
Development

No branches or pull requests

1 participant