Changeset 34816
- Timestamp:
- 10/04/2015 04:43:46 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/widgets.php
r34780 r34816 91 91 unregister_sidebar( $sidebar_id ); 92 92 $this->assertArrayNotHasKey( 'wp-unit-test', $wp_registered_sidebars ); 93 } 94 95 /** 96 * Utility hook callback used to store a sidebar ID mid-function. 97 */ 98 function retrieve_sidebar_id( $index ) { 99 $this->sidebar_index = $index; 100 } 101 102 /** 103 * @group sidebar 104 */ 105 function test_dynamic_sidebar_using_sidebar_registered_with_no_id() { 106 global $wp_registered_sidebars; 107 108 $this->setExpectedIncorrectUsage( 'register_sidebar' ); 109 110 // Register a couple of sidebars for fun. 111 register_sidebar(); 112 register_sidebar(); 113 114 $derived_sidebar_id = "sidebar-3"; // Number of sidebars in the global + 1. 115 116 add_action( 'dynamic_sidebar_before', array( $this, 'retrieve_sidebar_id' ) ); 117 118 dynamic_sidebar( 3 ); 119 120 $this->assertSame( $derived_sidebar_id, $this->sidebar_index ); 121 } 122 123 /** 124 * @group sidebar 125 */ 126 function test_dynamic_sidebar_numeric_id() { 127 $sidebar_id = 2; 128 register_sidebar( array( 'id' => $sidebar_id ) ); 129 130 add_action( 'dynamic_sidebar_before', array( $this, 'retrieve_sidebar_id' ) ); 131 132 dynamic_sidebar( $sidebar_id ); 133 134 $this->assertSame( "sidebar-{$sidebar_id}", $this->sidebar_index ); 135 } 136 137 /** 138 * @group sidebar 139 */ 140 function test_dynamic_sidebar_string_id() { 141 $sidebar_id = 'wp-unit-tests'; 142 register_sidebar( array( 'id' => $sidebar_id ) ); 143 144 add_action( 'dynamic_sidebar_before', array( $this, 'retrieve_sidebar_id' ) ); 145 146 dynamic_sidebar( $sidebar_id ); 147 148 $this->assertSame( $sidebar_id, $this->sidebar_index ); 93 149 } 94 150
Note: See TracChangeset
for help on using the changeset viewer.