[wp-trac] [WordPress Trac] #53010: Tests: introduce namespacing for the test classes

WordPress Trac noreply at wordpress.org
Tue Sep 24 00:18:39 UTC 2024


#53010: Tests: introduce namespacing for the test classes
-------------------------------------------------+-------------------------
 Reporter:  jrf                                  |       Owner:
                                                 |  hellofromTonya
     Type:  task (blessed)                       |      Status:  assigned
 Priority:  normal                               |   Milestone:  Future
                                                 |  Release
Component:  Build/Test Tools                     |     Version:
 Severity:  normal                               |  Resolution:
 Keywords:  2nd-opinion has-patch has-unit-      |     Focuses:  docs,
  tests                                          |  coding-standards
-------------------------------------------------+-------------------------

Comment (by azaozz):

 Replying to [comment:39 hellofromTonya]:
 > As I pointed out in comment:37, the renaming and splitting are now
 requirements.
 > ...
 > For tests that include more than one function or method, split each
 function and method into a separate test class and file.
 > ...
 > Test coverage changes in PHPUnit are now the primary driver for
 splitting the tests.

 So basically according to PHPUnit there can only be one test case per
 class if test coverage is to be tracked ([https://github.com/WordPress
 /wordpress-develop/pull/6235/files example])? Do I understand this
 correctly? If yes, this seems soooo inefficient? Is PHPUnit trying to be
 as slow as possible and wear out the hard disks of the computers it is
 running on, lol?

 Joking of course, but thought PHPUnit was supposed to be [https://www.php-
 fig.org/psr/psr-4/ PSR-4] compliant, right? Limiting classes to only one
 method is not compliant.

 I'm also starting to think whether this splitting is worth it. Seems like
 a pretty bad degradation. Perhaps can settle down for partial/somewhat
 undefined coverage if that means tests will run faster and cause less
 problems?

 > the recommendation now is to fully compatible with PHPUnit naming
 conventions

 Sure, makes sense.

 > The following parts of the proposal are not required for PHPUnit 11+,
 but are ideal to address now to avoid touching the files more than once:
 >
 > - Namespace.
 > - Reorganize the test suite directory and file structure.

 I don't really care about namespacing. Don't think it would fix or improve
 anything, just some overhead and very unlikely but nevertheless possible
 back-compat issues? But if that's your personal preference, may as well
 add them.

 If adding namespaces, imho changing the directory structure won't break
 anything more :)

 Frankly I'm starting to wonder if WP should just fork PHPUnit? Perhaps
 other older PHP projects would be happy to use/help maintain a fork? As
 far as I see there are always problems when it needs to be updated, and WP
 has to "jump through hoops" to be able to use it. Seems PHPUnit doesn't
 care much about its users and what are the use cases/existing code for it
 :(

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/53010#comment:47>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list