You appear to be a bot. Output may be restricted
Description
Helper function to test the output of a page which uses `WP_Posts_List_Table`.
Usage
Tests_Admin_includesListTable::_test_list_hierarchical_page( $args, $expected_ids );
Parameters
- $args
- ( array ) required – Query args for the list of pages.
- $expected_ids
- ( array ) required – Expected IDs of pages returned.
Returns
void
Source
File name: wordpress-develop-tests/phpunit/tests/admin/includesListTable.php
Lines:
1 to 41 of 41
protected function _test_list_hierarchical_page( array $args, array $expected_ids ) { $matches = array(); $_REQUEST['paged'] = $args['paged']; $GLOBALS['per_page'] = $args['posts_per_page']; $args = array_merge( array( 'post_type' => 'page', ), $args ); // Mimic the behaviour of `wp_edit_posts_query()`: if ( ! isset( $args['orderby'] ) ) { $args['orderby'] = 'menu_order title'; $args['order'] = 'asc'; $args['posts_per_page'] = -1; $args['posts_per_archive_page'] = -1; } $pages = new WP_Query( $args ); ob_start(); $this->table->set_hierarchical_display( true ); $this->table->display_rows( $pages->posts ); $output = ob_get_clean(); // Clean up. unset( $_REQUEST['paged'] ); unset( $GLOBALS['per_page'] ); preg_match_all( '|<tr[^>]*>|', $output, $matches ); $this->assertCount( count( $expected_ids ), array_keys( $matches[0] ) ); foreach ( $expected_ids as $id ) { $this->assertContains( sprintf( 'id="post-%d"', $id ), $output ); } }