Changeset 47122 for trunk/tests/phpunit/tests/theme/WPTheme.php
- Timestamp:
- 01/29/2020 12:43:23 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/theme/WPTheme.php
r46586 r47122 14 14 add_filter( 'stylesheet_root', array( $this, '_theme_root' ) ); 15 15 add_filter( 'template_root', array( $this, '_theme_root' ) ); 16 // clear caches16 // Clear caches. 17 17 wp_clean_themes_cache(); 18 18 unset( $GLOBALS['wp_themes'] ); … … 29 29 } 30 30 31 // replace the normal theme root dir with our premade test dir31 // Replace the normal theme root directory with our premade test directory. 32 32 function _theme_root( $dir ) { 33 33 return $this->theme_root; … … 36 36 $theme = new WP_Theme( 'theme1', $this->theme_root ); 37 37 38 // Meta38 // Meta. 39 39 $this->assertEquals( 'My Theme', $theme->get( 'Name' ) ); 40 40 $this->assertEquals( 'http://example.org/', $theme->get( 'ThemeURI' ) ); … … 47 47 $this->assertEquals( array(), $theme->get( 'Tags' ) ); 48 48 49 // Important49 // Important. 50 50 $this->assertEquals( 'theme1', $theme->get_stylesheet() ); 51 51 $this->assertEquals( 'theme1', $theme->get_template() ); … … 55 55 $theme = new WP_Theme( 'subdir/theme2', $this->theme_root ); 56 56 57 // Meta57 // Meta. 58 58 $this->assertEquals( 'My Subdir Theme', $theme->get( 'Name' ) ); 59 59 $this->assertEquals( 'http://example.org/', $theme->get( 'ThemeURI' ) ); … … 66 66 $this->assertEquals( array(), $theme->get( 'Tags' ) ); 67 67 68 // Important68 // Important. 69 69 $this->assertEquals( 'subdir/theme2', $theme->get_stylesheet() ); 70 70 $this->assertEquals( 'subdir/theme2', $theme->get_template() ); … … 75 75 */ 76 76 function test_new_WP_Theme_subdir_bad_root() { 77 // This is what get_theme_data() does when you pass it a style.css file for a theme in a subdir .77 // This is what get_theme_data() does when you pass it a style.css file for a theme in a subdirectory. 78 78 $theme = new WP_Theme( 'theme2', $this->theme_root . '/subdir' ); 79 79 80 // Meta80 // Meta. 81 81 $this->assertEquals( 'My Subdir Theme', $theme->get( 'Name' ) ); 82 82 $this->assertEquals( 'http://example.org/', $theme->get( 'ThemeURI' ) ); … … 89 89 $this->assertEquals( array(), $theme->get( 'Tags' ) ); 90 90 91 // Important91 // Important. 92 92 $this->assertEquals( 'subdir/theme2', $theme->get_stylesheet() ); 93 93 $this->assertEquals( 'subdir/theme2', $theme->get_template() ); … … 102 102 $this->assertEquals( 'subdir/theme with spaces', $theme->get_stylesheet() ); 103 103 104 // Check that in a URI path, we have raw url encoding (spaces become %20)104 // Check that in a URI path, we have raw URL encoding (spaces become %20). 105 105 // Don't try to verify the complete URI path. get_theme_root_uri() breaks down quickly. 106 106 $this->assertEquals( 'theme%20with%20spaces', basename( $theme->get_stylesheet_directory_uri() ) ); 107 107 $this->assertEquals( 'theme%20with%20spaces', basename( $theme->get_template_directory_uri() ) ); 108 108 109 // Check that wp_customize_url() uses url encoding, as it is a query arg (spaces become +)109 // Check that wp_customize_url() uses URL encoding, as it is a query arg (spaces become +). 110 110 $this->assertEquals( admin_url( 'customize.php?theme=theme+with+spaces' ), wp_customize_url( 'theme with spaces' ) ); 111 111 } … … 163 163 WP_Theme::network_enable_theme( $theme ); 164 164 $new_allowed_themes = get_site_option( 'allowedthemes' ); 165 update_site_option( 'allowedthemes', $current_allowed_themes ); // reset previous value.165 update_site_option( 'allowedthemes', $current_allowed_themes ); // Reset previous value. 166 166 $current_allowed_themes['testtheme-1'] = true; // Add the new theme to the previous set. 167 167 … … 180 180 WP_Theme::network_enable_theme( $themes ); 181 181 $new_allowed_themes = get_site_option( 'allowedthemes' ); 182 update_site_option( 'allowedthemes', $current_allowed_themes ); // reset previous value.182 update_site_option( 'allowedthemes', $current_allowed_themes ); // Reset previous value. 183 183 $current_allowed_themes = array_merge( 184 184 $current_allowed_themes, … … 211 211 WP_Theme::network_disable_theme( $disable_theme ); 212 212 $new_allowed_themes = get_site_option( 'allowedthemes' ); 213 update_site_option( 'allowedthemes', $current_allowed_themes ); // reset previous value.213 update_site_option( 'allowedthemes', $current_allowed_themes ); // Reset previous value. 214 214 unset( $allowed_themes[ $disable_theme ] ); // Remove deleted theme from initial set. 215 215 … … 236 236 WP_Theme::network_disable_theme( $disable_themes ); 237 237 $new_allowed_themes = get_site_option( 'allowedthemes' ); 238 update_site_option( 'allowedthemes', $current_allowed_themes ); // reset previous value.238 update_site_option( 'allowedthemes', $current_allowed_themes ); // Reset previous value. 239 239 unset( $allowed_themes['existing-4'] ); 240 240 unset( $allowed_themes['existing-5'] );
Note: See TracChangeset
for help on using the changeset viewer.