Changeset 53916
- Timestamp:
- 08/21/2022 04:55:18 PM (2 years ago)
- Location:
- trunk/tests/phpunit/tests
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/admin/includesTheme.php
r52010 r53916 5 5 class Tests_Admin_IncludesTheme extends WP_UnitTestCase { 6 6 7 /** 8 * Theme root directory. 9 * 10 * @var string 11 */ 12 const THEME_ROOT = DIR_TESTDATA . '/themedir1'; 13 14 /** 15 * Original theme directory. 16 * 17 * @var string 18 */ 19 private $orig_theme_dir; 20 7 21 public function set_up() { 8 22 parent::set_up(); 9 $this->theme_root = DIR_TESTDATA . '/themedir1';10 23 11 24 $this->orig_theme_dir = $GLOBALS['wp_theme_directories']; 12 $GLOBALS['wp_theme_directories'] = array( WP_CONTENT_DIR . '/themes', $this->theme_root);25 $GLOBALS['wp_theme_directories'] = array( WP_CONTENT_DIR . '/themes', self::THEME_ROOT ); 13 26 14 27 add_filter( 'theme_root', array( $this, 'filter_theme_root' ) ); … … 34 47 // Replace the normal theme root directory with our premade test directory. 35 48 public function filter_theme_root( $dir ) { 36 return $this->theme_root;49 return self::THEME_ROOT; 37 50 } 38 51 -
trunk/tests/phpunit/tests/block-supports/layout.php
r53680 r53916 18 18 */ 19 19 class Test_Block_Supports_Layout extends WP_UnitTestCase { 20 21 /** 22 * Theme root directory. 23 * 24 * @var string 25 */ 26 private $theme_root; 27 28 /** 29 * Original theme directory. 30 * 31 * @var string 32 */ 33 private $orig_theme_dir; 34 20 35 function set_up() { 21 36 parent::set_up(); … … 31 46 add_filter( 'template_root', array( $this, 'filter_set_theme_root' ) ); 32 47 33 $this->queries = array();34 48 // Clear caches. 35 49 wp_clean_themes_cache(); -
trunk/tests/phpunit/tests/theme/themeDir.php
r53874 r53916 8 8 class Tests_Theme_ThemeDir extends WP_UnitTestCase { 9 9 10 /** 11 * Theme root directory. 12 * 13 * @var string 14 */ 15 const THEME_ROOT = DIR_TESTDATA . '/themedir1'; 16 17 /** 18 * Original theme directory. 19 * 20 * @var string 21 */ 22 private $orig_theme_dir; 23 10 24 public function set_up() { 11 25 parent::set_up(); 12 $this->theme_root = DIR_TESTDATA . '/themedir1';13 26 14 27 $this->orig_theme_dir = $GLOBALS['wp_theme_directories']; 15 28 16 29 // /themes is necessary as theme.php functions assume /themes is the root if there is only one root. 17 $GLOBALS['wp_theme_directories'] = array( WP_CONTENT_DIR . '/themes', $this->theme_root);30 $GLOBALS['wp_theme_directories'] = array( WP_CONTENT_DIR . '/themes', self::THEME_ROOT ); 18 31 19 32 add_filter( 'theme_root', array( $this, 'filter_theme_root' ) ); … … 34 47 // Replace the normal theme root directory with our premade test directory. 35 48 public function filter_theme_root( $dir ) { 36 return $this->theme_root;49 return self::THEME_ROOT; 37 50 } 38 51 … … 58 71 $this->assertSame( 'default', $theme['Stylesheet'] ); 59 72 60 $this->assertContains( $this->theme_root. '/default/functions.php', $theme['Template Files'] );61 $this->assertContains( $this->theme_root. '/default/index.php', $theme['Template Files'] );62 $this->assertContains( $this->theme_root. '/default/style.css', $theme['Stylesheet Files'] );63 64 $this->assertSame( $this->theme_root. '/default', $theme['Template Dir'] );65 $this->assertSame( $this->theme_root. '/default', $theme['Stylesheet Dir'] );73 $this->assertContains( self::THEME_ROOT . '/default/functions.php', $theme['Template Files'] ); 74 $this->assertContains( self::THEME_ROOT . '/default/index.php', $theme['Template Files'] ); 75 $this->assertContains( self::THEME_ROOT . '/default/style.css', $theme['Stylesheet Files'] ); 76 77 $this->assertSame( self::THEME_ROOT . '/default', $theme['Template Dir'] ); 78 $this->assertSame( self::THEME_ROOT . '/default', $theme['Stylesheet Dir'] ); 66 79 $this->assertSame( 'publish', $theme['Status'] ); 67 80 $this->assertSame( '', $theme['Parent Theme'] ); … … 89 102 $template_files = $theme['Template Files']; 90 103 91 $this->assertSame( $this->theme_root. '/sandbox/functions.php', reset( $template_files ) );92 $this->assertSame( $this->theme_root. '/sandbox/index.php', next( $template_files ) );104 $this->assertSame( self::THEME_ROOT . '/sandbox/functions.php', reset( $template_files ) ); 105 $this->assertSame( self::THEME_ROOT . '/sandbox/index.php', next( $template_files ) ); 93 106 94 107 $stylesheet_files = $theme['Stylesheet Files']; 95 108 96 $this->assertSame( $this->theme_root. '/sandbox/style.css', reset( $stylesheet_files ) );97 98 $this->assertSame( $this->theme_root. '/sandbox', $theme['Template Dir'] );99 $this->assertSame( $this->theme_root. '/sandbox', $theme['Stylesheet Dir'] );109 $this->assertSame( self::THEME_ROOT . '/sandbox/style.css', reset( $stylesheet_files ) ); 110 111 $this->assertSame( self::THEME_ROOT . '/sandbox', $theme['Template Dir'] ); 112 $this->assertSame( self::THEME_ROOT . '/sandbox', $theme['Stylesheet Dir'] ); 100 113 $this->assertSame( 'publish', $theme['Status'] ); 101 114 $this->assertSame( '', $theme['Parent Theme'] ); … … 123 136 $this->assertSame( 'sandbox', $theme['Template'] ); 124 137 $this->assertSame( 'stylesheetonly', $theme['Stylesheet'] ); 125 $this->assertContains( $this->theme_root. '/sandbox/functions.php', $theme['Template Files'] );126 $this->assertContains( $this->theme_root. '/sandbox/index.php', $theme['Template Files'] );127 128 $this->assertContains( $this->theme_root. '/stylesheetonly/style.css', $theme['Stylesheet Files'] );129 130 $this->assertSame( $this->theme_root. '/sandbox', $theme['Template Dir'] );131 $this->assertSame( $this->theme_root. '/stylesheetonly', $theme['Stylesheet Dir'] );138 $this->assertContains( self::THEME_ROOT . '/sandbox/functions.php', $theme['Template Files'] ); 139 $this->assertContains( self::THEME_ROOT . '/sandbox/index.php', $theme['Template Files'] ); 140 141 $this->assertContains( self::THEME_ROOT . '/stylesheetonly/style.css', $theme['Stylesheet Files'] ); 142 143 $this->assertSame( self::THEME_ROOT . '/sandbox', $theme['Template Dir'] ); 144 $this->assertSame( self::THEME_ROOT . '/stylesheetonly', $theme['Stylesheet Dir'] ); 132 145 $this->assertSame( 'publish', $theme['Status'] ); 133 146 $this->assertSame( 'Sandbox', $theme['Parent Theme'] ); … … 143 156 // Ignore themes in the default /themes directory. 144 157 foreach ( $themes as $theme_name => $theme ) { 145 if ( $theme->get_theme_root() !== $this->theme_root) {158 if ( $theme->get_theme_root() !== self::THEME_ROOT ) { 146 159 unset( $themes[ $theme_name ] ); 147 160 } … … 199 212 200 213 public function test_wp_get_theme_with_non_default_theme_root() { 201 $this->assertFalse( wp_get_theme( 'sandbox', $this->theme_root)->errors() );214 $this->assertFalse( wp_get_theme( 'sandbox', self::THEME_ROOT )->errors() ); 202 215 $this->assertFalse( wp_get_theme( 'sandbox' )->errors() ); 203 216 } … … 213 226 214 227 $templates = $theme['Template Files']; 215 $this->assertContains( $this->theme_root. '/page-templates/template-top-level.php', $templates );228 $this->assertContains( self::THEME_ROOT . '/page-templates/template-top-level.php', $templates ); 216 229 } 217 230 … … 239 252 */ 240 253 public function test_get_theme_data_subdir() { 241 $theme_data = get_theme_data( $this->theme_root. '/subdir/theme2/style.css' );254 $theme_data = get_theme_data( self::THEME_ROOT . '/subdir/theme2/style.css' ); 242 255 243 256 $this->assertSame( 'My Subdir Theme', $theme_data['Name'] ); -
trunk/tests/phpunit/tests/theme/wpGetGlobalStylesheet.php
r52682 r53916 8 8 class Tests_Theme_wpGetGlobalStylesheet extends WP_UnitTestCase { 9 9 10 /** 11 * Theme root directory. 12 * 13 * @var string 14 */ 15 private $theme_root; 16 17 /** 18 * Original theme directory. 19 * 20 * @var string 21 */ 22 private $orig_theme_dir; 23 10 24 public function set_up() { 11 25 parent::set_up(); -
trunk/tests/phpunit/tests/theme/wpTheme.php
r53416 r53916 10 10 */ 11 11 class Tests_Theme_wpTheme extends WP_UnitTestCase { 12 13 /** 14 * Theme root directory. 15 * 16 * @var string 17 */ 18 private $theme_root; 19 20 /** 21 * Original theme directory. 22 * 23 * @var string 24 */ 25 private $orig_theme_dir; 12 26 13 27 public function set_up() { -
trunk/tests/phpunit/tests/theme/wpThemeJsonResolver.php
r52372 r53916 13 13 class Tests_Theme_wpThemeJsonResolver extends WP_UnitTestCase { 14 14 15 /** 16 * Theme root directory. 17 * 18 * @var string 19 */ 20 private $theme_root; 21 22 /** 23 * Original theme directory. 24 * 25 * @var string 26 */ 27 private $orig_theme_dir; 28 29 /** 30 * Queries. 31 * 32 * @var array 33 */ 34 private $queries = array(); 35 15 36 public function set_up() { 16 37 parent::set_up();
Note: See TracChangeset
for help on using the changeset viewer.