mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-28 14:20:15 +00:00
Administration: Add new get_views_links method to WP_List_Table.
Many `WP_List_Table` child classes in core use mostly the same code to create their "view" links markup. To DRY-up the code, a new `WP_List_Table->get_view_links` method is being introduced to consolidate the HTML link generation when provided an array of links. This change also implements this new method in the relevant `WP_List_Table_xxx` child classes `get_views` methods. Finally, unit tests are being added to validate view links markup and test for some "unhappy paths". Props afercia, costdev, garrett-eclipse, Dharm1025, juhise, peterwilsoncc. Fixes #42066. git-svn-id: https://develop.svn.wordpress.org/trunk@54215 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -319,4 +319,26 @@ class Tests_Admin_wpPostsListTable extends WP_UnitTestCase {
|
||||
$this->assertStringNotContainsString( 'id="delete_all"', $output );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 42066
|
||||
*
|
||||
* @covers WP_Posts_List_Table::get_views
|
||||
*/
|
||||
public function test_get_views_should_return_views_by_default() {
|
||||
global $avail_post_stati;
|
||||
|
||||
$avail_post_stati_backup = $avail_post_stati;
|
||||
$avail_post_stati = get_available_post_statuses();
|
||||
|
||||
$actual = $this->table->get_views();
|
||||
$avail_post_stati = $avail_post_stati_backup;
|
||||
|
||||
$expected = array(
|
||||
'all' => '<a href="edit.php?post_type=page">All <span class="count">(38)</span></a>',
|
||||
'publish' => '<a href="edit.php?post_status=publish&post_type=page">Published <span class="count">(38)</span></a>',
|
||||
);
|
||||
|
||||
$this->assertSame( $expected, $actual );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user