diff --git a/tests/phpunit/tests/admin/includesListTable.php b/tests/phpunit/tests/admin/includesListTable.php
index ac2e153e2f..af589dcfe6 100644
--- a/tests/phpunit/tests/admin/includesListTable.php
+++ b/tests/phpunit/tests/admin/includesListTable.php
@@ -185,6 +185,16 @@ class Tests_Admin_IncludesListTable extends WP_UnitTestCase {
* @param array $expected_ids Expected IDs of pages returned.
*/
protected function _test_list_hierarchical_page( array $args, array $expected_ids ) {
+ if ( PHP_VERSION_ID >= 80100 ) {
+ /*
+ * For the time being, ignoring PHP 8.1 "null to non-nullable" deprecations coming in
+ * via hooked in filter functions until a more structural solution to the
+ * "missing input validation" conundrum has been architected and implemented.
+ */
+ $this->expectDeprecation();
+ $this->expectDeprecationMessageMatches( '`Passing null to parameter \#[0-9]+ \(\$[^\)]+\) of type [^ ]+ is deprecated`' );
+ }
+
$matches = array();
$_REQUEST['paged'] = $args['paged'];
@@ -205,12 +215,14 @@ class Tests_Admin_IncludesListTable extends WP_UnitTestCase {
$args['posts_per_archive_page'] = -1;
}
+ // Effectively ignore the output until retrieving it later via `getActualOutput()`.
+ $this->expectOutputRegex( '`.`' );
+
$pages = new WP_Query( $args );
- ob_start();
$this->table->set_hierarchical_display( true );
$this->table->display_rows( $pages->posts );
- $output = ob_get_clean();
+ $output = $this->getActualOutput();
// Clean up.
unset( $_REQUEST['paged'] );
diff --git a/tests/phpunit/tests/admin/includesPost.php b/tests/phpunit/tests/admin/includesPost.php
index 8c5013279e..02c40d9071 100644
--- a/tests/phpunit/tests/admin/includesPost.php
+++ b/tests/phpunit/tests/admin/includesPost.php
@@ -876,6 +876,16 @@ class Tests_Admin_IncludesPost extends WP_UnitTestCase {
* @ticket 37406
*/
public function test_post_exists_should_support_post_type() {
+ if ( PHP_VERSION_ID >= 80100 ) {
+ /*
+ * For the time being, ignoring PHP 8.1 "null to non-nullable" deprecations coming in
+ * via hooked in filter functions until a more structural solution to the
+ * "missing input validation" conundrum has been architected and implemented.
+ */
+ $this->expectDeprecation();
+ $this->expectDeprecationMessageMatches( '`Passing null to parameter \#[0-9]+ \(\$[^\)]+\) of type [^ ]+ is deprecated`' );
+ }
+
$title = 'Foo Bar';
$post_type = 'page';
$post_id = self::factory()->post->create(
@@ -893,6 +903,16 @@ class Tests_Admin_IncludesPost extends WP_UnitTestCase {
* @ticket 37406
*/
public function test_post_exists_should_not_match_a_page_for_post() {
+ if ( PHP_VERSION_ID >= 80100 ) {
+ /*
+ * For the time being, ignoring PHP 8.1 "null to non-nullable" deprecations coming in
+ * via hooked in filter functions until a more structural solution to the
+ * "missing input validation" conundrum has been architected and implemented.
+ */
+ $this->expectDeprecation();
+ $this->expectDeprecationMessageMatches( '`Passing null to parameter \#[0-9]+ \(\$[^\)]+\) of type [^ ]+ is deprecated`' );
+ }
+
$title = 'Foo Bar';
$post_type = 'page';
$post_id = self::factory()->post->create(
@@ -910,6 +930,16 @@ class Tests_Admin_IncludesPost extends WP_UnitTestCase {
* @ticket 34012
*/
public function test_post_exists_should_support_post_status() {
+ if ( PHP_VERSION_ID >= 80100 ) {
+ /*
+ * For the time being, ignoring PHP 8.1 "null to non-nullable" deprecations coming in
+ * via hooked in filter functions until a more structural solution to the
+ * "missing input validation" conundrum has been architected and implemented.
+ */
+ $this->expectDeprecation();
+ $this->expectDeprecationMessageMatches( '`Passing null to parameter \#[0-9]+ \(\$[^\)]+\) of type [^ ]+ is deprecated`' );
+ }
+
$title = 'Foo Bar';
$post_type = 'post';
$post_status = 'publish';
@@ -930,6 +960,16 @@ class Tests_Admin_IncludesPost extends WP_UnitTestCase {
* @ticket 34012
*/
public function test_post_exists_should_support_post_type_status_combined() {
+ if ( PHP_VERSION_ID >= 80100 ) {
+ /*
+ * For the time being, ignoring PHP 8.1 "null to non-nullable" deprecations coming in
+ * via hooked in filter functions until a more structural solution to the
+ * "missing input validation" conundrum has been architected and implemented.
+ */
+ $this->expectDeprecation();
+ $this->expectDeprecationMessageMatches( '`Passing null to parameter \#[0-9]+ \(\$[^\)]+\) of type [^ ]+ is deprecated`' );
+ }
+
$title = 'Foo Bar';
$post_type = 'post';
$post_status = 'publish';
@@ -949,6 +989,16 @@ class Tests_Admin_IncludesPost extends WP_UnitTestCase {
* @ticket 34012
*/
public function test_post_exists_should_only_match_correct_post_status() {
+ if ( PHP_VERSION_ID >= 80100 ) {
+ /*
+ * For the time being, ignoring PHP 8.1 "null to non-nullable" deprecations coming in
+ * via hooked in filter functions until a more structural solution to the
+ * "missing input validation" conundrum has been architected and implemented.
+ */
+ $this->expectDeprecation();
+ $this->expectDeprecationMessageMatches( '`Passing null to parameter \#[0-9]+ \(\$[^\)]+\) of type [^ ]+ is deprecated`' );
+ }
+
$title = 'Foo Bar';
$post_type = 'post';
$post_status = 'draft';
@@ -968,6 +1018,16 @@ class Tests_Admin_IncludesPost extends WP_UnitTestCase {
* @ticket 34012
*/
public function test_post_exists_should_not_match_invalid_post_type_and_status_combined() {
+ if ( PHP_VERSION_ID >= 80100 ) {
+ /*
+ * For the time being, ignoring PHP 8.1 "null to non-nullable" deprecations coming in
+ * via hooked in filter functions until a more structural solution to the
+ * "missing input validation" conundrum has been architected and implemented.
+ */
+ $this->expectDeprecation();
+ $this->expectDeprecationMessageMatches( '`Passing null to parameter \#[0-9]+ \(\$[^\)]+\) of type [^ ]+ is deprecated`' );
+ }
+
$title = 'Foo Bar';
$post_type = 'post';
$post_status = 'publish';
diff --git a/tests/phpunit/tests/comment-submission.php b/tests/phpunit/tests/comment-submission.php
index 3e6c7ab1c2..2cd5d8473a 100644
--- a/tests/phpunit/tests/comment-submission.php
+++ b/tests/phpunit/tests/comment-submission.php
@@ -200,6 +200,15 @@ class Tests_Comment_Submission extends WP_UnitTestCase {
}
public function test_submitting_comment_to_password_protected_post_succeeds() {
+ if ( PHP_VERSION_ID >= 80100 ) {
+ /*
+ * For the time being, ignoring PHP 8.1 "null to non-nullable" deprecations coming in
+ * via hooked in filter functions until a more structural solution to the
+ * "missing input validation" conundrum has been architected and implemented.
+ */
+ $this->expectDeprecation();
+ $this->expectDeprecationMessageMatches( '`Passing null to parameter \#[0-9]+ \(\$[^\)]+\) of type [^ ]+ is deprecated`' );
+ }
$password = 'password';
$hasher = new PasswordHash( 8, true );
@@ -282,6 +291,15 @@ class Tests_Comment_Submission extends WP_UnitTestCase {
* @group slashes
*/
public function test_submitting_comment_handles_slashes_correctly_handles_slashes() {
+ if ( PHP_VERSION_ID >= 80100 ) {
+ /*
+ * For the time being, ignoring PHP 8.1 "null to non-nullable" deprecations coming in
+ * via hooked in filter functions until a more structural solution to the
+ * "missing input validation" conundrum has been architected and implemented.
+ */
+ $this->expectDeprecation();
+ $this->expectDeprecationMessageMatches( '`Passing null to parameter \#[0-9]+ \(\$[^\)]+\) of type [^ ]+ is deprecated`' );
+ }
$data = array(
'comment_post_ID' => self::$post->ID,
@@ -429,6 +447,15 @@ class Tests_Comment_Submission extends WP_UnitTestCase {
}
public function test_anonymous_user_cannot_comment_unfiltered_html() {
+ if ( PHP_VERSION_ID >= 80100 ) {
+ /*
+ * For the time being, ignoring PHP 8.1 "null to non-nullable" deprecations coming in
+ * via hooked in filter functions until a more structural solution to the
+ * "missing input validation" conundrum has been architected and implemented.
+ */
+ $this->expectDeprecation();
+ $this->expectDeprecationMessageMatches( '`Passing null to parameter \#[0-9]+ \(\$[^\)]+\) of type [^ ]+ is deprecated`' );
+ }
$data = array(
'comment_post_ID' => self::$post->ID,
@@ -719,6 +746,16 @@ class Tests_Comment_Submission extends WP_UnitTestCase {
* @ticket 49236
*/
public function test_submitting_comment_with_empty_type_results_in_correct_type() {
+ if ( PHP_VERSION_ID >= 80100 ) {
+ /*
+ * For the time being, ignoring PHP 8.1 "null to non-nullable" deprecations coming in
+ * via hooked in filter functions until a more structural solution to the
+ * "missing input validation" conundrum has been architected and implemented.
+ */
+ $this->expectDeprecation();
+ $this->expectDeprecationMessageMatches( '`Passing null to parameter \#[0-9]+ \(\$[^\)]+\) of type [^ ]+ is deprecated`' );
+ }
+
$data = array(
'comment_post_ID' => self::$post->ID,
'comment' => 'Comment',
@@ -802,6 +839,16 @@ class Tests_Comment_Submission extends WP_UnitTestCase {
* @ticket 36901
*/
public function test_submitting_duplicate_comments() {
+ if ( PHP_VERSION_ID >= 80100 ) {
+ /*
+ * For the time being, ignoring PHP 8.1 "null to non-nullable" deprecations coming in
+ * via hooked in filter functions until a more structural solution to the
+ * "missing input validation" conundrum has been architected and implemented.
+ */
+ $this->expectDeprecation();
+ $this->expectDeprecationMessageMatches( '`Passing null to parameter \#[0-9]+ \(\$[^\)]+\) of type [^ ]+ is deprecated`' );
+ }
+
$data = array(
'comment_post_ID' => self::$post->ID,
'comment' => 'Did I say that?',
@@ -818,6 +865,16 @@ class Tests_Comment_Submission extends WP_UnitTestCase {
* @ticket 36901
*/
public function test_comments_flood() {
+ if ( PHP_VERSION_ID >= 80100 ) {
+ /*
+ * For the time being, ignoring PHP 8.1 "null to non-nullable" deprecations coming in
+ * via hooked in filter functions until a more structural solution to the
+ * "missing input validation" conundrum has been architected and implemented.
+ */
+ $this->expectDeprecation();
+ $this->expectDeprecationMessageMatches( '`Passing null to parameter \#[0-9]+ \(\$[^\)]+\) of type [^ ]+ is deprecated`' );
+ }
+
$data = array(
'comment_post_ID' => self::$post->ID,
'comment' => 'Did I say that?',
diff --git a/tests/phpunit/tests/date/xmlrpc.php b/tests/phpunit/tests/date/xmlrpc.php
index 6fe96618bc..b2275403d8 100644
--- a/tests/phpunit/tests/date/xmlrpc.php
+++ b/tests/phpunit/tests/date/xmlrpc.php
@@ -14,6 +14,16 @@ class Tests_Date_XMLRPC extends WP_XMLRPC_UnitTestCase {
* @covers wp_xmlrpc_server::mw_newPost
*/
public function test_date_new_post() {
+ if ( PHP_VERSION_ID >= 80100 ) {
+ /*
+ * For the time being, ignoring PHP 8.1 "null to non-nullable" deprecations coming in
+ * via hooked in filter functions until a more structural solution to the
+ * "missing input validation" conundrum has been architected and implemented.
+ */
+ $this->expectDeprecation();
+ $this->expectDeprecationMessageMatches( '`Passing null to parameter \#[0-9]+ \(\$[^\)]+\) of type [^ ]+ is deprecated`' );
+ }
+
$timezone = 'Europe/Kiev';
update_option( 'timezone_string', $timezone );
diff --git a/tests/phpunit/tests/dependencies/scripts.php b/tests/phpunit/tests/dependencies/scripts.php
index 2863a5ec9b..90394fab30 100644
--- a/tests/phpunit/tests/dependencies/scripts.php
+++ b/tests/phpunit/tests/dependencies/scripts.php
@@ -721,6 +721,16 @@ JS;
$wp_scripts->base_url = '';
$wp_scripts->do_concat = true;
+ if ( PHP_VERSION_ID >= 80100 ) {
+ /*
+ * For the time being, ignoring PHP 8.1 "null to non-nullable" deprecations coming in
+ * via hooked in filter functions until a more structural solution to the
+ * "missing input validation" conundrum has been architected and implemented.
+ */
+ $this->expectDeprecation();
+ $this->expectDeprecationMessageMatches( '`Passing null to parameter \#[0-9]+ \(\$[^\)]+\) of type [^ ]+ is deprecated`' );
+ }
+
$ver = get_bloginfo( 'version' );
$suffix = wp_scripts_get_suffix();
$expected = "\n";
@@ -746,8 +756,12 @@ JS;
wp_enqueue_script( 'test-example2', 'http://example2.com', array( 'wp-a11y' ), null );
wp_add_inline_script( 'test-example2', 'console.log("after");', 'after' );
- $print_scripts = get_echo( 'wp_print_scripts' );
- $print_scripts .= get_echo( '_print_scripts' );
+ // Effectively ignore the output until retrieving it later via `getActualOutput()`.
+ $this->expectOutputRegex( '`.`' );
+
+ wp_print_scripts();
+ _print_scripts();
+ $print_scripts = $this->getActualOutput();
/*
* We've replaced wp-a11y.js with @wordpress/a11y package (see #45066),
@@ -776,6 +790,16 @@ JS;
$wp_scripts->base_url = '';
$wp_scripts->do_concat = true;
+ if ( PHP_VERSION_ID >= 80100 ) {
+ /*
+ * For the time being, ignoring PHP 8.1 "null to non-nullable" deprecations coming in
+ * via hooked in filter functions until a more structural solution to the
+ * "missing input validation" conundrum has been architected and implemented.
+ */
+ $this->expectDeprecation();
+ $this->expectDeprecationMessageMatches( '`Passing null to parameter \#[0-9]+ \(\$[^\)]+\) of type [^ ]+ is deprecated`' );
+ }
+
$expected_tail = "\n";
$expected_tail .= "