From 52eb3fbe3a35aac5abae3ec21fc7f8d8ce66163c Mon Sep 17 00:00:00 2001 From: John Blackbourn Date: Mon, 25 Mar 2019 17:07:12 +0000 Subject: [PATCH] Build/Test tools: Backport the fixed tests for `wp_normalize_path()` from the 4.5 branch into 4.4. See #35996 git-svn-id: https://develop.svn.wordpress.org/branches/4.4@45012 602fd350-edb4-49c9-b593-d223f7449a82 --- tests/phpunit/tests/functions.php | 40 +++++++++++++++++-------------- 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/tests/phpunit/tests/functions.php b/tests/phpunit/tests/functions.php index 631b303e70..eb94d70e4b 100644 --- a/tests/phpunit/tests/functions.php +++ b/tests/phpunit/tests/functions.php @@ -115,26 +115,30 @@ class Tests_Functions extends WP_UnitTestCase { /** * @ticket 33265 + * @ticket 35996 + * + * @dataProvider data_wp_normalize_path */ - function test_wp_normalize_path() { - $paths = array( - '/WINDOWS' => '/WINDOWS', - 'C:/' => 'C:/', - 'C:/WINDOWS' => 'C:/WINDOWS', - 'C:/WINDOWS/system32' => 'C:/WINDOWS/system32', - '\\WINDOWS' => '/WINDOWS', - 'C:\\' => 'C:/', - 'C:\\WINDOWS' => 'C:/WINDOWS', - 'C:\\\\WINDOWS' => 'C:/WINDOWS', - 'C:\\WINDOWS\\system32' => 'C:/WINDOWS/system32', - '\\\\sambashare\\foo' => '/sambashare/foo', - 'c:/windows' => 'C:/windows', - 'c:\\windows' => 'C:/windows', - ); + function test_wp_normalize_path( $path, $expected ) { + $this->assertEquals( $expected, wp_normalize_path( $path ) ); + } + function data_wp_normalize_path() { + return array( + // Windows paths + array( 'C:\\www\\path\\', 'C:/www/path/' ), + array( 'C:\\www\\\\path\\', 'C:/www/path/' ), + array( 'c:/www/path', 'C:/www/path' ), + array( 'c:\\www\\path\\', 'C:/www/path/' ), // uppercase drive letter + array( 'c:\\\\www\\path\\', 'C:/www/path/' ), + array( '\\\\Domain\\DFSRoots\\share\\path\\', '//Domain/DFSRoots/share/path/' ), + array( '\\\\Server\\share\\path', '//Server/share/path' ), + array( '\\\\Server\\share', '//Server/share' ), - foreach ($paths as $original => $expected) { - $this->assertEquals( $expected, wp_normalize_path( $original ) ); - } + // Linux paths + array( '/www/path/', '/www/path/' ), + array( '/www/path/////', '/www/path/' ), + array( '/www/path', '/www/path' ), + ); } function test_wp_unique_filename() {