Skip to content

Commit f9f19c7

Browse files
Tests: Use file paths independent of OS-specifics assertion or helper.
Use `WP_UnitTestCase_Base::assertSamePathIgnoringDirectorySeparators()` and `WP_UnitTestCase_Base::normalizeDirectorySeparatorsInPath()` in existing tests. Follow-up to [59057], [57753], [57215], [56635], [48937], [25002]. Props jrf. See #61530. git-svn-id: https://develop.svn.wordpress.org/trunk@59061 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 5168e19 commit f9f19c7

File tree

4 files changed

+7
-5
lines changed

4 files changed

+7
-5
lines changed

tests/phpunit/tests/admin/includesFile.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public function test_get_home_path() {
1515
$home = get_option( 'home' );
1616
$siteurl = get_option( 'siteurl' );
1717
$sfn = $_SERVER['SCRIPT_FILENAME'];
18-
$this->assertSame( str_replace( '\\', '/', ABSPATH ), get_home_path() );
18+
$this->assertSamePathIgnoringDirectorySeparators( ABSPATH, get_home_path() );
1919

2020
update_option( 'home', 'http://localhost' );
2121
update_option( 'siteurl', 'http://localhost/wp' );

tests/phpunit/tests/block-template.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ public function data_get_block_theme_folders() {
395395
* @covers ::_get_block_templates_paths
396396
*/
397397
public function test_get_block_templates_paths_dir_exists() {
398-
$theme_dir = get_template_directory();
398+
$theme_dir = $this->normalizeDirectorySeparatorsInPath( get_template_directory() );
399399
// Templates in the current theme.
400400
$templates = array(
401401
'parts/small-header.html',
@@ -415,6 +415,8 @@ static function ( $template ) use ( $theme_dir ) {
415415
);
416416

417417
$template_paths = _get_block_templates_paths( $theme_dir );
418+
$template_paths = array_map( array( $this, 'normalizeDirectorySeparatorsInPath' ), _get_block_templates_paths( $theme_dir ) );
419+
418420
$this->assertSameSets( $expected_template_paths, $template_paths );
419421
}
420422

tests/phpunit/tests/filesystem/wpFilesystemDirect/chdir.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public function test_should_change_directory() {
8686
'Changing working directory failed.'
8787
);
8888

89-
$this->assertSame(
89+
$this->assertSamePathIgnoringDirectorySeparators(
9090
$path,
9191
$cwd_result,
9292
'The current working directory was incorrect.'

tests/phpunit/tests/theme.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -925,7 +925,7 @@ public function test_is_child_theme_false() {
925925
*/
926926
public function test_get_stylesheet_directory() {
927927
switch_theme( 'block-theme-child' );
928-
$this->assertSame( realpath( DIR_TESTDATA ) . '/themedir1/block-theme-child', get_stylesheet_directory() );
928+
$this->assertSamePathIgnoringDirectorySeparators( realpath( DIR_TESTDATA ) . '/themedir1/block-theme-child', get_stylesheet_directory() );
929929
}
930930

931931
/**
@@ -937,7 +937,7 @@ public function test_get_stylesheet_directory() {
937937
*/
938938
public function test_get_template_directory() {
939939
switch_theme( 'block-theme-child' );
940-
$this->assertSame( realpath( DIR_TESTDATA ) . '/themedir1/block-theme', get_template_directory() );
940+
$this->assertSamePathIgnoringDirectorySeparators( realpath( DIR_TESTDATA ) . '/themedir1/block-theme', get_template_directory() );
941941
}
942942

943943
/**

0 commit comments

Comments
 (0)