- Timestamp:
- 10/24/2018 12:35:51 AM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/5.0/tests/phpunit/tests/dependencies/styles.php
r36649 r43812 5 5 */ 6 6 class Tests_Dependencies_Styles extends WP_UnitTestCase { 7 var $old_wp_styles; 7 private $old_wp_styles; 8 private $old_wp_scripts; 8 9 9 10 function setUp() { 10 11 parent::setUp(); 11 if ( empty( $GLOBALS['wp_styles'] ) ) 12 13 if ( empty( $GLOBALS['wp_styles'] ) ) { 12 14 $GLOBALS['wp_styles'] = null; 15 } 16 13 17 $this->old_wp_styles = $GLOBALS['wp_styles']; 18 19 if ( empty( $GLOBALS['wp_scripts'] ) ) { 20 $GLOBALS['wp_scripts'] = null; 21 } 22 23 $this->old_wp_styles = $GLOBALS['wp_scripts']; 24 14 25 remove_action( 'wp_default_styles', 'wp_default_styles' ); 15 26 remove_action( 'wp_print_styles', 'print_emoji_styles' ); 27 16 28 $GLOBALS['wp_styles'] = new WP_Styles(); 17 29 $GLOBALS['wp_styles']->default_version = get_bloginfo( 'version' ); 30 31 $GLOBALS['wp_scripts'] = new WP_Scripts(); 32 $GLOBALS['wp_scripts']->default_version = get_bloginfo( 'version' ); 18 33 } 19 34 20 35 function tearDown() { 21 36 $GLOBALS['wp_styles'] = $this->old_wp_styles; 37 $GLOBALS['wp_scripts'] = $this->old_wp_scripts; 38 22 39 add_action( 'wp_default_styles', 'wp_default_styles' ); 23 40 add_action( 'wp_print_styles', 'print_emoji_styles' ); 41 42 if ( current_theme_supports( 'wp-block-styles' ) ) { 43 remove_theme_support( 'wp-block-styles' ); 44 } 45 24 46 parent::tearDown(); 25 47 } … … 299 321 ); 300 322 } 323 324 /** 325 * Tests that visual block styles are enqueued in the editor even when there is not theme support for 'wp-block-styles'. 326 * 327 * Visual block styles should always be enqueued when editing to avoid the appearance of a broken editor. 328 */ 329 function test_block_styles_for_editing_without_theme_support() { 330 // Confirm we are without theme support by default. 331 $this->assertFalse( current_theme_supports( 'wp-block-styles' ) ); 332 333 wp_default_styles( $GLOBALS['wp_styles'] ); 334 335 $this->assertFalse( wp_style_is( 'wp-block-library-theme' ) ); 336 wp_enqueue_style( 'wp-edit-blocks' ); 337 $this->assertTrue( wp_style_is( 'wp-block-library-theme' ) ); 338 } 339 340 /** 341 * Tests that visual block styles are enqueued when there is theme support for 'wp-block-styles'. 342 * 343 * Visual block styles should always be enqueued when editing to avoid the appearance of a broken editor. 344 */ 345 function test_block_styles_for_editing_with_theme_support() { 346 add_theme_support( 'wp-block-styles' ); 347 348 wp_default_styles( $GLOBALS['wp_styles'] ); 349 350 $this->assertFalse( wp_style_is( 'wp-block-library-theme' ) ); 351 wp_common_block_scripts_and_styles(); 352 $this->assertTrue( wp_style_is( 'wp-block-library-theme' ) ); 353 } 354 355 /** 356 * Tests that visual block styles are not enqueued for viewing when there is no theme support for 'wp-block-styles'. 357 * 358 * Visual block styles should not be enqueued unless a theme opts in. 359 * This way we avoid style conflicts with existing themes. 360 */ 361 function test_no_block_styles_for_viewing_without_theme_support() { 362 // Confirm we are without theme support by default. 363 $this->assertFalse( current_theme_supports( 'wp-block-styles' ) ); 364 365 wp_default_styles( $GLOBALS['wp_styles'] ); 366 367 $this->assertFalse( wp_style_is( 'wp-block-library-theme' ) ); 368 wp_enqueue_style( 'wp-block-library' ); 369 $this->assertFalse( wp_style_is( 'wp-block-library-theme' ) ); 370 } 371 372 /** 373 * Tests that visual block styles are enqueued for viewing when there is theme support for 'wp-block-styles'. 374 * 375 * Visual block styles should be enqueued when a theme opts in. 376 */ 377 function test_block_styles_for_viewing_with_theme_support() { 378 add_theme_support( 'wp-block-styles' ); 379 380 wp_default_styles( $GLOBALS['wp_styles'] ); 381 382 $this->assertFalse( wp_style_is( 'wp-block-library-theme' ) ); 383 wp_common_block_scripts_and_styles(); 384 $this->assertTrue( wp_style_is( 'wp-block-library-theme' ) ); 385 } 301 386 }
Note: See TracChangeset
for help on using the changeset viewer.