[wp-trac] [WordPress Trac] #54470: Add support to read WP_TESTS_PHPUNIT_POLYFILLS_PATH from environment variables

WordPress Trac noreply at wordpress.org
Fri Nov 19 00:34:09 UTC 2021


#54470: Add support to read WP_TESTS_PHPUNIT_POLYFILLS_PATH from environment
variables
--------------------------------------+------------------------------
 Reporter:  shivammathur              |       Owner:  (none)
     Type:  enhancement               |      Status:  new
 Priority:  normal                    |   Milestone:  Awaiting Review
Component:  Build/Test Tools          |     Version:  trunk
 Severity:  normal                    |  Resolution:
 Keywords:  has-patch has-unit-tests  |     Focuses:
--------------------------------------+------------------------------

Comment (by jrf):

 👋🏻 Hi @shivammathur!

 I'm not opposed to this proposal, but I do not fully understand the use-
 case. Could you elaborate a little on that ?

 The way things were designed to work and have been set up, the constant is
 only supposed to be used by plugins/themes running integration tests with
 the WP Core test framework. WP Core itself does not need it.

 As plugins and themes in that situation will **''always''** need a custom
 test bootstrap file anyway - to  load the WP Core boostrap file + to
 register the plugin/theme with WP -, declaring the constant from within
 their test bootstrap file ahead of loading the WP Core bootstrap - or even
 in their [https://phpunit.readthedocs.io/en/stable/configuration.html#the-
 const-element `phpunit.xml.dist` file] - should not be a problem.

 Aside from that, in most cases, the constant isn't even needed:
 If a plugin/theme has installed PHPUnit + the Polyfills via Composer and
 includes the `vendor/autoload.php` file ahead of loading the WP Core
 bootstrap, the polyfills autoload file will already have been loaded and
 registered, so the constant is not needed.

 This also applies to to the situation where the Polyfills + PHPUnit are
 installed via `setup-php`, as in that case, both will be installed in the
 Composer global directory and PHPUnit will automatically call the
 `vendor/autoload.php` file for Composer global as explained in
 https://github.com/Yoast/PHPUnit-Polyfills/#q-how-do-i-run-my-tests-when-
 the-library-is-installed-via-the-github-actions-setup-php-action-

 So with that in mind: what problem will this solve ?

 Also see: https://make.wordpress.org/core/2021/09/27/changes-to-the-
 wordpress-core-php-test-suite/

 I'll leave some comments on the PR in a moment.

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


More information about the wp-trac mailing list