Make WordPress Core

Ticket #44813: 44813.tests.diff

File 44813.tests.diff, 1.4 KB (added by soulseekah, 6 years ago)
  • tests/phpunit/tests/admin/includesListTable.php

    diff --git tests/phpunit/tests/admin/includesListTable.php tests/phpunit/tests/admin/includesListTable.php
    index ff18d4a724..127aa32aa4 100644
    class Tests_Admin_includesListTable extends WP_UnitTestCase { 
    293293
    294294                $this->assertNotContains( 'id="delete_all"', $output );
    295295        }
     296
     297        /**
     298         * @ticket 44813
     299         */
     300        public function test_filter_admin_get_list_table() {
     301                add_filter( 'admin_get_list_table_instance', array( $this, 'filter_admin_get_list_table_callback' ) );
     302                $table = _get_list_table( 'WP_Comments_List_Table', array( 'screen' => 'edit-comments' ) );
     303
     304                $this->assertContains( 'Mock_WP_Comments_List_Table', get_class( $table ) );
     305
     306                remove_filter( 'admin_get_list_table_instance', array( $this, 'filter_admin_get_list_table_callback' ) );
     307
     308                add_filter( 'admin_get_list_table_instance', array( $this, 'filter_admin_get_list_table_callback_invalid' ) );
     309
     310                $this->assertFalse( _get_list_table( 'WP_Comments_List_Table' ) );
     311
     312                remove_filter( 'admin_get_list_table_instance', array( $this, 'filter_admin_get_list_table_callback_invalid' ) );
     313        }
     314
     315        public function filter_admin_get_list_table_callback() {
     316                return $this->createMock( 'WP_Comments_List_Table' );
     317        }
     318
     319        public function filter_admin_get_list_table_callback_invalid() {
     320                return 'invalid_class';
     321        }
    296322}