@@ -76,13 +76,21 @@ public static function set_up_before_class() {
7676 self ::$ is_trash = new ReflectionProperty ( self ::$ list_table , 'is_trash ' );
7777 self ::$ detached = new ReflectionProperty ( self ::$ list_table , 'detached ' );
7878
79- self ::$ is_trash ->setAccessible ( true );
79+ if ( PHP_VERSION_ID < 80100 ) {
80+ self ::$ is_trash ->setAccessible ( true );
81+ }
8082 self ::$ is_trash_original = self ::$ is_trash ->getValue ( self ::$ list_table );
81- self ::$ is_trash ->setAccessible ( false );
83+ if ( PHP_VERSION_ID < 80100 ) {
84+ self ::$ is_trash ->setAccessible ( false );
85+ }
8286
83- self ::$ detached ->setAccessible ( true );
87+ if ( PHP_VERSION_ID < 80100 ) {
88+ self ::$ detached ->setAccessible ( true );
89+ }
8490 self ::$ detached_original = self ::$ detached ->getValue ( self ::$ list_table );
85- self ::$ detached ->setAccessible ( false );
91+ if ( PHP_VERSION_ID < 80100 ) {
92+ self ::$ detached ->setAccessible ( false );
93+ }
8694
8795 // Create users.
8896 self ::$ admin = self ::factory ()->user ->create ( array ( 'role ' => 'administrator ' ) );
@@ -181,9 +189,13 @@ public function test_get_row_actions_should_include_action( $action, $role, $tra
181189 }
182190
183191 $ _get_row_actions = new ReflectionMethod ( self ::$ list_table , '_get_row_actions ' );
184- $ _get_row_actions ->setAccessible ( true );
192+ if ( PHP_VERSION_ID < 80100 ) {
193+ $ _get_row_actions ->setAccessible ( true );
194+ }
185195 $ actions = $ _get_row_actions ->invoke ( self ::$ list_table , self ::$ post , 'att_title ' );
186- $ _get_row_actions ->setAccessible ( false );
196+ if ( PHP_VERSION_ID < 80100 ) {
197+ $ _get_row_actions ->setAccessible ( false );
198+ }
187199
188200 $ this ->assertIsArray ( $ actions , 'An array was not returned. ' );
189201 $ this ->assertArrayHasKey ( $ action , $ actions , "' $ action' was not included in the actions. " );
@@ -262,9 +274,13 @@ public function test_get_row_actions_should_not_include_action( $action, $role,
262274 }
263275
264276 $ _get_row_actions = new ReflectionMethod ( self ::$ list_table , '_get_row_actions ' );
265- $ _get_row_actions ->setAccessible ( true );
277+ if ( PHP_VERSION_ID < 80100 ) {
278+ $ _get_row_actions ->setAccessible ( true );
279+ }
266280 $ actions = $ _get_row_actions ->invoke ( self ::$ list_table , self ::$ post , 'att_title ' );
267- $ _get_row_actions ->setAccessible ( false );
281+ if ( PHP_VERSION_ID < 80100 ) {
282+ $ _get_row_actions ->setAccessible ( false );
283+ }
268284
269285 $ this ->assertIsArray ( $ actions , 'An array was not returned. ' );
270286 $ this ->assertArrayNotHasKey ( $ action , $ actions , "' $ action' was included in the actions. " );
@@ -355,9 +371,13 @@ public function test_get_row_actions_should_not_include_view_without_a_permalink
355371 add_filter ( 'post_link ' , '__return_false ' , 10 , 0 );
356372
357373 $ _get_row_actions = new ReflectionMethod ( self ::$ list_table , '_get_row_actions ' );
358- $ _get_row_actions ->setAccessible ( true );
374+ if ( PHP_VERSION_ID < 80100 ) {
375+ $ _get_row_actions ->setAccessible ( true );
376+ }
359377 $ actions = $ _get_row_actions ->invoke ( self ::$ list_table , self ::$ post , 'att_title ' );
360- $ _get_row_actions ->setAccessible ( false );
378+ if ( PHP_VERSION_ID < 80100 ) {
379+ $ _get_row_actions ->setAccessible ( false );
380+ }
361381
362382 $ this ->assertIsArray ( $ actions , 'An array was not returned. ' );
363383 $ this ->assertArrayNotHasKey ( 'view ' , $ actions , '"view" was included in the actions. ' );
@@ -374,9 +394,13 @@ public function test_get_row_actions_should_include_copy() {
374394 self ::set_is_trash ( false );
375395
376396 $ _get_row_actions = new ReflectionMethod ( self ::$ list_table , '_get_row_actions ' );
377- $ _get_row_actions ->setAccessible ( true );
397+ if ( PHP_VERSION_ID < 80100 ) {
398+ $ _get_row_actions ->setAccessible ( true );
399+ }
378400 $ actions = $ _get_row_actions ->invoke ( self ::$ list_table , self ::$ attachment , 'att_title ' );
379- $ _get_row_actions ->setAccessible ( false );
401+ if ( PHP_VERSION_ID < 80100 ) {
402+ $ _get_row_actions ->setAccessible ( false );
403+ }
380404
381405 $ this ->assertIsArray ( $ actions , 'An array was not returned. ' );
382406 $ this ->assertArrayHasKey ( 'copy ' , $ actions , '"copy" was not included in the actions. ' );
@@ -397,9 +421,13 @@ public function test_get_row_actions_should_not_include_copy_without_an_attachme
397421 add_filter ( 'wp_get_attachment_url ' , '__return_false ' , 10 , 0 );
398422
399423 $ _get_row_actions = new ReflectionMethod ( self ::$ list_table , '_get_row_actions ' );
400- $ _get_row_actions ->setAccessible ( true );
424+ if ( PHP_VERSION_ID < 80100 ) {
425+ $ _get_row_actions ->setAccessible ( true );
426+ }
401427 $ actions = $ _get_row_actions ->invoke ( self ::$ list_table , self ::$ attachment , 'att_title ' );
402- $ _get_row_actions ->setAccessible ( false );
428+ if ( PHP_VERSION_ID < 80100 ) {
429+ $ _get_row_actions ->setAccessible ( false );
430+ }
403431
404432 $ this ->assertIsArray ( $ actions , 'An array was not returned. ' );
405433 $ this ->assertArrayNotHasKey ( 'copy ' , $ actions , '"copy" was included in the actions. ' );
@@ -414,9 +442,13 @@ public function test_get_row_actions_should_not_include_copy_without_an_attachme
414442 */
415443 public function test_get_row_actions_should_include_download () {
416444 $ _get_row_actions = new ReflectionMethod ( self ::$ list_table , '_get_row_actions ' );
417- $ _get_row_actions ->setAccessible ( true );
445+ if ( PHP_VERSION_ID < 80100 ) {
446+ $ _get_row_actions ->setAccessible ( true );
447+ }
418448 $ actions = $ _get_row_actions ->invoke ( self ::$ list_table , self ::$ attachment , 'att_title ' );
419- $ _get_row_actions ->setAccessible ( false );
449+ if ( PHP_VERSION_ID < 80100 ) {
450+ $ _get_row_actions ->setAccessible ( false );
451+ }
420452
421453 $ this ->assertIsArray ( $ actions , 'An array was not returned. ' );
422454 $ this ->assertArrayHasKey ( 'download ' , $ actions , '"download" was not included in the actions. ' );
@@ -435,9 +467,13 @@ public function test_get_row_actions_should_not_include_download_without_an_atta
435467 add_filter ( 'wp_get_attachment_url ' , '__return_false ' , 10 , 0 );
436468
437469 $ _get_row_actions = new ReflectionMethod ( self ::$ list_table , '_get_row_actions ' );
438- $ _get_row_actions ->setAccessible ( true );
470+ if ( PHP_VERSION_ID < 80100 ) {
471+ $ _get_row_actions ->setAccessible ( true );
472+ }
439473 $ actions = $ _get_row_actions ->invoke ( self ::$ list_table , self ::$ attachment , 'att_title ' );
440- $ _get_row_actions ->setAccessible ( false );
474+ if ( PHP_VERSION_ID < 80100 ) {
475+ $ _get_row_actions ->setAccessible ( false );
476+ }
441477
442478 $ this ->assertIsArray ( $ actions , 'An array was not returned. ' );
443479 $ this ->assertArrayNotHasKey ( 'download ' , $ actions , '"download" was included in the actions. ' );
@@ -451,9 +487,13 @@ public function test_get_row_actions_should_not_include_download_without_an_atta
451487 * @param bool $is_trash Whether the attachment filter is currently 'trash'.
452488 */
453489 private static function set_is_trash ( $ is_trash ) {
454- self ::$ is_trash ->setAccessible ( true );
490+ if ( PHP_VERSION_ID < 80100 ) {
491+ self ::$ is_trash ->setAccessible ( true );
492+ }
455493 self ::$ is_trash ->setValue ( self ::$ list_table , $ is_trash );
456- self ::$ is_trash ->setAccessible ( false );
494+ if ( PHP_VERSION_ID < 80100 ) {
495+ self ::$ is_trash ->setAccessible ( false );
496+ }
457497 }
458498
459499 /**
@@ -464,8 +504,12 @@ private static function set_is_trash( $is_trash ) {
464504 * @param bool $detached Whether the attachment filter is currently 'detached'.
465505 */
466506 private static function set_detached ( $ detached ) {
467- self ::$ detached ->setAccessible ( true );
507+ if ( PHP_VERSION_ID < 80100 ) {
508+ self ::$ detached ->setAccessible ( true );
509+ }
468510 self ::$ detached ->setValue ( self ::$ list_table , $ detached );
469- self ::$ detached ->setAccessible ( false );
511+ if ( PHP_VERSION_ID < 80100 ) {
512+ self ::$ detached ->setAccessible ( false );
513+ }
470514 }
471515}
0 commit comments