forked from WordPress/wordpress-develop
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadminbar.php
More file actions
64 lines (51 loc) · 1.52 KB
/
adminbar.php
File metadata and controls
64 lines (51 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?php
/**
* @group admin-bar
* @group toolbar
* @group admin
*/
class Tests_AdminBar extends WP_UnitTestCase {
static function setUpBeforeClass() {
WP_UnitTestCase::setUpBeforeClass();
require_once ABSPATH . WPINC . '/class-wp-admin-bar.php';
}
function setUp() {
parent::setUp();
$this->current_user = get_current_user_id();
wp_set_current_user( $this->factory->user->create( array( 'role' => 'editor' ) ) );
}
function tearDown() {
wp_set_current_user( $this->current_user );
parent::tearDown();
}
/**
* @ticket 21117
*/
function test_content_post_type() {
register_post_type( 'content', array( 'show_in_admin_bar' => true ) );
$admin_bar = new WP_Admin_Bar;
wp_admin_bar_new_content_menu( $admin_bar );
$nodes = $admin_bar->get_nodes();
$this->assertFalse( $nodes['new-content']->parent );
$this->assertEquals( 'new-content', $nodes['add-new-content']->parent );
_unregister_post_type( 'content' );
}
/**
* @ticket 21117
*/
function test_merging_existing_meta_values() {
$admin_bar = new WP_Admin_Bar;
$admin_bar->add_node( array(
'id' => 'test-node',
'meta' => array( 'class' => 'test-class' ),
) );
$node = $admin_bar->get_node( 'test-node' );
$this->assertEquals( array( 'class' => 'test-class' ), $node->meta );
$admin_bar->add_node( array(
'id' => 'test-node',
'meta' => array( 'some-meta' => 'value' ),
) );
$node = $admin_bar->get_node( 'test-node' );
$this->assertEquals( array( 'class' => 'test-class', 'some-meta' => 'value' ), $node->meta );
}
}