Make WordPress Core

Changeset 59061


Ignore:
Timestamp:
09/18/2024 09:04:48 PM (17 months ago)
Author:
hellofromTonya
Message:

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.

Location:
trunk/tests/phpunit/tests
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/admin/includesFile.php

    r58208 r59061  
    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' );
  • trunk/tests/phpunit/tests/block-template.php

    r58323 r59061  
    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(
     
    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    }
  • trunk/tests/phpunit/tests/filesystem/wpFilesystemDirect/chdir.php

    r57753 r59061  
    8787        );
    8888
    89         $this->assertSame(
     89        $this->assertSamePathIgnoringDirectorySeparators(
    9090            $path,
    9191            $cwd_result,
  • trunk/tests/phpunit/tests/theme.php

    r59054 r59061  
    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
     
    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
Note: See TracChangeset for help on using the changeset viewer.