mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-07-28 13:00:19 +00:00
Coding Standards: Add visibility to methods in tests/phpunit/tests/.
Adds a `public` visibility to test fixtures, tests, data providers, and callbacks methods. Adds a `private` visibility to helper methods within test classes. Renames callbacks and helpers that previously started with a `_` prefix. Why? For consistency and to leverage using the method visibility. Further naming standardizations is beyond the scope of this commit. Props costdev, jrf, hellofromTonya. Fixes #54177. git-svn-id: https://develop.svn.wordpress.org/trunk@52010 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
*/
|
||||
class Tests_Theme_ThemeDir extends WP_UnitTestCase {
|
||||
|
||||
function set_up() {
|
||||
public function set_up() {
|
||||
parent::set_up();
|
||||
$this->theme_root = DIR_TESTDATA . '/themedir1';
|
||||
|
||||
@@ -16,15 +16,15 @@ class Tests_Theme_ThemeDir extends WP_UnitTestCase {
|
||||
// /themes is necessary as theme.php functions assume /themes is the root if there is only one root.
|
||||
$GLOBALS['wp_theme_directories'] = array( WP_CONTENT_DIR . '/themes', $this->theme_root );
|
||||
|
||||
add_filter( 'theme_root', array( $this, '_theme_root' ) );
|
||||
add_filter( 'stylesheet_root', array( $this, '_theme_root' ) );
|
||||
add_filter( 'template_root', array( $this, '_theme_root' ) );
|
||||
add_filter( 'theme_root', array( $this, 'filter_theme_root' ) );
|
||||
add_filter( 'stylesheet_root', array( $this, 'filter_theme_root' ) );
|
||||
add_filter( 'template_root', array( $this, 'filter_theme_root' ) );
|
||||
// Clear caches.
|
||||
wp_clean_themes_cache();
|
||||
unset( $GLOBALS['wp_themes'] );
|
||||
}
|
||||
|
||||
function tear_down() {
|
||||
public function tear_down() {
|
||||
$GLOBALS['wp_theme_directories'] = $this->orig_theme_dir;
|
||||
wp_clean_themes_cache();
|
||||
unset( $GLOBALS['wp_themes'] );
|
||||
@@ -32,7 +32,7 @@ class Tests_Theme_ThemeDir extends WP_UnitTestCase {
|
||||
}
|
||||
|
||||
// Replace the normal theme root directory with our premade test directory.
|
||||
function _theme_root( $dir ) {
|
||||
public function filter_theme_root( $dir ) {
|
||||
return $this->theme_root;
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ class Tests_Theme_ThemeDir extends WP_UnitTestCase {
|
||||
* @expectedDeprecated get_theme
|
||||
* @expectedDeprecated get_themes
|
||||
*/
|
||||
function test_theme_default() {
|
||||
public function test_theme_default() {
|
||||
$themes = get_themes();
|
||||
$theme = get_theme( 'WordPress Default' );
|
||||
$this->assertSame( $themes['WordPress Default'], $theme );
|
||||
@@ -71,7 +71,7 @@ class Tests_Theme_ThemeDir extends WP_UnitTestCase {
|
||||
* @expectedDeprecated get_theme
|
||||
* @expectedDeprecated get_themes
|
||||
*/
|
||||
function test_theme_sandbox() {
|
||||
public function test_theme_sandbox() {
|
||||
$theme = get_theme( 'Sandbox' );
|
||||
|
||||
$this->assertNotEmpty( $theme );
|
||||
@@ -107,7 +107,7 @@ class Tests_Theme_ThemeDir extends WP_UnitTestCase {
|
||||
*
|
||||
* @expectedDeprecated get_themes
|
||||
*/
|
||||
function test_theme_stylesheet_only() {
|
||||
public function test_theme_stylesheet_only() {
|
||||
$themes = get_themes();
|
||||
|
||||
$theme = $themes['Stylesheet Only'];
|
||||
@@ -137,7 +137,7 @@ class Tests_Theme_ThemeDir extends WP_UnitTestCase {
|
||||
/**
|
||||
* @expectedDeprecated get_themes
|
||||
*/
|
||||
function test_theme_list() {
|
||||
public function test_theme_list() {
|
||||
$themes = get_themes();
|
||||
|
||||
// Ignore themes in the default /themes directory.
|
||||
@@ -174,7 +174,7 @@ class Tests_Theme_ThemeDir extends WP_UnitTestCase {
|
||||
* @expectedDeprecated get_themes
|
||||
* @expectedDeprecated get_broken_themes
|
||||
*/
|
||||
function test_broken_themes() {
|
||||
public function test_broken_themes() {
|
||||
$themes = get_themes();
|
||||
|
||||
$expected = array(
|
||||
@@ -193,7 +193,7 @@ class Tests_Theme_ThemeDir extends WP_UnitTestCase {
|
||||
$this->assertSame( $expected, get_broken_themes() );
|
||||
}
|
||||
|
||||
function test_wp_get_theme_with_non_default_theme_root() {
|
||||
public function test_wp_get_theme_with_non_default_theme_root() {
|
||||
$this->assertFalse( wp_get_theme( 'sandbox', $this->theme_root )->errors() );
|
||||
$this->assertFalse( wp_get_theme( 'sandbox' )->errors() );
|
||||
}
|
||||
@@ -201,7 +201,7 @@ class Tests_Theme_ThemeDir extends WP_UnitTestCase {
|
||||
/**
|
||||
* @expectedDeprecated get_themes
|
||||
*/
|
||||
function test_page_templates() {
|
||||
public function test_page_templates() {
|
||||
$themes = get_themes();
|
||||
|
||||
$theme = $themes['Page Template Theme'];
|
||||
@@ -214,7 +214,7 @@ class Tests_Theme_ThemeDir extends WP_UnitTestCase {
|
||||
/**
|
||||
* @expectedDeprecated get_theme_data
|
||||
*/
|
||||
function test_get_theme_data_top_level() {
|
||||
public function test_get_theme_data_top_level() {
|
||||
$theme_data = get_theme_data( DIR_TESTDATA . '/themedir1/theme1/style.css' );
|
||||
|
||||
$this->assertSame( 'My Theme', $theme_data['Name'] );
|
||||
@@ -233,7 +233,7 @@ class Tests_Theme_ThemeDir extends WP_UnitTestCase {
|
||||
/**
|
||||
* @expectedDeprecated get_theme_data
|
||||
*/
|
||||
function test_get_theme_data_subdir() {
|
||||
public function test_get_theme_data_subdir() {
|
||||
$theme_data = get_theme_data( $this->theme_root . '/subdir/theme2/style.css' );
|
||||
|
||||
$this->assertSame( 'My Subdir Theme', $theme_data['Name'] );
|
||||
@@ -252,7 +252,7 @@ class Tests_Theme_ThemeDir extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 28662
|
||||
*/
|
||||
function test_theme_dir_slashes() {
|
||||
public function test_theme_dir_slashes() {
|
||||
$size = count( $GLOBALS['wp_theme_directories'] );
|
||||
|
||||
@mkdir( WP_CONTENT_DIR . '/themes/foo' );
|
||||
|
||||
Reference in New Issue
Block a user