| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * Test widget template tags |
| 5 | * |
| 6 | * @group widgets |
| 7 | */ |
| 8 | class Tests_Widgets extends WP_UnitTestCase { |
| 9 | |
| 10 | function test_register_widget_corewidget() { |
| 11 | |
| 12 | global $wp_widget_factory; |
| 13 | |
| 14 | unregister_widget( 'WP_Widget_Search' ); |
| 15 | register_widget( 'WP_Widget_Search' ); |
| 16 | |
| 17 | $this->assertTrue( isset( $wp_widget_factory->widgets['WP_Widget_Search'] ) ); |
| 18 | |
| 19 | } |
| 20 | |
| 21 | function test_unregister_widget_corewidget() { |
| 22 | |
| 23 | global $wp_widget_factory; |
| 24 | |
| 25 | unregister_widget( 'WP_Widget_Search' ); |
| 26 | |
| 27 | $this->assertFalse( isset( $wp_widget_factory->widgets['WP_Widget_Search'] ) ); |
| 28 | |
| 29 | } |
| 30 | |
| 31 | function test_register_sidebars_single() { |
| 32 | |
| 33 | global $wp_registered_sidebars; |
| 34 | |
| 35 | register_sidebars( 1, array( 'id' => 'wp-unit-test' ) ); |
| 36 | |
| 37 | $this->assertTrue( isset( $wp_registered_sidebars['wp-unit-test'] ) ); |
| 38 | |
| 39 | } |
| 40 | |
| 41 | function test_register_sidebars_multiple() { |
| 42 | |
| 43 | global $wp_registered_sidebars; |
| 44 | |
| 45 | $num = 3; |
| 46 | $id_base = 'WP Unit Test'; |
| 47 | register_sidebars( $num, array( 'name' => $id_base . ' %d' ) ); |
| 48 | |
| 49 | $names = wp_list_pluck( $wp_registered_sidebars, 'name' ); |
| 50 | for ( $i = 1; $i <= $num; $i++ ) { |
| 51 | if ( in_array( "$id_base $i", $names ) ) |
| 52 | $result[] = true; |
| 53 | } |
| 54 | |
| 55 | $this->assertEquals( $num, count( $result ) ); |
| 56 | |
| 57 | } |
| 58 | |
| 59 | function test_register_sidebar() { |
| 60 | |
| 61 | global $wp_registered_sidebars; |
| 62 | |
| 63 | register_sidebar( array( 'id' => 'wp-unit-test' ) ); |
| 64 | |
| 65 | $this->assertTrue( isset( $wp_registered_sidebars['wp-unit-test'] ) ); |
| 66 | |
| 67 | } |
| 68 | |
| 69 | function test_unregister_sidebar() { |
| 70 | |
| 71 | global $wp_registered_sidebars; |
| 72 | |
| 73 | unregister_sidebar( 'sidebar-1' ); |
| 74 | |
| 75 | $this->assertFalse( isset( $wp_registered_sidebars['sidebar-1'] ) ); |
| 76 | |
| 77 | } |
| 78 | |
| 79 | /* |
| 80 | function test_wp_register_sidebar_widget() { |
| 81 | |
| 82 | global $wp_registered_widgets; |
| 83 | |
| 84 | |
| 85 | |
| 86 | } |
| 87 | */ |
| 88 | } |
| 89 | No newline at end of file |