Skip to content

Commit 475c6f3

Browse files
Tests: Clean up file destination in _unzip_file_*() unit tests.
This ensures clean environment in case of a previous test failure. Follow-up to [56689]. Props aslamdoctor, wildworks, peterwilsoncc, SirLouen, mindctrl, kalpeshh, yashjawale, sachinrajcp123, SergeyBiryukov. Fixes #63443. git-svn-id: https://develop.svn.wordpress.org/trunk@61212 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 507fd54 commit 475c6f3

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

tests/phpunit/tests/filesystem/unzipFilePclzip.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,15 @@ public function test_should_apply_pre_unzip_file_filters() {
4141

4242
// Prepare test environment.
4343
$unzip_destination = self::$test_data_dir . 'archive/';
44+
if ( file_exists( $unzip_destination ) ) {
45+
$this->rmdir( $unzip_destination );
46+
$this->delete_folders( $unzip_destination );
47+
}
4448
mkdir( $unzip_destination );
4549

4650
_unzip_file_pclzip( self::$test_data_dir . 'archive.zip', $unzip_destination );
4751

48-
// Cleanup test environment.
52+
// Clean up test environment.
4953
$this->rmdir( $unzip_destination );
5054
$this->delete_folders( $unzip_destination );
5155

@@ -63,11 +67,15 @@ public function test_should_apply_unzip_file_filters() {
6367

6468
// Prepare test environment.
6569
$unzip_destination = self::$test_data_dir . 'archive/';
70+
if ( file_exists( $unzip_destination ) ) {
71+
$this->rmdir( $unzip_destination );
72+
$this->delete_folders( $unzip_destination );
73+
}
6674
mkdir( $unzip_destination );
6775

6876
_unzip_file_pclzip( self::$test_data_dir . 'archive.zip', $unzip_destination );
6977

70-
// Cleanup test environment.
78+
// Clean up test environment.
7179
$this->rmdir( $unzip_destination );
7280
$this->delete_folders( $unzip_destination );
7381

tests/phpunit/tests/filesystem/unzipFileZiparchive.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,15 @@ public function test_should_apply_pre_unzip_file_filters() {
4545

4646
// Prepare test environment.
4747
$unzip_destination = self::$test_data_dir . 'archive/';
48+
if ( file_exists( $unzip_destination ) ) {
49+
$this->rmdir( $unzip_destination );
50+
$this->delete_folders( $unzip_destination );
51+
}
4852
mkdir( $unzip_destination );
4953

5054
_unzip_file_ziparchive( self::$test_data_dir . 'archive.zip', $unzip_destination );
5155

52-
// Cleanup test environment.
56+
// Clean up test environment.
5357
$this->rmdir( $unzip_destination );
5458
$this->delete_folders( $unzip_destination );
5559

@@ -71,11 +75,15 @@ public function test_should_apply_unzip_file_filters() {
7175

7276
// Prepare test environment.
7377
$unzip_destination = self::$test_data_dir . 'archive/';
78+
if ( file_exists( $unzip_destination ) ) {
79+
$this->rmdir( $unzip_destination );
80+
$this->delete_folders( $unzip_destination );
81+
}
7482
mkdir( $unzip_destination );
7583

7684
_unzip_file_ziparchive( self::$test_data_dir . 'archive.zip', $unzip_destination );
7785

78-
// Cleanup test environment.
86+
// Clean up test environment.
7987
$this->rmdir( $unzip_destination );
8088
$this->delete_folders( $unzip_destination );
8189

0 commit comments

Comments
 (0)