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 9.x breaks loading of PSR-0/PEAR style classes #5020

Closed
totten opened this issue Jul 19, 2022 · 0 comments
Closed

PHPUnit 9.x breaks loading of PSR-0/PEAR style classes #5020

totten opened this issue Jul 19, 2022 · 0 comments
Labels
type/bug Something is broken

Comments

@totten
Copy link
Contributor

totten commented Jul 19, 2022

Q A
PHPUnit version 9.5.21
PHP version 7.4.26
Installation Method PHAR

Summary

PHPUnit 9.x breaks support for loading classes that use _-based naming.

For example (https://github.com/totten/phpunit-underscore-namespace), if you have a class CRM_Utils_String, then you would want a corresponding test-class CRM_Utils_StringTest.

As is typical in PSR-0 and earlier PEAR-based conventions, the underscores are mapped to folders. The example project has typical filenames like:

  • CRM/Utils/String.php
  • tests/phpunit/CRM/Utils/StringTest.php

Current behavior

Command Result
phpunit9 Runs without error or warning
phpunit9 path/to/test/folder/ Runs with warning
phpunit9 path/to/test/file.php Fails

Full output reproduced at https://github.com/totten/phpunit-underscore-namespace#running-with-phpunit-9

How to reproduce

Checkout the example https://github.com/totten/phpunit-underscore-namespace

Expected behavior

Command Result
phpunit9 Runs without error or warning
phpunit9 path/to/test/folder/ Runs without error or warning
phpunit9 path/to/test/file.php Runs without error or warning

You can similar/expected output when running PHPUnit 8.x, eg https://github.com/totten/phpunit-underscore-namespace#running-with-phpunit-8

Discussion

The changelog (https://phpunit.de/announcements/phpunit-9.html) reports some known breaking changes:

  • (Removed) Support for using class name as CLI argument
  • (Removed) Support for declaring more that one test case class in test source file

However, it's important to note that the example here does not implicate either of these:

  • The tests are executed based on file-names (not class-names).
  • There is only one test-class in each source file. The file-names are consistent with well-known conventions (supported by PSR-0 and earlier PEAR conventions).
@totten totten added the type/bug Something is broken label Jul 19, 2022
@totten totten changed the title PHPUnit 9.x breaks loading of PSR-0 / Underscore-based Classes PHPUnit 9.x breaks loading of PSR-0/PEAR style classes Jul 19, 2022
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

2 participants