Skip to content

Commit 9057bde

Browse files
committed
normalize slashes & mac paths
1 parent 0288e88 commit 9057bde

1 file changed

Lines changed: 7 additions & 9 deletions

File tree

tests/phpunit/ComposerJsonTest.php

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public function test_create_default_composer_json() {
8585
// Succeed.
8686
$expected = $this->temp_dir . 'packages/composer.json';
8787
$actual = $create_default_composer_json->invoke( $package, $expected );
88-
$this->assertSame( $expected, $this->mac_safe_path( $actual ) );
88+
$this->assertSame( $this->mac_safe_path( realpath( $expected ) ?: $expected ), $this->mac_safe_path( realpath( $actual ) ?: $actual ) );
8989
$this->assertTrue( false !== strpos( file_get_contents( $actual ), 'wp-cli/wp-cli' ) );
9090
unlink( $actual );
9191
rmdir( dirname( $actual ) );
@@ -110,7 +110,7 @@ public function test_get_composer_json_path() {
110110
putenv( 'WP_CLI_PACKAGES_DIR' );
111111
$expected = $this->temp_dir . '.wp-cli/packages/composer.json';
112112
$actual = $get_composer_json_path->invoke( $package );
113-
$this->assertSame( $expected, $this->mac_safe_path( $actual ) );
113+
$this->assertSame( $this->mac_safe_path( realpath( $expected ) ?: $expected ), $this->mac_safe_path( realpath( $actual ) ?: $actual ) );
114114
$this->assertTrue( false !== strpos( file_get_contents( $actual ), 'wp-cli/wp-cli' ) );
115115
unlink( $actual );
116116
rmdir( dirname( $actual ) );
@@ -120,7 +120,7 @@ public function test_get_composer_json_path() {
120120
putenv( 'WP_CLI_PACKAGES_DIR=' . $this->temp_dir . 'packages' );
121121
$expected = $this->temp_dir . 'packages/composer.json';
122122
$actual = $get_composer_json_path->invoke( $package );
123-
$this->assertSame( $expected, $this->mac_safe_path( $actual ) );
123+
$this->assertSame( $this->mac_safe_path( realpath( $expected ) ?: $expected ), $this->mac_safe_path( realpath( $actual ) ?: $actual ) );
124124
$this->assertTrue( false !== strpos( file_get_contents( $actual ), 'wp-cli/wp-cli' ) );
125125
unlink( $actual );
126126
rmdir( dirname( $actual ) );
@@ -131,7 +131,7 @@ public function test_get_composer_json_path() {
131131
mkdir( $this->temp_dir . 'packages' );
132132
touch( $expected );
133133
$actual = $get_composer_json_path->invoke( $package );
134-
$this->assertSame( $expected, $this->mac_safe_path( $actual ) );
134+
$this->assertSame( $this->mac_safe_path( realpath( $expected ) ?: $expected ), $this->mac_safe_path( realpath( $actual ) ?: $actual ) );
135135
$this->assertSame( 0, filesize( $actual ) );
136136
unlink( $actual );
137137
rmdir( dirname( $actual ) );
@@ -175,7 +175,7 @@ public function test_get_composer_json_path_backup_decoded() {
175175
// Succeed with newly created.
176176
$expected = $this->temp_dir . 'packages/composer.json';
177177
list( $actual, $content, $decoded ) = $get_composer_json_path_backup_decoded->invoke( $package );
178-
$this->assertSame( $expected, $this->mac_safe_path( $actual ) );
178+
$this->assertSame( $this->mac_safe_path( realpath( $expected ) ?: $expected ), $this->mac_safe_path( realpath( $actual ) ?: $actual ) );
179179
$this->assertTrue( false !== strpos( file_get_contents( $actual ), 'wp-cli/wp-cli' ) );
180180
$this->assertSame( file_get_contents( $actual ), $content );
181181
$this->assertFalse( empty( $decoded ) );
@@ -187,7 +187,7 @@ public function test_get_composer_json_path_backup_decoded() {
187187
mkdir( $this->temp_dir . 'packages' );
188188
file_put_contents( $expected, '{}' );
189189
list( $actual, $content, $decoded ) = $get_composer_json_path_backup_decoded->invoke( $package );
190-
$this->assertSame( $expected, $this->mac_safe_path( $actual ) );
190+
$this->assertSame( $this->mac_safe_path( realpath( $expected ) ?: $expected ), $this->mac_safe_path( realpath( $actual ) ?: $actual ) );
191191
$this->assertSame( '{}', $content );
192192
$this->assertTrue( empty( $decoded ) );
193193
unlink( $expected );
@@ -199,9 +199,7 @@ public function test_get_composer_json_path_backup_decoded() {
199199

200200
private function mac_safe_path( $path ) {
201201
$path = preg_replace( '#^/private/(var|tmp)/#i', '/$1/', $path );
202-
if ( Utils\is_windows() ) {
203-
$path = str_replace( '\\', '/', $path );
204-
}
202+
$path = str_replace( '\\', '/', $path );
205203
return $path;
206204
}
207205
}

0 commit comments

Comments
 (0)