Changeset 44157 for trunk/tests/phpunit/tests/dependencies/styles.php
- Timestamp:
- 12/14/2018 03:35:55 AM (7 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
tests/phpunit/tests/dependencies/styles.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/branches/5.0 merged: 43812
- Property svn:mergeinfo changed
-
trunk/tests/phpunit/tests/dependencies/styles.php
r42343 r44157 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(); 12 11 13 if ( empty( $GLOBALS['wp_styles'] ) ) { 12 14 $GLOBALS['wp_styles'] = null; 13 15 } 16 14 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 15 25 remove_action( 'wp_default_styles', 'wp_default_styles' ); 16 26 remove_action( 'wp_print_styles', 'print_emoji_styles' ); 27 17 28 $GLOBALS['wp_styles'] = new WP_Styles(); 18 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' ); 19 33 } 20 34 21 35 function tearDown() { 22 $GLOBALS['wp_styles'] = $this->old_wp_styles; 36 $GLOBALS['wp_styles'] = $this->old_wp_styles; 37 $GLOBALS['wp_scripts'] = $this->old_wp_scripts; 38 23 39 add_action( 'wp_default_styles', 'wp_default_styles' ); 24 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 25 46 parent::tearDown(); 26 47 } … … 306 327 ); 307 328 } 329 330 /** 331 * Tests that visual block styles are enqueued in the editor even when there is not theme support for 'wp-block-styles'. 332 * 333 * Visual block styles should always be enqueued when editing to avoid the appearance of a broken editor. 334 */ 335 function test_block_styles_for_editing_without_theme_support() { 336 // Confirm we are without theme support by default. 337 $this->assertFalse( current_theme_supports( 'wp-block-styles' ) ); 338 339 wp_default_styles( $GLOBALS['wp_styles'] ); 340 341 $this->assertFalse( wp_style_is( 'wp-block-library-theme' ) ); 342 wp_enqueue_style( 'wp-edit-blocks' ); 343 $this->assertTrue( wp_style_is( 'wp-block-library-theme' ) ); 344 } 345 346 /** 347 * Tests that visual block styles are enqueued when there is theme support for 'wp-block-styles'. 348 * 349 * Visual block styles should always be enqueued when editing to avoid the appearance of a broken editor. 350 */ 351 function test_block_styles_for_editing_with_theme_support() { 352 add_theme_support( 'wp-block-styles' ); 353 354 wp_default_styles( $GLOBALS['wp_styles'] ); 355 356 $this->assertFalse( wp_style_is( 'wp-block-library-theme' ) ); 357 wp_common_block_scripts_and_styles(); 358 $this->assertTrue( wp_style_is( 'wp-block-library-theme' ) ); 359 } 360 361 /** 362 * Tests that visual block styles are not enqueued for viewing when there is no theme support for 'wp-block-styles'. 363 * 364 * Visual block styles should not be enqueued unless a theme opts in. 365 * This way we avoid style conflicts with existing themes. 366 */ 367 function test_no_block_styles_for_viewing_without_theme_support() { 368 // Confirm we are without theme support by default. 369 $this->assertFalse( current_theme_supports( 'wp-block-styles' ) ); 370 371 wp_default_styles( $GLOBALS['wp_styles'] ); 372 373 $this->assertFalse( wp_style_is( 'wp-block-library-theme' ) ); 374 wp_enqueue_style( 'wp-block-library' ); 375 $this->assertFalse( wp_style_is( 'wp-block-library-theme' ) ); 376 } 377 378 /** 379 * Tests that visual block styles are enqueued for viewing when there is theme support for 'wp-block-styles'. 380 * 381 * Visual block styles should be enqueued when a theme opts in. 382 */ 383 function test_block_styles_for_viewing_with_theme_support() { 384 add_theme_support( 'wp-block-styles' ); 385 386 wp_default_styles( $GLOBALS['wp_styles'] ); 387 388 $this->assertFalse( wp_style_is( 'wp-block-library-theme' ) ); 389 wp_common_block_scripts_and_styles(); 390 $this->assertTrue( wp_style_is( 'wp-block-library-theme' ) ); 391 } 308 392 }
Note: See TracChangeset
for help on using the changeset viewer.