[wp-trac] [WordPress Trac] #57071: PHPUnit tests are broken
WordPress Trac
noreply at wordpress.org
Fri Nov 11 10:07:44 UTC 2022
#57071: PHPUnit tests are broken
--------------------------+---------------------------------------------
Reporter: emanuelx | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: General | Version: 6.1
Severity: normal | Keywords: has-dev-note needs-testing-info
Focuses: |
--------------------------+---------------------------------------------
Hi, I'm using the test suite for testing the functionalities for my theme.
I've adapted your install.sh scripts in a single container, and it's
working fine until version 6.0.
My tests configuration:
PHP version: 8.0.2
{{{#!php
<?php
ENV WP_TESTS_DIR=/app/wordpress/tests
ENV WP_CORE_DIR=/usr/src/wordpress/
define( 'ABSPATH', getenv_docker('WP_CORE_DIR', '') );
}}}
**Version <=6.0**
The behaviour is:
1. Install.php file - https://github.com/WordPress/wordpress-
develop/blob/6.1/tests/phpunit/includes/install.php#L43
- on this line the require_once will duplicate the forward slash.
code line: require_once ABSPATH . '/wp-includes/class-wpdb.php';
Translated line: require_once '/usr/src/wordpress//wp-includes/class-
wpdb.php'
2. Mock-mailer file - https://github.com/WordPress/wordpress-
develop/blob/6.1/tests/phpunit/includes/mock-mailer.php#L2
on this line we have a missing slash.
code line: require_once ABSPATH . 'wp-includes/PHPMailer/PHPMailer.php';
Translated line: require_once '/usr/src/wordpress/wp-
includes/PHPMailer/PHPMailer.php';
On the first case, we have a duplicated forward slash, but this is
necessary because the includes of phpMailer inside mock-mailer.php file.
but this works fine, without any issue.
**Version 6.1**
The version 6.1 of tests, the issue with duplicated forward slash will
break the code, I don't know why on version <=6.0 it's working fine, and
on version 6.1 the error is fired.
I've analysed the code, and this is issue with duplicated slash is present
on the code for several versions. So, something was introduced on this
version 6.1 to trigger the error with require_once.
Error ABSPATH with forward slash: /usr/src/wordpress/
{{{#!php
<?php
[11-Nov-2022 10:03:02 UTC] PHP Warning: require_once(/usr/src/wordpress
//wp-includes/class-wpdb.php): Failed to open stream: No such file or
directory in /app/wordpress/tests/includes/install.php on line 43
[11-Nov-2022 10:03:02 UTC] PHP Fatal error: Uncaught Error: Failed
opening required '/usr/src/wordpress//wp-includes/class-wpdb.php'
(include_path='.:/usr/local/lib/php') in
/app/wordpress/tests/includes/install.php:43
Stack trace:
#0 {main}
thrown in /app/wordpress/tests/includes/install.php on line 43
}}}
Error ABSPATH without forward slash: /usr/src/wordpress
{{{#!php
<?php
[11-Nov-2022 10:05:45 UTC] PHP Warning: require_once(/usr/src
/wordpresswp-includes/PHPMailer/PHPMailer.php): Failed to open stream: No
such file or directory in /app/wordpress/tests/includes/mock-mailer.php on
line 2
PHPUnit 9.5.26 by Sebastian Bergmann and contributors.
Error in bootstrap script: Error:
Failed opening required '/usr/src/wordpresswp-
includes/PHPMailer/PHPMailer.php' (include_path='.:/usr/local/lib/php')
#0 /app/wordpress/tests/includes/bootstrap.php(250): require_once()
#1 /theme/tests/bootstrap.php(66): require('/app/wordpress/...')
#2 /theme/vendor/phpunit/phpunit/src/Util/FileLoader.php(66):
include_once('/theme/tests/bo...')
#3 /theme/vendor/phpunit/phpunit/src/Util/FileLoader.php(49):
PHPUnit\Util\FileLoader::load('/theme/tests/bo...')
#4 /theme/vendor/phpunit/phpunit/src/TextUI/Command.php(565):
PHPUnit\Util\FileLoader::checkAndLoad('./tests/bootstr...')
#5 /theme/vendor/phpunit/phpunit/src/TextUI/Command.php(345):
PHPUnit\TextUI\Command->handleBootstrap('./tests/bootstr...')
#6 /theme/vendor/phpunit/phpunit/src/TextUI/Command.php(112):
PHPUnit\TextUI\Command->handleArguments(Array)
#7 /theme/vendor/phpunit/phpunit/src/TextUI/Command.php(97):
PHPUnit\TextUI\Command->run(Array, true)
#8 /theme/vendor/phpunit/phpunit/phpunit(98):
PHPUnit\TextUI\Command::main()
#9 /theme/vendor/bin/phpunit(123): include('/theme/vendor/p...')
#10 {main}
Script phpunit -c phpunit-no-coverage.xml.dev handling the phpunit event
returned with error code 1
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/57071>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list