Changeset 10769 for sites/trunk/wordpress.org/public_html/wp-content/plugins/handbook/phpunit/tests/init.php
- Timestamp:
- 03/05/2021 12:21:47 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/handbook/phpunit/tests/init.php
r10768 r10769 15 15 16 16 WPorg_Handbook_Init::reset( true ); 17 } 18 19 20 // 21 // 22 // DATA PROVIDERS 23 // 24 // 25 26 27 public static function get_default_config() { 28 return [ 29 [ 'label', '' ], 30 [ 'manifest', '' ], 31 [ 'slug', '' ], 32 [ 'with_front', '' ], 33 ]; 17 34 } 18 35 … … 143 160 } 144 161 162 /* 163 * get_handbooks_config() 164 */ 165 166 /** 167 * @dataProvider get_default_config 168 */ 169 public function test_get_handbooks_config_default( $key, $default ) { 170 $configs = WPorg_Handbook_Init::get_handbooks_config(); 171 $this->assertArrayHasKey( 'handbook', $configs ); 172 $this->assertEquals( 1, count( $configs ) ); 173 174 $config = $configs['handbook']; 175 176 $this->assertArrayHasKey( $key, $config ); 177 $value = $config[ $key ]; 178 179 if ( 'slug' === $key ) { 180 $this->assertEquals( 'handbook', $value ); 181 } elseif ( '' === $default ) { 182 $this->assertEmpty( $value ); 183 } else { 184 $this->assertEquals( $default, $value ); 185 } 186 } 187 188 public function test_get_handbooks_config_non_handbook() { 189 $this->assertEmpty( WPorg_Handbook_Init::get_handbooks_config( 'nonexistent-handbook' ) ); 190 } 191 192 /** 193 * @dataProvider get_default_config 194 */ 195 public function test_get_handbooks_config_specific_handbook_default( $key, $default ) { 196 $config = WPorg_Handbook_Init::get_handbooks_config( 'handbook' ); 197 198 $this->assertArrayHasKey( $key, $config ); 199 $value = $config[ $key ]; 200 201 if ( 'slug' === $key ) { 202 $this->assertEquals( 'handbook', $value ); 203 } elseif ( '' === $default ) { 204 $this->assertEmpty( $value ); 205 } else { 206 $this->assertEquals( $default, $value ); 207 } 208 } 209 210 /** 211 * @dataProvider get_default_config 212 */ 213 public function test_get_handbooks_config_specific_custom_handbook( $key, $default ) { 214 reinit_handbooks( [ 'plugins' => [] ] ); 215 216 $config = WPorg_Handbook_Init::get_handbooks_config( 'plugins-handbook' ); 217 218 $this->assertArrayHasKey( $key, $config ); 219 $value = $config[ $key ]; 220 221 if ( 'slug' === $key ) { 222 $this->assertEquals( 'plugins', $value ); 223 } elseif ( '' === $default ) { 224 $this->assertEmpty( $value ); 225 } else { 226 $this->assertEquals( $default, $value ); 227 } 228 } 229 145 230 }
Note: See TracChangeset
for help on using the changeset viewer.