Skip to content

Commit a4a0272

Browse files
committed
Tests: Isolate theme, script module, and post password fixtures.
Restore the registered theme features, allow the saved script modules instance to be `null`, and clear the post password cookie after the header tests. Developed in: #16131, #16132, #16134 Props ekamran. See #66755. git-svn-id: https://develop.svn.wordpress.org/trunk@65729 602fd350-edb4-49c9-b593-d223f7449a82
1 parent d20a2fb commit a4a0272

3 files changed

Lines changed: 18 additions & 2 deletions

File tree

‎tests/phpunit/tests/script-modules/wpScriptModules.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
*/
1212
class Tests_Script_Modules_WpScriptModules extends WP_UnitTestCase {
1313

14-
protected WP_Script_Modules $original_script_modules;
14+
protected ?WP_Script_Modules $original_script_modules;
1515

1616
protected string $original_wp_version;
1717

‎tests/phpunit/tests/theme.php‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,13 @@ class Tests_Theme extends WP_UnitTestCase {
4141
*/
4242
private $orig_theme_features;
4343

44+
/**
45+
* Theme features registered with register_theme_feature() before the test ran.
46+
*
47+
* @var array
48+
*/
49+
private $orig_registered_theme_features;
50+
4451
public function set_up() {
4552
global $wp_theme_directories;
4653

@@ -51,6 +58,8 @@ public function set_up() {
5158
$wp_theme_directories = array( WP_CONTENT_DIR . '/themes', realpath( DIR_TESTDATA . '/themedir1' ) );
5259
$this->orig_theme_features = $GLOBALS['_wp_theme_features'];
5360

61+
$this->orig_registered_theme_features = $GLOBALS['_wp_registered_theme_features'];
62+
5463
add_filter( 'extra_theme_headers', array( $this, 'theme_data_extra_headers' ) );
5564
wp_clean_themes_cache();
5665
unset( $GLOBALS['wp_themes'] );
@@ -69,7 +78,8 @@ public function tear_down() {
6978
parent::tear_down();
7079
} finally {
7180
// Restore after the parent removes HTML5 theme support.
72-
$GLOBALS['_wp_theme_features'] = $this->orig_theme_features;
81+
$GLOBALS['_wp_theme_features'] = $this->orig_theme_features;
82+
$GLOBALS['_wp_registered_theme_features'] = $this->orig_registered_theme_features;
7383
}
7484
}
7585

‎tests/phpunit/tests/wp/sendHeaders.php‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@
88
class Tests_WP_SendHeaders extends WP_UnitTestCase {
99
protected $headers_sent = array();
1010

11+
public function tear_down() {
12+
unset( $_COOKIE[ 'wp-postpass_' . COOKIEHASH ] );
13+
14+
parent::tear_down();
15+
}
16+
1117
/**
1218
* @ticket 56068
1319
*/

0 commit comments

Comments
 (0)