[wp-trac] [WordPress Trac] #56681: Failing unit tests on PHP 8.1 and 8.2
WordPress Trac
noreply at wordpress.org
Fri Sep 30 15:16:12 UTC 2022
#56681: Failing unit tests on PHP 8.1 and 8.2
------------------------------+---------------------
Reporter: desrosj | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: 6.1
Component: Build/Test Tools | Version:
Severity: normal | Resolution:
Keywords: needs-testing | Focuses:
------------------------------+---------------------
Comment (by jrf):
I came here to open a ticket about the
`WP_Test_REST_Posts_Controller::test_get_post_draft_edit_context()` test,
only to find you already opened this ticket. 😁
I have investigated the
`WP_Test_REST_Posts_Controller::test_get_post_draft_edit_context()` test
failure and the failure is a little more problematic than a "plain" PHP
compatibility issue.
* The test sets a `$post_content` of `'Hello World'`, then does some
things and then verifies that the subsequent REST API response does
''not'' contain `'Hello World'` via a `assertStringNotContainsString()`.
* The problem is that the original post which was created with the
`'Hello World'` content, was created as a ''password protected post''.
* I couldn't reproduce the test failure locally on PHP 8.1 and when I dug
deeper, it turned out that it was because the REST API response returned
contained `'This content is password protected.'` instead of `'Hello
World'`.
* As the tests uses the ''negative'' assertion
`assertStringNotContainsString()`, it would pass, but as far as I can see,
**it doesn't actually test what it should be testing**.
My interim conclusion is that this needs further investigation on what the
''intention'' was behind the test and the test probably needs to be
rewritten to make sure the test tests what it is supposed to test.
👉🏻 I'm proposing to skip that test for now (on all PHP versions) until
it has been fixed, as, as it is, the test has no value.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/56681#comment:3>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list