Skip to content

Commit 825228c

Browse files
committed
Tests: Avoid ReflectionMethod::setAccessible() on PHP 8.1+ in post list table tests.
setAccessible() is redundant on PHP 8.1+ and deprecated in PHP 8.5+, which causes PHPUnit deprecation errors when run with convertDeprecationsToExceptions enabled. Guard the call with PHP_VERSION_ID < 80100 to match core conventions. Fixes #66244.
1 parent 1dd9337 commit 825228c

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

‎tests/phpunit/tests/admin/wpPostsListTable.php‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -634,7 +634,9 @@ public function test_post_title_formatting_tags_are_rendered_in_list_table() {
634634

635635
$table = _get_list_table( 'WP_Posts_List_Table', array( 'screen' => 'edit-post' ) );
636636
$method = new ReflectionMethod( $table, 'get_primary_column_aria_label' );
637-
$method->setAccessible( true );
637+
if ( PHP_VERSION_ID < 80100 ) {
638+
$method->setAccessible( true );
639+
}
638640

639641
$this->assertSame( 'The page title', $method->invoke( $table, $post ) );
640642
}

0 commit comments

Comments
 (0)