Black box / round trip testing for content with duplicated values in the post_name field.
Use the dupes plugin to test scenarios that cause duplicate values in the post_name field leading to incorrectly displayed content, from the user's point of view.
For many years WordPress has allowed the user to define a permalink structure such that permalinks can be duplicated between posts. This can lead to the user being shown a link to some content which, when clicked, doesn't actually deliver the content proposed.
WordPress TRAC issue #13459 covers the initial problem, raised for a permalink structure of /%postname%/.
Deeper investigation has indicated there are a number of other problems that could/should be fixed.
v0.1.0 of this plugin doesn't yet do anything to fix the problems. It only contains PHPUnit tests to demonstrate where problems occur.
The tests currently produce two failures.
The tests don't give a clear indication of the actual test coverage and results.
This would be nice to have.
In the meantime, you'll have to read the tests and the PHPUnit test results in phpunit.json
.
The tests have been developed to run either In Situ, which means they can be run in an existing installation, or as block box testing using WordPress develop.
In both cases the tests use wp_remote_get()
to attempt to access the duplicated posts in the same way that an end user would.
The test website therefore needs to be accessible with valid values for WordPress Address (URL) and Site Address (URL).
In my development environment the installations are within subdirectories of /apache/htdocs
.
Rather than using localhost
I use a domain name of s.b
, and connect using the https scheme.
Installation type | WordPress core in | Home URL / Site URL |
---|---|---|
In Situ | cwiccer | https://s.b/cwiccer/ |
WordPress develop | wordpress-develop/src | https://s.b/wordpress-develop/src/ |
In Situ | wordpress-develop/src | https://s.b/wordpress-develop/src/ |
For In Situ testing:
oik-phpunit.php
eg. Using phpunit.bat
php ..\..\plugins\oik-batch\oik-phpunit.php "--verbose" "--disallow-test-output" "--log-junit=phpunit.json" %*
For black box testing using WordPress-develop
tests/test-issue-13459.php
file from dupes
to tests/phpunit/tests
--filter Tests-issue-13459
eg. Using phpempty.bat
@echo Run PHPUnit against WordPress core.
rem See https://make.wordpress.org/core/handbook/testing/automated-testing/phpunit/#setup
cd \apache\htdocs\wordpress-develop
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" %*
WP_TEST_SKIP_INSTALL=1
prevents the bootstrap routine from running install.phpNow supports testing In Situ testing using oik-batch and/or black box testing in a WordPress-develop environment.
First version of In Situ PHP Unit tests for WordPress TRAC issue #13459
The In Situ tests are dependent upon a number of other plugins:
References