Changeset 42343 for trunk/tests/phpunit/tests/admin/includesTheme.php
- Timestamp:
- 11/30/2017 11:09:33 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/admin/includesTheme.php
r41975 r42343 9 9 $this->theme_root = DIR_TESTDATA . '/themedir1'; 10 10 11 $this->orig_theme_dir = $GLOBALS['wp_theme_directories'];11 $this->orig_theme_dir = $GLOBALS['wp_theme_directories']; 12 12 $GLOBALS['wp_theme_directories'] = array( WP_CONTENT_DIR . '/themes', $this->theme_root ); 13 13 14 add_filter( 'theme_root', array($this, '_theme_root'));15 add_filter( 'stylesheet_root', array( $this, '_theme_root') );16 add_filter( 'template_root', array( $this, '_theme_root') );14 add_filter( 'theme_root', array( $this, '_theme_root' ) ); 15 add_filter( 'stylesheet_root', array( $this, '_theme_root' ) ); 16 add_filter( 'template_root', array( $this, '_theme_root' ) ); 17 17 18 18 // clear caches … … 23 23 function tearDown() { 24 24 $GLOBALS['wp_theme_directories'] = $this->orig_theme_dir; 25 remove_filter( 'theme_root', array($this, '_theme_root'));26 remove_filter( 'stylesheet_root', array( $this, '_theme_root') );27 remove_filter( 'template_root', array( $this, '_theme_root') );25 remove_filter( 'theme_root', array( $this, '_theme_root' ) ); 26 remove_filter( 'stylesheet_root', array( $this, '_theme_root' ) ); 27 remove_filter( 'template_root', array( $this, '_theme_root' ) ); 28 28 29 29 wp_clean_themes_cache(); … … 33 33 34 34 // replace the normal theme root dir with our premade test dir 35 function _theme_root( $dir) {35 function _theme_root( $dir ) { 36 36 return $this->theme_root; 37 37 } … … 49 49 switch_theme( $theme['Template'], $theme['Stylesheet'] ); 50 50 51 $this->assertEqualSetsWithIndex( array( 52 'Top Level' => 'template-top-level.php', 53 'Sub Dir' => 'subdir/template-sub-dir.php', 54 'This Template Header Is On One Line' => 'template-header.php', 55 ), get_page_templates() ); 51 $this->assertEqualSetsWithIndex( 52 array( 53 'Top Level' => 'template-top-level.php', 54 'Sub Dir' => 'subdir/template-sub-dir.php', 55 'This Template Header Is On One Line' => 'template-header.php', 56 ), get_page_templates() 57 ); 56 58 57 59 $theme = wp_get_theme( 'page-templates' ); … … 60 62 switch_theme( $theme['Template'], $theme['Stylesheet'] ); 61 63 62 $this->assertEqualSetsWithIndex( array( 63 'Top Level' => 'template-top-level.php', 64 'Sub Dir' => 'subdir/template-sub-dir.php', 65 'This Template Header Is On One Line' => 'template-header.php', 66 ), get_page_templates() ); 64 $this->assertEqualSetsWithIndex( 65 array( 66 'Top Level' => 'template-top-level.php', 67 'Sub Dir' => 'subdir/template-sub-dir.php', 68 'This Template Header Is On One Line' => 'template-header.php', 69 ), get_page_templates() 70 ); 67 71 } 68 72 … … 76 80 switch_theme( $theme['Template'], $theme['Stylesheet'] ); 77 81 78 $this->assertEqualSetsWithIndex( array( 79 'Top Level' => 'template-top-level-post-types.php', 80 'Sub Dir' => 'subdir/template-sub-dir-post-types.php', 81 ), get_page_templates( null, 'foo' ) ); 82 $this->assertEqualSetsWithIndex( array( 83 'Top Level' => 'template-top-level-post-types.php', 84 'Sub Dir' => 'subdir/template-sub-dir-post-types.php', 85 ), get_page_templates( null, 'post' ) ); 82 $this->assertEqualSetsWithIndex( 83 array( 84 'Top Level' => 'template-top-level-post-types.php', 85 'Sub Dir' => 'subdir/template-sub-dir-post-types.php', 86 ), get_page_templates( null, 'foo' ) 87 ); 88 $this->assertEqualSetsWithIndex( 89 array( 90 'Top Level' => 'template-top-level-post-types.php', 91 'Sub Dir' => 'subdir/template-sub-dir-post-types.php', 92 ), get_page_templates( null, 'post' ) 93 ); 86 94 $this->assertEquals( array(), get_page_templates( null, 'bar' ) ); 87 95 } … … 96 104 switch_theme( $theme['Template'], $theme['Stylesheet'] ); 97 105 98 $this->assertEqualSetsWithIndex( array( 99 'No Trailing Period' => '38766/no-trailing-period-post-types.php', 100 'Trailing Period.' => '38766/trailing-period-post-types.php', 101 'Trailing Comma,' => '38766/trailing-comma-post-types.php', 102 'Trailing Period, White Space.' => '38766/trailing-period-whitespace-post-types.php', 103 'Trailing White Space, Period.' => '38766/trailing-whitespace-period-post-types.php', 104 'Tilde in Post Type.' => '38766/tilde-post-types.php', 105 ), get_page_templates( null, 'period' ) ); 106 $this->assertEqualSetsWithIndex( array( 107 'No Trailing Period' => '38766/no-trailing-period-post-types.php', 108 'Trailing Period.' => '38766/trailing-period-post-types.php', 109 'Trailing Comma,' => '38766/trailing-comma-post-types.php', 110 'Trailing Period, White Space.' => '38766/trailing-period-whitespace-post-types.php', 111 'Trailing White Space, Period.' => '38766/trailing-whitespace-period-post-types.php', 112 ), get_page_templates( null, 'full-stop' ) ); 106 $this->assertEqualSetsWithIndex( 107 array( 108 'No Trailing Period' => '38766/no-trailing-period-post-types.php', 109 'Trailing Period.' => '38766/trailing-period-post-types.php', 110 'Trailing Comma,' => '38766/trailing-comma-post-types.php', 111 'Trailing Period, White Space.' => '38766/trailing-period-whitespace-post-types.php', 112 'Trailing White Space, Period.' => '38766/trailing-whitespace-period-post-types.php', 113 'Tilde in Post Type.' => '38766/tilde-post-types.php', 114 ), get_page_templates( null, 'period' ) 115 ); 116 $this->assertEqualSetsWithIndex( 117 array( 118 'No Trailing Period' => '38766/no-trailing-period-post-types.php', 119 'Trailing Period.' => '38766/trailing-period-post-types.php', 120 'Trailing Comma,' => '38766/trailing-comma-post-types.php', 121 'Trailing Period, White Space.' => '38766/trailing-period-whitespace-post-types.php', 122 'Trailing White Space, Period.' => '38766/trailing-whitespace-period-post-types.php', 123 ), get_page_templates( null, 'full-stop' ) 124 ); 113 125 } 114 126 … … 122 134 switch_theme( $theme['Template'], $theme['Stylesheet'] ); 123 135 124 $this->assertEqualSetsWithIndex( array( 125 'Top Level' => 'template-top-level-post-types.php', 126 'Sub Dir' => 'subdir/template-sub-dir-post-types.php', 127 'Top Level In A Child Theme' => 'template-top-level-post-types-child.php', 128 'Sub Dir In A Child Theme' => 'subdir/template-sub-dir-post-types-child.php', 129 ), get_page_templates( null, 'foo' ) ); 130 131 $this->assertEqualSetsWithIndex( array( 132 'Top Level' => 'template-top-level-post-types.php', 133 'Sub Dir' => 'subdir/template-sub-dir-post-types.php', 134 ), get_page_templates( null, 'post' ) ); 135 136 $this->assertEqualSetsWithIndex( array( 137 'Top Level' => 'template-top-level.php', 138 'Sub Dir' => 'subdir/template-sub-dir.php', 139 'This Template Header Is On One Line' => 'template-header.php', 140 ), get_page_templates() ); 136 $this->assertEqualSetsWithIndex( 137 array( 138 'Top Level' => 'template-top-level-post-types.php', 139 'Sub Dir' => 'subdir/template-sub-dir-post-types.php', 140 'Top Level In A Child Theme' => 'template-top-level-post-types-child.php', 141 'Sub Dir In A Child Theme' => 'subdir/template-sub-dir-post-types-child.php', 142 ), get_page_templates( null, 'foo' ) 143 ); 144 145 $this->assertEqualSetsWithIndex( 146 array( 147 'Top Level' => 'template-top-level-post-types.php', 148 'Sub Dir' => 'subdir/template-sub-dir-post-types.php', 149 ), get_page_templates( null, 'post' ) 150 ); 151 152 $this->assertEqualSetsWithIndex( 153 array( 154 'Top Level' => 'template-top-level.php', 155 'Sub Dir' => 'subdir/template-sub-dir.php', 156 'This Template Header Is On One Line' => 'template-header.php', 157 ), get_page_templates() 158 ); 141 159 142 160 $this->assertEquals( array(), get_page_templates( null, 'bar' ) ); … … 154 172 $post_templates = $theme->get_post_templates(); 155 173 156 $this->assertEqualSetsWithIndex( array( 157 'template-top-level-post-types.php' => 'Top Level', 158 'subdir/template-sub-dir-post-types.php' => 'Sub Dir', 159 'template-top-level-post-types-child.php' => 'Top Level In A Child Theme', 160 'subdir/template-sub-dir-post-types-child.php' => 'Sub Dir In A Child Theme', 161 ), $post_templates['foo'] ); 162 163 $this->assertEqualSetsWithIndex( array( 164 'template-top-level-post-types.php' => 'Top Level', 165 'subdir/template-sub-dir-post-types.php' => 'Sub Dir', 166 ), $post_templates['post'] ); 167 168 $this->assertEqualSetsWithIndex( array( 169 'template-top-level.php' => 'Top Level', 170 'subdir/template-sub-dir.php' => 'Sub Dir', 171 'template-header.php' => 'This Template Header Is On One Line', 172 ), $post_templates['page'] ); 174 $this->assertEqualSetsWithIndex( 175 array( 176 'template-top-level-post-types.php' => 'Top Level', 177 'subdir/template-sub-dir-post-types.php' => 'Sub Dir', 178 'template-top-level-post-types-child.php' => 'Top Level In A Child Theme', 179 'subdir/template-sub-dir-post-types-child.php' => 'Sub Dir In A Child Theme', 180 ), $post_templates['foo'] 181 ); 182 183 $this->assertEqualSetsWithIndex( 184 array( 185 'template-top-level-post-types.php' => 'Top Level', 186 'subdir/template-sub-dir-post-types.php' => 'Sub Dir', 187 ), $post_templates['post'] 188 ); 189 190 $this->assertEqualSetsWithIndex( 191 array( 192 'template-top-level.php' => 'Top Level', 193 'subdir/template-sub-dir.php' => 'Sub Dir', 194 'template-header.php' => 'This Template Header Is On One Line', 195 ), $post_templates['page'] 196 ); 173 197 } 174 198
Note: See TracChangeset
for help on using the changeset viewer.