Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions tests/phpunit/data/themedir1/block-theme/theme.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@
}
}
}
},
"my/unregistered-third-party-block": {
"color": {
"background": "hotpink"
}
}
},
"elements": {
Expand Down
5 changes: 5 additions & 0 deletions tests/phpunit/tests/template.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,11 @@ public function tear_down() {
$registry->unregister( 'third-party/test' );
}

if ( isset( $GLOBALS['_wp_tests_development_mode'] ) ) {
remove_all_filters( 'theme_file_path' );
wp_theme_has_theme_json();
}

unset( $GLOBALS['_wp_tests_development_mode'] );
parent::tear_down();
}
Expand Down
6 changes: 6 additions & 0 deletions tests/phpunit/tests/theme/support.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public function test_post_thumbnails() {
$this->assertFalse( current_theme_supports( 'post-thumbnails' ) );
add_theme_support( 'post-thumbnails' );
$this->assertTrue( current_theme_supports( 'post-thumbnails' ) );
remove_theme_support( 'post-thumbnails' );
}

public function test_post_thumbnails_flat_array_of_post_types() {
Expand All @@ -57,6 +58,8 @@ public function test_post_thumbnails_flat_array_of_post_types() {
* @ticket 22080
*/
public function test_post_thumbnails_mixed_args() {
remove_theme_support( 'post-thumbnails' );

add_theme_support( 'post-thumbnails', array( 'post', 'page' ) );
add_theme_support( 'post-thumbnails', array( 'page' ) );
$this->assertTrue( current_theme_supports( 'post-thumbnails', 'post' ) );
Expand Down Expand Up @@ -162,6 +165,8 @@ public function supports_foobar( $yesno, $args, $feature ) {
* @ticket 11611
*/
public function test_plugin_hook() {
remove_theme_support( 'foobar' );

$this->assertFalse( current_theme_supports( 'foobar' ) );
add_theme_support( 'foobar' );
$this->assertTrue( current_theme_supports( 'foobar' ) );
Expand All @@ -185,6 +190,7 @@ public function test_plugin_hook_with_no_args() {
add_filter( 'current_theme_supports-foobar', '__return_false' );

$this->assertFalse( current_theme_supports( 'foobar' ) );
remove_theme_support( 'foobar' );
}

/**
Expand Down
14 changes: 13 additions & 1 deletion tests/phpunit/tests/theme/wpAddGlobalStylesForBlocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ class Tests_Theme_WpAddGlobalStylesForBlocks extends WP_Theme_UnitTestCase {
*/
private $test_blocks = array();

/**
* Original stylesheet.
*
* @var string
*/
private $original_stylesheet;

/**
* Administrator ID.
*
Expand All @@ -37,6 +44,7 @@ public static function set_up_before_class() {

public function set_up() {
parent::set_up();
$this->original_stylesheet = get_stylesheet();
remove_action( 'wp_print_styles', 'print_emoji_styles' );
}

Expand All @@ -49,6 +57,10 @@ public function tear_down() {
$this->test_blocks = array();
}

if ( get_stylesheet() !== $this->original_stylesheet ) {
switch_theme( $this->original_stylesheet );
}

parent::tear_down();
}

Expand All @@ -63,7 +75,7 @@ public function test_third_party_blocks_inline_styles_not_register_to_global_sty
wp_add_global_styles_for_blocks();

$this->assertNotContains(
':root :where(.wp-block-my-third-party-block){background-color: hotpink;}',
':root :where(.wp-block-my-unregistered-third-party-block){background-color: hotpink;}',
$this->get_global_styles()
);
}
Expand Down
Loading