Changeset 42343 for trunk/tests/phpunit/tests/theme/WPTheme.php
- Timestamp:
- 11/30/2017 11:09:33 PM (8 years ago)
- File:
-
- 1 edited
-
trunk/tests/phpunit/tests/theme/WPTheme.php (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/theme/WPTheme.php
r41601 r42343 8 8 $this->theme_root = realpath( DIR_TESTDATA . '/themedir1' ); 9 9 10 $this->orig_theme_dir = $GLOBALS['wp_theme_directories'];10 $this->orig_theme_dir = $GLOBALS['wp_theme_directories']; 11 11 $GLOBALS['wp_theme_directories'] = array( $this->theme_root ); 12 12 13 add_filter( 'theme_root', array($this, '_theme_root'));14 add_filter( 'stylesheet_root', array( $this, '_theme_root') );15 add_filter( 'template_root', array( $this, '_theme_root') );13 add_filter( 'theme_root', array( $this, '_theme_root' ) ); 14 add_filter( 'stylesheet_root', array( $this, '_theme_root' ) ); 15 add_filter( 'template_root', array( $this, '_theme_root' ) ); 16 16 // clear caches 17 17 wp_clean_themes_cache(); … … 21 21 function tearDown() { 22 22 $GLOBALS['wp_theme_directories'] = $this->orig_theme_dir; 23 remove_filter( 'theme_root', array($this, '_theme_root'));24 remove_filter( 'stylesheet_root', array( $this, '_theme_root') );25 remove_filter( 'template_root', array( $this, '_theme_root') );23 remove_filter( 'theme_root', array( $this, '_theme_root' ) ); 24 remove_filter( 'stylesheet_root', array( $this, '_theme_root' ) ); 25 remove_filter( 'template_root', array( $this, '_theme_root' ) ); 26 26 wp_clean_themes_cache(); 27 27 unset( $GLOBALS['wp_themes'] ); … … 30 30 31 31 // replace the normal theme root dir with our premade test dir 32 function _theme_root( $dir) {32 function _theme_root( $dir ) { 33 33 return $this->theme_root; 34 34 } … … 37 37 38 38 //Meta 39 $this->assertEquals( 'My Theme', $theme->get( 'Name') );40 $this->assertEquals( 'http://example.org/', $theme->get('ThemeURI') );41 $this->assertEquals( 'An example theme', $theme->get( 'Description') );42 $this->assertEquals( 'Minnie Bannister', $theme->get( 'Author') );43 $this->assertEquals( 'http://example.com/', $theme->get( 'AuthorURI') );44 $this->assertEquals( '1.3', $theme->get( 'Version') );45 $this->assertEquals( '', $theme->get( 'Template') );46 $this->assertEquals( 'publish', $theme->get( 'Status') );47 $this->assertEquals( array(), $theme->get( 'Tags') );39 $this->assertEquals( 'My Theme', $theme->get( 'Name' ) ); 40 $this->assertEquals( 'http://example.org/', $theme->get( 'ThemeURI' ) ); 41 $this->assertEquals( 'An example theme', $theme->get( 'Description' ) ); 42 $this->assertEquals( 'Minnie Bannister', $theme->get( 'Author' ) ); 43 $this->assertEquals( 'http://example.com/', $theme->get( 'AuthorURI' ) ); 44 $this->assertEquals( '1.3', $theme->get( 'Version' ) ); 45 $this->assertEquals( '', $theme->get( 'Template' ) ); 46 $this->assertEquals( 'publish', $theme->get( 'Status' ) ); 47 $this->assertEquals( array(), $theme->get( 'Tags' ) ); 48 48 49 49 //Important … … 56 56 57 57 //Meta 58 $this->assertEquals( 'My Subdir Theme', $theme->get( 'Name') );59 $this->assertEquals( 'http://example.org/', $theme->get('ThemeURI') );60 $this->assertEquals( 'An example theme in a sub directory', $theme->get( 'Description') );61 $this->assertEquals( 'Mr. WordPress', $theme->get( 'Author') );62 $this->assertEquals( 'http://wordpress.org/', $theme->get( 'AuthorURI') );63 $this->assertEquals( '0.1', $theme->get( 'Version') );64 $this->assertEquals( '', $theme->get( 'Template') );65 $this->assertEquals( 'publish', $theme->get( 'Status') );66 $this->assertEquals( array(), $theme->get( 'Tags') );58 $this->assertEquals( 'My Subdir Theme', $theme->get( 'Name' ) ); 59 $this->assertEquals( 'http://example.org/', $theme->get( 'ThemeURI' ) ); 60 $this->assertEquals( 'An example theme in a sub directory', $theme->get( 'Description' ) ); 61 $this->assertEquals( 'Mr. WordPress', $theme->get( 'Author' ) ); 62 $this->assertEquals( 'http://wordpress.org/', $theme->get( 'AuthorURI' ) ); 63 $this->assertEquals( '0.1', $theme->get( 'Version' ) ); 64 $this->assertEquals( '', $theme->get( 'Template' ) ); 65 $this->assertEquals( 'publish', $theme->get( 'Status' ) ); 66 $this->assertEquals( array(), $theme->get( 'Tags' ) ); 67 67 68 68 //Important … … 79 79 80 80 //Meta 81 $this->assertEquals( 'My Subdir Theme', $theme->get( 'Name') );82 $this->assertEquals( 'http://example.org/', $theme->get('ThemeURI') );83 $this->assertEquals( 'An example theme in a sub directory', $theme->get( 'Description') );84 $this->assertEquals( 'Mr. WordPress', $theme->get( 'Author') );85 $this->assertEquals( 'http://wordpress.org/', $theme->get( 'AuthorURI') );86 $this->assertEquals( '0.1', $theme->get( 'Version') );87 $this->assertEquals( '', $theme->get( 'Template') );88 $this->assertEquals( 'publish', $theme->get( 'Status') );89 $this->assertEquals( array(), $theme->get( 'Tags') );81 $this->assertEquals( 'My Subdir Theme', $theme->get( 'Name' ) ); 82 $this->assertEquals( 'http://example.org/', $theme->get( 'ThemeURI' ) ); 83 $this->assertEquals( 'An example theme in a sub directory', $theme->get( 'Description' ) ); 84 $this->assertEquals( 'Mr. WordPress', $theme->get( 'Author' ) ); 85 $this->assertEquals( 'http://wordpress.org/', $theme->get( 'AuthorURI' ) ); 86 $this->assertEquals( '0.1', $theme->get( 'Version' ) ); 87 $this->assertEquals( '', $theme->get( 'Template' ) ); 88 $this->assertEquals( 'publish', $theme->get( 'Status' ) ); 89 $this->assertEquals( array(), $theme->get( 'Tags' ) ); 90 90 91 91 //Important … … 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 $this->assertEquals( 'theme%20with%20spaces', basename( $theme->get_template_directory_uri() ) );107 $this->assertEquals( 'theme%20with%20spaces', basename( $theme->get_template_directory_uri() ) ); 108 108 109 109 // Check that wp_customize_url() uses url encoding, as it is a query arg (spaces become +) … … 145 145 */ 146 146 function test_child_theme_with_itself_as_parent_should_appear_as_broken() { 147 $theme = new WP_Theme( 'child-parent-itself', $this->theme_root );147 $theme = new WP_Theme( 'child-parent-itself', $this->theme_root ); 148 148 $errors = $theme->errors(); 149 149 $this->assertWPError( $errors ); … … 159 159 */ 160 160 function test_wp_theme_network_enable_single_theme() { 161 $theme = 'testtheme-1';161 $theme = 'testtheme-1'; 162 162 $current_allowed_themes = get_site_option( 'allowedthemes' ); 163 163 WP_Theme::network_enable_theme( $theme ); … … 176 176 */ 177 177 function test_wp_theme_network_enable_multiple_themes() { 178 $themes = array( 'testtheme-2', 'testtheme-3' );178 $themes = array( 'testtheme-2', 'testtheme-3' ); 179 179 $current_allowed_themes = get_site_option( 'allowedthemes' ); 180 180 WP_Theme::network_enable_theme( $themes ); 181 181 $new_allowed_themes = get_site_option( 'allowedthemes' ); 182 182 update_site_option( 'allowedthemes', $current_allowed_themes ); // reset previous value. 183 $current_allowed_themes = array_merge( $current_allowed_themes, array( 'testtheme-2' => true, 'testtheme-3' => true ) ); 183 $current_allowed_themes = array_merge( 184 $current_allowed_themes, array( 185 'testtheme-2' => true, 186 'testtheme-3' => true, 187 ) 188 ); 184 189 185 190 $this->assertEqualSetsWithIndex( $current_allowed_themes, $new_allowed_themes ); … … 195 200 $current_allowed_themes = get_site_option( 'allowedthemes' ); 196 201 197 $allowed_themes = array( 'existing-1' => true, 'existing-2' => true, 'existing-3' => true ); 202 $allowed_themes = array( 203 'existing-1' => true, 204 'existing-2' => true, 205 'existing-3' => true, 206 ); 198 207 update_site_option( 'allowedthemes', $allowed_themes ); 199 208 … … 216 225 $current_allowed_themes = get_site_option( 'allowedthemes' ); 217 226 218 $allowed_themes = array( 'existing-4' => true, 'existing-5' => true, 'existing-6' => true ); 227 $allowed_themes = array( 228 'existing-4' => true, 229 'existing-5' => true, 230 'existing-6' => true, 231 ); 219 232 update_site_option( 'allowedthemes', $allowed_themes ); 220 233
Note: See TracChangeset
for help on using the changeset viewer.