Skip to content

Commit

Permalink
Tests: start using the new assertion and helper method
Browse files Browse the repository at this point in the history
  • Loading branch information
jrfnl committed Sep 18, 2024
1 parent 0e965d9 commit 309ce81
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion tests/phpunit/tests/admin/includesFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public function test_get_home_path() {
$home = get_option( 'home' );
$siteurl = get_option( 'siteurl' );
$sfn = $_SERVER['SCRIPT_FILENAME'];
$this->assertSame( str_replace( '\\', '/', ABSPATH ), get_home_path() );
$this->assertSamePathIgnoringDirectorySeparators( ABSPATH, get_home_path() );

update_option( 'home', 'http://localhost' );
update_option( 'siteurl', 'http://localhost/wp' );
Expand Down
4 changes: 3 additions & 1 deletion tests/phpunit/tests/block-template.php
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ public function data_get_block_theme_folders() {
* @covers ::_get_block_templates_paths
*/
public function test_get_block_templates_paths_dir_exists() {
$theme_dir = get_template_directory();
$theme_dir = $this->normalizeDirectorySeparatorsInPath( get_template_directory() );
// Templates in the current theme.
$templates = array(
'parts/small-header.html',
Expand All @@ -415,6 +415,8 @@ static function ( $template ) use ( $theme_dir ) {
);

$template_paths = _get_block_templates_paths( $theme_dir );
$template_paths = array_map( array( $this, 'normalizeDirectorySeparatorsInPath' ), _get_block_templates_paths( $theme_dir ) );

$this->assertSameSets( $expected_template_paths, $template_paths );
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public function test_should_change_directory() {
'Changing working directory failed.'
);

$this->assertSame(
$this->assertSamePathIgnoringDirectorySeparators(
$path,
$cwd_result,
'The current working directory was incorrect.'
Expand Down
4 changes: 2 additions & 2 deletions tests/phpunit/tests/theme.php
Original file line number Diff line number Diff line change
Expand Up @@ -925,7 +925,7 @@ public function test_is_child_theme_false() {
*/
public function test_get_stylesheet_directory() {
switch_theme( 'block-theme-child' );
$this->assertSame( realpath( DIR_TESTDATA ) . '/themedir1/block-theme-child', get_stylesheet_directory() );
$this->assertSamePathIgnoringDirectorySeparators( realpath( DIR_TESTDATA ) . '/themedir1/block-theme-child', get_stylesheet_directory() );
}

/**
Expand All @@ -937,7 +937,7 @@ public function test_get_stylesheet_directory() {
*/
public function test_get_template_directory() {
switch_theme( 'block-theme-child' );
$this->assertSame( realpath( DIR_TESTDATA ) . '/themedir1/block-theme', get_template_directory() );
$this->assertSamePathIgnoringDirectorySeparators( realpath( DIR_TESTDATA ) . '/themedir1/block-theme', get_template_directory() );
}

/**
Expand Down

0 comments on commit 309ce81

Please sign in to comment.