forked from WordPress/wordpress-develop
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwidgets.php
More file actions
78 lines (46 loc) · 1.56 KB
/
widgets.php
File metadata and controls
78 lines (46 loc) · 1.56 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<?php
/**
* Test widget template tags
*
* @group widgets
*/
class Tests_Widgets extends WP_UnitTestCase {
function test_register_widget_core_widget() {
global $wp_widget_factory;
unregister_widget( 'WP_Widget_Search' );
register_widget( 'WP_Widget_Search' );
$this->assertTrue( isset( $wp_widget_factory->widgets['WP_Widget_Search'] ) );
}
function test_unregister_widget_core_widget() {
global $wp_widget_factory;
unregister_widget( 'WP_Widget_Search' );
$this->assertFalse( isset( $wp_widget_factory->widgets['WP_Widget_Search'] ) );
}
function test_register_sidebars_single() {
global $wp_registered_sidebars;
register_sidebars( 1, array( 'id' => 'wp-unit-test' ) );
$this->assertTrue( isset( $wp_registered_sidebars['wp-unit-test'] ) );
}
function test_register_sidebars_multiple() {
global $wp_registered_sidebars;
$num = 3;
$id_base = 'WP Unit Test';
register_sidebars( $num, array( 'name' => $id_base . ' %d' ) );
$names = wp_list_pluck( $wp_registered_sidebars, 'name' );
for ( $i = 1; $i <= $num; $i++ ) {
if ( in_array( "$id_base $i", $names ) )
$result[] = true;
}
$this->assertEquals( $num, count( $result ) );
}
function test_register_sidebar() {
global $wp_registered_sidebars;
register_sidebar( array( 'id' => 'wp-unit-test' ) );
$this->assertTrue( isset( $wp_registered_sidebars['wp-unit-test'] ) );
}
function test_unregister_sidebar() {
global $wp_registered_sidebars;
unregister_sidebar( 'sidebar-1' );
$this->assertFalse( isset( $wp_registered_sidebars['sidebar-1'] ) );
}
}