Changeset 52279 for trunk/tests/phpunit/tests/theme/wpTheme.php
- Timestamp:
- 11/30/2021 02:25:34 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/theme/wpTheme.php
r51568 r52279 247 247 $this->assertSameSetsWithIndex( $allowed_themes, $new_allowed_themes ); 248 248 } 249 250 /** 251 * @dataProvider data_is_block_based 252 * @ticket 54460 253 * 254 * @covers WP_Theme::is_block_based 255 * 256 * @param string $theme_dir Directory of the theme to test. 257 * @param bool $expected Expected result. 258 */ 259 public function test_is_block_based( $theme_dir, $expected ) { 260 $theme = new WP_Theme( $theme_dir, $this->theme_root ); 261 $actual = $theme->is_block_based(); 262 263 if ( $expected ) { 264 $this->assertTrue( $actual ); 265 } else { 266 $this->assertFalse( $actual ); 267 } 268 } 269 270 /** 271 * Data provider. 272 * 273 * @return array 274 */ 275 public function data_is_block_based() { 276 return array( 277 'default - non-block theme' => array( 278 'theme_dir' => 'default', 279 'expected' => false, 280 ), 281 'parent block theme' => array( 282 'theme_dir' => 'test-block-theme', 283 'expected' => true, 284 ), 285 'child block theme' => array( 286 'theme_dir' => 'test-block-child-theme', 287 'expected' => true, 288 ), 289 ); 290 } 291 292 /** 293 * @dataProvider data_get_file_path 294 * @ticket 54460 295 * 296 * @covers WP_Theme::get_file_path 297 * 298 * @param string $theme_dir Directory of the theme to test. 299 * @param string $file Given file name to test. 300 * @param string $expected Expected file path. 301 */ 302 public function test_get_file_path( $theme_dir, $file, $expected ) { 303 $theme = new WP_Theme( $theme_dir, $this->theme_root ); 304 305 $this->assertStringEndsWith( $expected, $theme->get_file_path( $file ) ); 306 } 307 308 /** 309 * Data provider. 310 * 311 * @return array 312 */ 313 public function data_get_file_path() { 314 return array( 315 'no theme: no file given' => array( 316 'theme_dir' => 'nonexistent', 317 'file' => '', 318 'expected' => '/nonexistent', 319 ), 320 'parent theme: no file given' => array( 321 'theme_dir' => 'test-block-theme', 322 'file' => '', 323 'expected' => '/test-block-theme', 324 ), 325 'child theme: no file given' => array( 326 'theme_dir' => 'test-block-child-theme', 327 'file' => '', 328 'expected' => '/test-block-child-theme', 329 ), 330 'nonexistent theme: file given' => array( 331 'theme_dir' => 'nonexistent', 332 'file' => '/templates/page.html', 333 'expected' => '/nonexistent/templates/page.html', 334 ), 335 'parent theme: file exists' => array( 336 'theme_dir' => 'test-block-theme', 337 'file' => '/templates/page-home.html', 338 'expected' => '/test-block-theme/templates/page-home.html', 339 ), 340 'parent theme: file does not exist' => array( 341 'theme_dir' => 'test-block-theme', 342 'file' => '/templates/nonexistent.html', 343 'expected' => '/test-block-theme/templates/nonexistent.html', 344 ), 345 'child theme: file exists' => array( 346 'theme_dir' => 'test-block-child-theme', 347 'file' => '/templates/page-1.html', 348 'expected' => '/test-block-child-theme/templates/page-1.html', 349 ), 350 'child theme: file does not exist' => array( 351 'theme_dir' => 'test-block-child-theme', 352 'file' => '/templates/nonexistent.html', 353 'expected' => '/test-block-theme/templates/nonexistent.html', 354 ), 355 'child theme: file exists in parent, not in child' => array( 356 'theme_dir' => 'test-block-child-theme', 357 'file' => '/templates/page.html', 358 'expected' => '/test-block-theme/templates/page.html', 359 ), 360 ); 361 } 249 362 }
Note: See TracChangeset
for help on using the changeset viewer.