File tree Expand file tree Collapse file tree 2 files changed +18
-1
lines changed
tests/phpunit/tests/admin Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -658,7 +658,7 @@ public function current_action() {
658658 * @return string The HTML for the row actions.
659659 */
660660 protected function row_actions ( $ actions , $ always_visible = false ) {
661- $ action_count = count ( $ actions );
661+ $ action_count = is_countable ( $ actions ) ? count ( $ actions ) : 0 ;
662662
663663 if ( ! $ action_count ) {
664664 return '' ;
Original file line number Diff line number Diff line change @@ -584,4 +584,21 @@ public function test_search_box_works_with_orderby_string() {
584584
585585 $ this ->assertStringContainsString ( $ expected_html , $ actual );
586586 }
587+
588+ /**
589+ * Tests that `WP_List_Table::row_actions()` is returning an empty string
590+ * and not throwing a TypeError when a non-countable `$actions` param is passed.
591+ *
592+ * @ticket 58789
593+ *
594+ * @covers WP_List_Table::row_actions()
595+ */
596+ public function test_row_actions_should_return_empty_string_when_non_countable_actions_is_passed () {
597+ $ row_actions = new ReflectionMethod ( $ this ->list_table , 'row_actions ' );
598+ $ row_actions ->setAccessible ( true );
599+
600+ $ actual = $ row_actions ->invokeArgs ( $ this ->list_table , array ( '' ) );
601+
602+ $ this ->assertSame ( '' , $ actual );
603+ }
587604}
You can’t perform that action at this time.
0 commit comments