mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-28 14:20:15 +00:00
Coding Standards: Add missing visibility keywords to WP_Theme, WP_Theme_JSON, and WP_Theme_JSON_Resolver tests.
Follow-up to [50959], [50960], [50967]. See #52627. git-svn-id: https://develop.svn.wordpress.org/trunk@51287 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -62,7 +62,7 @@ class WP_Test_REST_Sidebars_Controller extends WP_Test_REST_Controller_Testcase
|
||||
update_option( 'sidebars_widgets', array() );
|
||||
}
|
||||
|
||||
function clean_up_global_scope() {
|
||||
public function clean_up_global_scope() {
|
||||
global $wp_widget_factory, $wp_registered_sidebars, $wp_registered_widgets, $wp_registered_widget_controls, $wp_registered_widget_updates;
|
||||
|
||||
$wp_registered_sidebars = array();
|
||||
|
||||
@@ -9,7 +9,8 @@
|
||||
* @group themes
|
||||
*/
|
||||
class Tests_Theme_wpTheme extends WP_UnitTestCase {
|
||||
function setUp() {
|
||||
|
||||
public function setUp() {
|
||||
parent::setUp();
|
||||
$this->theme_root = realpath( DIR_TESTDATA . '/themedir1' );
|
||||
|
||||
@@ -24,7 +25,7 @@ class Tests_Theme_wpTheme extends WP_UnitTestCase {
|
||||
unset( $GLOBALS['wp_themes'] );
|
||||
}
|
||||
|
||||
function tearDown() {
|
||||
public function tearDown() {
|
||||
$GLOBALS['wp_theme_directories'] = $this->orig_theme_dir;
|
||||
wp_clean_themes_cache();
|
||||
unset( $GLOBALS['wp_themes'] );
|
||||
@@ -32,10 +33,11 @@ class Tests_Theme_wpTheme extends WP_UnitTestCase {
|
||||
}
|
||||
|
||||
// Replace the normal theme root directory with our premade test directory.
|
||||
function _theme_root( $dir ) {
|
||||
public function _theme_root( $dir ) {
|
||||
return $this->theme_root;
|
||||
}
|
||||
function test_new_WP_Theme_top_level() {
|
||||
|
||||
public function test_new_WP_Theme_top_level() {
|
||||
$theme = new WP_Theme( 'theme1', $this->theme_root );
|
||||
|
||||
// Meta.
|
||||
@@ -54,7 +56,7 @@ class Tests_Theme_wpTheme extends WP_UnitTestCase {
|
||||
$this->assertSame( 'theme1', $theme->get_template() );
|
||||
}
|
||||
|
||||
function test_new_WP_Theme_subdir() {
|
||||
public function test_new_WP_Theme_subdir() {
|
||||
$theme = new WP_Theme( 'subdir/theme2', $this->theme_root );
|
||||
|
||||
// Meta.
|
||||
@@ -76,7 +78,7 @@ class Tests_Theme_wpTheme extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 20313
|
||||
*/
|
||||
function test_new_WP_Theme_subdir_bad_root() {
|
||||
public function test_new_WP_Theme_subdir_bad_root() {
|
||||
// This is what get_theme_data() does when you pass it a style.css file for a theme in a subdirectory.
|
||||
$theme = new WP_Theme( 'theme2', $this->theme_root . '/subdir' );
|
||||
|
||||
@@ -99,7 +101,7 @@ class Tests_Theme_wpTheme extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 21749
|
||||
*/
|
||||
function test_wp_theme_uris_with_spaces() {
|
||||
public function test_wp_theme_uris_with_spaces() {
|
||||
$theme = new WP_Theme( 'theme with spaces', $this->theme_root . '/subdir' );
|
||||
// Make sure subdir/ is considered part of the stylesheet, as we must avoid encoding /'s.
|
||||
$this->assertSame( 'subdir/theme with spaces', $theme->get_stylesheet() );
|
||||
@@ -116,7 +118,7 @@ class Tests_Theme_wpTheme extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 21969
|
||||
*/
|
||||
function test_theme_uris_with_spaces() {
|
||||
public function test_theme_uris_with_spaces() {
|
||||
$callback = array( $this, 'filter_theme_with_spaces' );
|
||||
add_filter( 'stylesheet', $callback );
|
||||
add_filter( 'template', $callback );
|
||||
@@ -128,14 +130,14 @@ class Tests_Theme_wpTheme extends WP_UnitTestCase {
|
||||
remove_filter( 'template', $callback );
|
||||
}
|
||||
|
||||
function filter_theme_with_spaces() {
|
||||
public function filter_theme_with_spaces() {
|
||||
return 'subdir/theme with spaces';
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 26873
|
||||
*/
|
||||
function test_display_method_on_get_method_failure() {
|
||||
public function test_display_method_on_get_method_failure() {
|
||||
$theme = new WP_Theme( 'nonexistent', $this->theme_root );
|
||||
$this->assertSame( 'nonexistent', $theme->get( 'Name' ) );
|
||||
$this->assertFalse( $theme->get( 'AuthorURI' ) );
|
||||
@@ -146,7 +148,7 @@ class Tests_Theme_wpTheme extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 40820
|
||||
*/
|
||||
function test_child_theme_with_itself_as_parent_should_appear_as_broken() {
|
||||
public function test_child_theme_with_itself_as_parent_should_appear_as_broken() {
|
||||
$theme = new WP_Theme( 'child-parent-itself', $this->theme_root );
|
||||
$errors = $theme->errors();
|
||||
$this->assertWPError( $errors );
|
||||
@@ -160,7 +162,7 @@ class Tests_Theme_wpTheme extends WP_UnitTestCase {
|
||||
* @ticket 30594
|
||||
* @group ms-required
|
||||
*/
|
||||
function test_wp_theme_network_enable_single_theme() {
|
||||
public function test_wp_theme_network_enable_single_theme() {
|
||||
$theme = 'testtheme-1';
|
||||
$current_allowed_themes = get_site_option( 'allowedthemes' );
|
||||
WP_Theme::network_enable_theme( $theme );
|
||||
@@ -177,7 +179,7 @@ class Tests_Theme_wpTheme extends WP_UnitTestCase {
|
||||
* @ticket 30594
|
||||
* @group ms-required
|
||||
*/
|
||||
function test_wp_theme_network_enable_multiple_themes() {
|
||||
public function test_wp_theme_network_enable_multiple_themes() {
|
||||
$themes = array( 'testtheme-2', 'testtheme-3' );
|
||||
$current_allowed_themes = get_site_option( 'allowedthemes' );
|
||||
WP_Theme::network_enable_theme( $themes );
|
||||
@@ -200,7 +202,7 @@ class Tests_Theme_wpTheme extends WP_UnitTestCase {
|
||||
* @ticket 30594
|
||||
* @group ms-required
|
||||
*/
|
||||
function test_network_disable_single_theme() {
|
||||
public function test_network_disable_single_theme() {
|
||||
$current_allowed_themes = get_site_option( 'allowedthemes' );
|
||||
|
||||
$allowed_themes = array(
|
||||
@@ -225,7 +227,7 @@ class Tests_Theme_wpTheme extends WP_UnitTestCase {
|
||||
* @ticket 30594
|
||||
* @group ms-required
|
||||
*/
|
||||
function test_network_disable_multiple_themes() {
|
||||
public function test_network_disable_multiple_themes() {
|
||||
$current_allowed_themes = get_site_option( 'allowedthemes' );
|
||||
|
||||
$allowed_themes = array(
|
||||
|
||||
@@ -16,7 +16,7 @@ class Tests_Theme_wpThemeJson extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 52991
|
||||
*/
|
||||
function test_get_settings() {
|
||||
public function test_get_settings() {
|
||||
$theme_json = new WP_Theme_JSON(
|
||||
array(
|
||||
'version' => WP_Theme_JSON::LATEST_SCHEMA,
|
||||
@@ -67,7 +67,7 @@ class Tests_Theme_wpThemeJson extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 53397
|
||||
*/
|
||||
function test_get_settings_presets_are_keyed_by_origin() {
|
||||
public function test_get_settings_presets_are_keyed_by_origin() {
|
||||
$core_origin = new WP_Theme_JSON(
|
||||
array(
|
||||
'version' => WP_Theme_JSON::LATEST_SCHEMA,
|
||||
@@ -195,7 +195,7 @@ class Tests_Theme_wpThemeJson extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 53175
|
||||
*/
|
||||
function test_get_stylesheet() {
|
||||
public function test_get_stylesheet() {
|
||||
$theme_json = new WP_Theme_JSON(
|
||||
array(
|
||||
'version' => WP_Theme_JSON::LATEST_SCHEMA,
|
||||
@@ -316,7 +316,7 @@ class Tests_Theme_wpThemeJson extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 52991
|
||||
*/
|
||||
function test_get_stylesheet_preset_classes_work_with_compounded_selectors() {
|
||||
public function test_get_stylesheet_preset_classes_work_with_compounded_selectors() {
|
||||
$theme_json = new WP_Theme_JSON(
|
||||
array(
|
||||
'version' => WP_Theme_JSON::LATEST_SCHEMA,
|
||||
@@ -346,7 +346,7 @@ class Tests_Theme_wpThemeJson extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 53175
|
||||
*/
|
||||
function test_get_stylesheet_preset_rules_come_after_block_rules() {
|
||||
public function test_get_stylesheet_preset_rules_come_after_block_rules() {
|
||||
$theme_json = new WP_Theme_JSON(
|
||||
array(
|
||||
'version' => WP_Theme_JSON::LATEST_SCHEMA,
|
||||
@@ -670,7 +670,7 @@ class Tests_Theme_wpThemeJson extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 52991
|
||||
*/
|
||||
function test_get_from_editor_settings() {
|
||||
public function test_get_from_editor_settings() {
|
||||
$input = array(
|
||||
'disableCustomColors' => true,
|
||||
'disableCustomGradients' => true,
|
||||
@@ -746,7 +746,7 @@ class Tests_Theme_wpThemeJson extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 52991
|
||||
*/
|
||||
function test_get_editor_settings_no_theme_support() {
|
||||
public function test_get_editor_settings_no_theme_support() {
|
||||
$input = array(
|
||||
'__unstableEnableFullSiteEditingBlocks' => false,
|
||||
'disableCustomColors' => false,
|
||||
@@ -801,7 +801,7 @@ class Tests_Theme_wpThemeJson extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 52991
|
||||
*/
|
||||
function test_get_editor_settings_blank() {
|
||||
public function test_get_editor_settings_blank() {
|
||||
$expected = array(
|
||||
'version' => WP_Theme_JSON::LATEST_SCHEMA,
|
||||
'settings' => array(),
|
||||
@@ -814,7 +814,7 @@ class Tests_Theme_wpThemeJson extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 52991
|
||||
*/
|
||||
function test_get_editor_settings_custom_units_can_be_disabled() {
|
||||
public function test_get_editor_settings_custom_units_can_be_disabled() {
|
||||
add_theme_support( 'custom-units', array() );
|
||||
$input = get_default_block_editor_settings();
|
||||
|
||||
@@ -831,7 +831,7 @@ class Tests_Theme_wpThemeJson extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 52991
|
||||
*/
|
||||
function test_get_editor_settings_custom_units_can_be_enabled() {
|
||||
public function test_get_editor_settings_custom_units_can_be_enabled() {
|
||||
add_theme_support( 'custom-units' );
|
||||
$input = get_default_block_editor_settings();
|
||||
|
||||
@@ -848,7 +848,7 @@ class Tests_Theme_wpThemeJson extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 52991
|
||||
*/
|
||||
function test_get_editor_settings_custom_units_can_be_filtered() {
|
||||
public function test_get_editor_settings_custom_units_can_be_filtered() {
|
||||
add_theme_support( 'custom-units', 'rem', 'em' );
|
||||
$input = get_default_block_editor_settings();
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
*/
|
||||
class Tests_Theme_wpThemeJsonResolver extends WP_UnitTestCase {
|
||||
|
||||
function setUp() {
|
||||
public function setUp() {
|
||||
parent::setUp();
|
||||
$this->theme_root = realpath( DIR_TESTDATA . '/themedir1' );
|
||||
|
||||
@@ -29,25 +29,25 @@ class Tests_Theme_wpThemeJsonResolver extends WP_UnitTestCase {
|
||||
unset( $GLOBALS['wp_themes'] );
|
||||
}
|
||||
|
||||
function tearDown() {
|
||||
public function tearDown() {
|
||||
$GLOBALS['wp_theme_directories'] = $this->orig_theme_dir;
|
||||
wp_clean_themes_cache();
|
||||
unset( $GLOBALS['wp_themes'] );
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
function filter_set_theme_root() {
|
||||
public function filter_set_theme_root() {
|
||||
return $this->theme_root;
|
||||
}
|
||||
|
||||
function filter_set_locale_to_polish() {
|
||||
public function filter_set_locale_to_polish() {
|
||||
return 'pl_PL';
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 52991
|
||||
*/
|
||||
function test_fields_are_extracted() {
|
||||
public function test_fields_are_extracted() {
|
||||
$actual = WP_Theme_JSON_Resolver::get_fields_to_translate();
|
||||
|
||||
$expected = array(
|
||||
@@ -94,7 +94,7 @@ class Tests_Theme_wpThemeJsonResolver extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 52991
|
||||
*/
|
||||
function test_translations_are_applied() {
|
||||
public function test_translations_are_applied() {
|
||||
add_filter( 'locale', array( $this, 'filter_set_locale_to_polish' ) );
|
||||
load_textdomain( 'fse', realpath( DIR_TESTDATA . '/languages/themes/fse-pl_PL.mo' ) );
|
||||
|
||||
@@ -148,7 +148,7 @@ class Tests_Theme_wpThemeJsonResolver extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 52991
|
||||
*/
|
||||
function test_switching_themes_recalculates_data() {
|
||||
public function test_switching_themes_recalculates_data() {
|
||||
// By default, the theme for unit tests is "default",
|
||||
// which doesn't have theme.json support.
|
||||
$default = WP_Theme_JSON_Resolver::theme_has_support();
|
||||
|
||||
Reference in New Issue
Block a user