Open bobbingwide opened 2 years ago
Run the tests
To attempt to access the posts in the same way that an end user does the tests include calls to wp_remote_get()
.
The site therefore has to be set up as a working site that you can actually log into.
Target site: https://s.b/wordpress-develop/src/
c:\apache\htdocs\wordpress-develop
.npm
and build the runtime code using npm run dev
or npm run build
.c:\apache\htdocs\wordpress-develop\wp-config.php
.c:\apache\htdocs\wordpress-develop\wp-tests-config.php
:define( 'WP_DEFAULT_THEME', 'twentytwentytwo' );
define( 'WP_DEBUG', true );
define( 'WP_TESTS_DOMAIN', 'https://s.b/wordpress-develop/src/' );
define( 'WP_TESTS_PHPUNIT_POLYFILLS_PATH', 'C:/github/Yoast/PHPUnit-Polyfills' );
default
folder; I chose twentytwentytwo.default
theme, rather than TT2.WP_TESTS_SKIP_INSTALL=1
before calling PHPunit@echo Run PHPUnit against WordPress core
rem See https://make.wordpress.org/core/handbook/testing/automated-testing/phpunit/#setup
cd \apache\htdocs\wordpress-develop
echo This is the one that empties databases. Press Enter to continue.
pause
set WP_TESTS_SKIP_INSTALL=1
php c:\apache\htdocs\phpLibraries\phpunit\phpunit-9.5.5.phar "--verbose" "--disallow-test-output" "--log-junit=phpunit.json" %*
test-issue-13459.php
into tests/phpunit/tests
BW_UnitTestCase
to WP_UnitTestCase
.phpempty --filter Tests_issue_13459 --stop-on-failure --stop-on-error
Run the tests using
Note: WordPress develop is currently: WordPress 6.0-alpha-52448-src
I get different results depending on the initial value for the site's permalink structure. The tests fail early when the permalink structure isn't set... default plain.
Initial permalink structure | first fails at... |
---|---|
( plain ) | See 1) Tests_issue_13459::test_permalink_structures |
/%year%/%monthnum%/%day%/%postname%/ ( day and name ) | See 1) Tests_issue_13459::test_permalink_structures_page_post below |
First failure for plain
1) Tests_issue_13459::test_permalink_structures
Permalink: `https://s.b/wordpress-develop/src/2022/03/29/duplicate-title-trac-13459/`
Structure: /%year%/%monthnum%/%day%/%postname%/
Failed asserting that 404 matches expected 200.
First failure for Day and Name
1) Tests_issue_13459::test_permalink_structures_page_post
Structure: /%postname%/
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'<p class="duplicate-title-trac-13459">duplicate title TRAC 13459:post:publish:617:/%postname%/</p>'
+'<p class="duplicate-title-trac-13459">duplicate title TRAC 13459:page:publish:615:/%postname%/</p>'
Distraction: Theme without comments.php
message produced.
It helps if I refer to the correct TRAC ticket.
The tests fail early when the permalink structure isn't set... default plain.
I tracked down the first part of this problem with the installation.
The .htaccess
file didn't contain the rewrite logic I'd expect to see for a subdirectory install.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /wordpress-develop/src/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wordpress-develop/src/index.php [L]
</IfModule>
Once I'd added the above then the requests made with a permalink structure were correctly served.
BTW: I'd already noted that the .htaccess file wasn't normal, but for some reason I ignored this problem. During the problem determination:
BW_UnitTestCase
.But after resetting it to WP_UnitTestCase
the In Situ tests failed immediately.
Fetching by permalink:Fetching: https://s.b/wordpress-develop/src/2022/03/29/new-post/
1) Tests_issue_13459::test_round_trip_day_and_name
Failed asserting that false is greater than 0.
C:\apache\htdocs\wordpress\wp-content\plugins\dupes\tests\test-issue-13459.php:261
C:\apache\htdocs\wordpress\wp-content\plugins\dupes\tests\test-issue-13459.php:344
But after resetting it to WP_UnitTestCase the In Situ tests failed immediately.
Meanwhile the tests run by phpempty
produce the same results as I got in other environments with the In Situ tests.
This indicates that the version of WP_UnitTestCase
class in oik-batch needs updating.
In #1 I've developed PHPUnit tests that run in situ under oik-batch, with wordpress-develop-tests.
Most core developers don't expect to have to use oik-batch. It would be better for other contributors if the tests could be run as part of the core PHPUnit tests. This will be the first time for ages that I've tried to develop PHPUnit tests for core.
Requirement
Proposed solution
Implement Workflow 4: PHPUnit PHAR file without composer.
c:\apache\htdocs\wordpress-develop
c:\github\Yoast\PHPUnit-Polyfills
empty
wp-tests-config.php
to set'WP_TESTS_PHPUNIT_POLYFILLS_PATH'
and DB infophpempty.bat file
to invoke PHPUnit