mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-04-08 22:54:36 +00:00
Implement a priority system for Help Tabs to add them at specific positions.
Adds unit tests. Props swissspidy. Fixes #19828. git-svn-id: https://develop.svn.wordpress.org/trunk@33985 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -163,7 +163,13 @@ class Tests_Admin_includesScreen extends WP_UnitTestCase {
|
||||
|
||||
$screen = get_current_screen();
|
||||
$screen->add_help_tab( $tab_args );
|
||||
$this->assertEquals( $screen->get_help_tab( $tab ), $tab_args );
|
||||
$this->assertEquals( $screen->get_help_tab( $tab ), array(
|
||||
'id' => $tab,
|
||||
'title' => 'Help!',
|
||||
'content' => 'Some content',
|
||||
'callback' => false,
|
||||
'priority' => 10,
|
||||
) );
|
||||
|
||||
$tabs = $screen->get_help_tabs();
|
||||
$this->assertArrayHasKey( $tab, $tabs );
|
||||
@@ -175,6 +181,62 @@ class Tests_Admin_includesScreen extends WP_UnitTestCase {
|
||||
$this->assertEquals( $screen->get_help_tabs(), array() );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 19828
|
||||
*/
|
||||
function test_help_tabs_priority() {
|
||||
$tab_1 = rand_str();
|
||||
$tab_1_args = array(
|
||||
'id' => $tab_1,
|
||||
'title' => 'Help!',
|
||||
'content' => 'Some content',
|
||||
'callback' => false,
|
||||
'priority' => 11,
|
||||
);
|
||||
|
||||
$tab_2 = rand_str();
|
||||
$tab_2_args = array(
|
||||
'id' => $tab_2,
|
||||
'title' => 'Help!',
|
||||
'content' => 'Some content',
|
||||
'callback' => false,
|
||||
'priority' => 9,
|
||||
);
|
||||
|
||||
$screen = get_current_screen();
|
||||
|
||||
// Add help tabs.
|
||||
|
||||
$screen->add_help_tab( $tab_1_args );
|
||||
$this->assertEquals( $screen->get_help_tab( $tab_1 ), $tab_1_args );
|
||||
|
||||
$screen->add_help_tab( $tab_2_args );
|
||||
$this->assertEquals( $screen->get_help_tab( $tab_2 ), $tab_2_args );
|
||||
|
||||
$tabs = $screen->get_help_tabs();
|
||||
$this->assertEquals( 2, count( $tabs ) );
|
||||
$this->assertArrayHasKey( $tab_1, $tabs );
|
||||
$this->assertArrayHasKey( $tab_2, $tabs );
|
||||
|
||||
// Test priority order.
|
||||
|
||||
$this->assertEquals( $tabs, array(
|
||||
$tab_2 => $tab_2_args,
|
||||
$tab_1 => $tab_1_args,
|
||||
) );
|
||||
|
||||
$screen->remove_help_tab( $tab_1 );
|
||||
$this->assertNull( $screen->get_help_tab( $tab_1 ) );
|
||||
$this->assertEquals( 1, count( $screen->get_help_tabs() ) );
|
||||
|
||||
$screen->remove_help_tab( $tab_2 );
|
||||
$this->assertNull( $screen->get_help_tab( $tab_2 ) );
|
||||
$this->assertEquals( 0, count( $screen->get_help_tabs() ) );
|
||||
|
||||
$screen->remove_help_tabs();
|
||||
$this->assertEquals( $screen->get_help_tabs(), array() );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 25799
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user