[wp-trac] [WordPress Trac] #56681: Failing unit tests on PHP 8.1 and 8.2

WordPress Trac noreply at wordpress.org
Sat Oct 1 15:47:27 UTC 2022


#56681: Failing unit tests on PHP 8.1 and 8.2
-------------------------------------------------+-------------------------
 Reporter:  desrosj                              |       Owner:
                                                 |  SergeyBiryukov
     Type:  defect (bug)                         |      Status:  accepted
 Priority:  normal                               |   Milestone:  6.1
Component:  Build/Test Tools                     |     Version:
 Severity:  normal                               |  Resolution:
 Keywords:  needs-testing has-patch has-unit-    |     Focuses:
  tests                                          |
-------------------------------------------------+-------------------------

Comment (by SergeyBiryukov):

 In [changeset:"54365" 54365]:
 {{{
 #!CommitTicketReference repository="" revision="54365"
 Tests: Ensure prerequisites are met for draft length tests in
 `Tests_L10n`.

 These three tests for `wp_dashboard_recent_drafts()` would run into a PHP
 8.1 "passing null to non-nullable" deprecation for the call to `ltrim()`
 when the result of `get_edit_post_link()` is passed to `esc_url()`.

 Setting a deprecation expectation would not solve this as the returned
 value would still not match the expected value(s).

 The recent drafts list is only displayed on the Dashboard screen for users
 with the `edit_posts` capability. By setting the current user to Editor,
 the prerequisites for `wp_dashboard_recent_drafts()` are met, which means
 the deprecation notice is avoided and the assertions will succeed.

 This commit addresses a few errors in the test suite along the lines of:
 {{{
 1) Tests_L10n::test_length_of_draft_should_be_counted_by_words
 ltrim(): Passing null to parameter #1 ($string) of type string is
 deprecated

 /var/www/src/wp-includes/formatting.php:4376
 /var/www/src/wp-admin/includes/dashboard.php:657
 /var/www/tests/phpunit/tests/l10n.php:449
 /var/www/vendor/bin/phpunit:123
 }}}

 Follow-up to [45505], [52253], [52259].

 Props jrf, desrosj, SergeyBiryukov.
 See #56681, #55652, #55656.
 }}}

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


More information about the wp-trac mailing list