Changeset 42343 for trunk/tests/phpunit/tests/theme/themeDir.php
- Timestamp:
- 11/30/2017 11:09:33 PM (8 years ago)
- File:
-
- 1 edited
-
trunk/tests/phpunit/tests/theme/themeDir.php (modified) (15 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/theme/themeDir.php
r41610 r42343 17 17 $GLOBALS['wp_theme_directories'] = array( WP_CONTENT_DIR . '/themes', $this->theme_root ); 18 18 19 add_filter( 'theme_root', array($this, '_theme_root'));20 add_filter( 'stylesheet_root', array( $this, '_theme_root') );21 add_filter( 'template_root', array( $this, '_theme_root') );19 add_filter( 'theme_root', array( $this, '_theme_root' ) ); 20 add_filter( 'stylesheet_root', array( $this, '_theme_root' ) ); 21 add_filter( 'template_root', array( $this, '_theme_root' ) ); 22 22 // clear caches 23 23 wp_clean_themes_cache(); … … 27 27 function tearDown() { 28 28 $GLOBALS['wp_theme_directories'] = $this->orig_theme_dir; 29 remove_filter( 'theme_root', array($this, '_theme_root'));30 remove_filter( 'stylesheet_root', array( $this, '_theme_root') );31 remove_filter( 'template_root', array( $this, '_theme_root') );29 remove_filter( 'theme_root', array( $this, '_theme_root' ) ); 30 remove_filter( 'stylesheet_root', array( $this, '_theme_root' ) ); 31 remove_filter( 'template_root', array( $this, '_theme_root' ) ); 32 32 wp_clean_themes_cache(); 33 33 unset( $GLOBALS['wp_themes'] ); … … 36 36 37 37 // replace the normal theme root dir with our premade test dir 38 function _theme_root( $dir) {38 function _theme_root( $dir ) { 39 39 return $this->theme_root; 40 40 } … … 46 46 function test_theme_default() { 47 47 $themes = get_themes(); 48 $theme = get_theme('WordPress Default');48 $theme = get_theme( 'WordPress Default' ); 49 49 $this->assertEquals( $themes['WordPress Default'], $theme ); 50 50 51 $this->assertFalse( empty( $theme) );51 $this->assertFalse( empty( $theme ) ); 52 52 53 53 #echo gen_tests_array('theme', $theme); … … 65 65 $this->assertContains( $this->theme_root . '/default/style.css', $theme['Stylesheet Files'] ); 66 66 67 $this->assertEquals( $this->theme_root .'/default', $theme['Template Dir'] );68 $this->assertEquals( $this->theme_root .'/default', $theme['Stylesheet Dir'] );67 $this->assertEquals( $this->theme_root . '/default', $theme['Template Dir'] ); 68 $this->assertEquals( $this->theme_root . '/default', $theme['Stylesheet Dir'] ); 69 69 $this->assertEquals( 'publish', $theme['Status'] ); 70 70 $this->assertEquals( '', $theme['Parent Theme'] ); … … 76 76 */ 77 77 function test_theme_sandbox() { 78 $theme = get_theme( 'Sandbox');79 80 $this->assertFalse( empty( $theme) );78 $theme = get_theme( 'Sandbox' ); 79 80 $this->assertFalse( empty( $theme ) ); 81 81 82 82 #echo gen_tests_array('theme', $theme); … … 92 92 $template_files = $theme['Template Files']; 93 93 94 $this->assertEquals( $this->theme_root .'/sandbox/functions.php', reset( $template_files ) );95 $this->assertEquals( $this->theme_root .'/sandbox/index.php', next( $template_files ) );94 $this->assertEquals( $this->theme_root . '/sandbox/functions.php', reset( $template_files ) ); 95 $this->assertEquals( $this->theme_root . '/sandbox/index.php', next( $template_files ) ); 96 96 97 97 $stylesheet_files = $theme['Stylesheet Files']; 98 98 99 $this->assertEquals( $this->theme_root .'/sandbox/style.css', reset( $stylesheet_files ) );100 101 $this->assertEquals( $this->theme_root .'/sandbox', $theme['Template Dir'] );102 $this->assertEquals( $this->theme_root .'/sandbox', $theme['Stylesheet Dir'] );99 $this->assertEquals( $this->theme_root . '/sandbox/style.css', reset( $stylesheet_files ) ); 100 101 $this->assertEquals( $this->theme_root . '/sandbox', $theme['Template Dir'] ); 102 $this->assertEquals( $this->theme_root . '/sandbox', $theme['Stylesheet Dir'] ); 103 103 $this->assertEquals( 'publish', $theme['Status'] ); 104 104 $this->assertEquals( '', $theme['Parent Theme'] ); … … 115 115 116 116 $theme = $themes['Stylesheet Only']; 117 $this->assertFalse( empty( $theme) );117 $this->assertFalse( empty( $theme ) ); 118 118 119 119 #echo gen_tests_array('theme', $theme); … … 126 126 $this->assertEquals( 'sandbox', $theme['Template'] ); 127 127 $this->assertEquals( 'stylesheetonly', $theme['Stylesheet'] ); 128 $this->assertContains( $this->theme_root .'/sandbox/functions.php', $theme['Template Files'] );129 $this->assertContains( $this->theme_root .'/sandbox/index.php', $theme['Template Files'] );130 131 $this->assertContains( $this->theme_root .'/stylesheetonly/style.css', $theme['Stylesheet Files']);132 133 $this->assertEquals( $this->theme_root .'/sandbox', $theme['Template Dir'] );134 $this->assertEquals( $this->theme_root .'/stylesheetonly', $theme['Stylesheet Dir'] );128 $this->assertContains( $this->theme_root . '/sandbox/functions.php', $theme['Template Files'] ); 129 $this->assertContains( $this->theme_root . '/sandbox/index.php', $theme['Template Files'] ); 130 131 $this->assertContains( $this->theme_root . '/stylesheetonly/style.css', $theme['Stylesheet Files'] ); 132 133 $this->assertEquals( $this->theme_root . '/sandbox', $theme['Template Dir'] ); 134 $this->assertEquals( $this->theme_root . '/stylesheetonly', $theme['Stylesheet Dir'] ); 135 135 $this->assertEquals( 'publish', $theme['Status'] ); 136 136 $this->assertEquals( 'Sandbox', $theme['Parent Theme'] ); … … 146 146 // Ignore themes in the default /themes directory. 147 147 foreach ( $themes as $theme_name => $theme ) { 148 if ( $theme->get_theme_root() != $this->theme_root ) 148 if ( $theme->get_theme_root() != $this->theme_root ) { 149 149 unset( $themes[ $theme_name ] ); 150 } 150 151 } 151 152 152 $theme_names = array_keys( $themes);153 $expected = array(153 $theme_names = array_keys( $themes ); 154 $expected = array( 154 155 'WordPress Default', 155 156 'Sandbox', … … 157 158 'My Theme', 158 159 'My Theme/theme1', // duplicate theme should be given a unique name 159 'My Subdir Theme', // theme in a subdirectory should work160 'Page Template Child Theme', // theme which inherits page templates160 'My Subdir Theme', // theme in a subdirectory should work 161 'Page Template Child Theme', // theme which inherits page templates 161 162 'Page Template Theme', // theme with page templates for other test code 162 163 'Theme with Spaces in the Directory', … … 165 166 ); 166 167 167 sort( $theme_names);168 sort( $expected);169 170 $this->assertEquals( $expected, $theme_names);168 sort( $theme_names ); 169 sort( $expected ); 170 171 $this->assertEquals( $expected, $theme_names ); 171 172 } 172 173 … … 176 177 */ 177 178 function test_broken_themes() { 178 $themes = get_themes();179 $themes = get_themes(); 179 180 180 181 $expected = array( … … 191 192 ); 192 193 193 $this->assertEquals( $expected, get_broken_themes() );194 $this->assertEquals( $expected, get_broken_themes() ); 194 195 } 195 196 … … 206 207 207 208 $theme = $themes['Page Template Theme']; 208 $this->assertFalse( empty( $theme) );209 $this->assertFalse( empty( $theme ) ); 209 210 210 211 $templates = $theme['Template Files']; 211 $this->assertTrue( in_array( $this->theme_root . '/page-templates/template-top-level.php', $templates ));212 $this->assertTrue( in_array( $this->theme_root . '/page-templates/template-top-level.php', $templates ) ); 212 213 } 213 214
Note: See TracChangeset
for help on using the changeset viewer.