Skip to content

Commit 29d678d

Browse files
Tests: Replace assertFileNotExists() with assertFileDoesNotExist().
The `assertFileNotExists()` method was hard deprecated in PHPUnit 9.1 and the functionality will be removed in PHPUnit 10.0. The `assertFileDoesNotExist()` method was introduced as a replacement in PHPUnit 9.1. This new PHPUnit method is polyfilled by the PHPUnit Polyfills and switching to it will future-proof the tests some more. References: * https://github.com/sebastianbergmann/phpunit/blob/9.1.5/ChangeLog-9.1.md#910---2020-04-03 * sebastianbergmann/phpunit#4076 Follow-up to [51559-51563]. Props jrf. See #46149. git-svn-id: https://develop.svn.wordpress.org/trunk@51564 602fd350-edb4-49c9-b593-d223f7449a82
1 parent fe7295b commit 29d678d

File tree

8 files changed

+11
-11
lines changed

8 files changed

+11
-11
lines changed

tests/phpunit/tests/admin/includesPlugin.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ public function test_get_mu_plugins_when_mu_plugins_exists_but_is_empty() {
403403
* @covers ::get_mu_plugins
404404
*/
405405
public function test_get_mu_plugins_when_mu_plugins_directory_does_not_exist() {
406-
$this->assertFileNotExists( WPMU_PLUGIN_DIR );
406+
$this->assertFileDoesNotExist( WPMU_PLUGIN_DIR );
407407
$this->assertSame( array(), get_mu_plugins() );
408408
}
409409

tests/phpunit/tests/ajax/MediaEdit.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public function testImageEditOverwriteConstant() {
9696
}
9797

9898
foreach ( $files_that_shouldnt_exist as $file ) {
99-
$this->assertFileNotExists( $file, 'IMAGE_EDIT_OVERWRITE is leaving garbage image files behind.' );
99+
$this->assertFileDoesNotExist( $file, 'IMAGE_EDIT_OVERWRITE is leaving garbage image files behind.' );
100100
}
101101
}
102102
}

tests/phpunit/tests/functions.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ function test_wp_unique_filename() {
173173
// Check number is appended for file already exists.
174174
$this->assertFileExists( $testdir . 'test-image.png', 'Test image does not exist' );
175175
$this->assertSame( 'test-image-1.png', wp_unique_filename( $testdir, 'test-image.png' ), 'Number not appended correctly' );
176-
$this->assertFileNotExists( $testdir . 'test-image-1.png' );
176+
$this->assertFileDoesNotExist( $testdir . 'test-image-1.png' );
177177

178178
// Check special chars.
179179
$this->assertSame( 'testtest-image.png', wp_unique_filename( $testdir, 'testtést-imagé.png' ), 'Filename with special chars failed' );

tests/phpunit/tests/image/editorImagick.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -607,7 +607,7 @@ public function test_directory_creation() {
607607
$directory = realpath( DIR_TESTDATA ) . '/images/nonexistent-directory';
608608
$editor = new WP_Image_Editor_Imagick( $file );
609609

610-
$this->assertFileNotExists( $directory );
610+
$this->assertFileDoesNotExist( $directory );
611611

612612
$loaded = $editor->load();
613613
$this->assertNotWPError( $loaded );

tests/phpunit/tests/link/themeFile.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,13 +121,13 @@ public function test_theme_file_existance( $file, $expected_theme, $existence )
121121
if ( in_array( 'theme-file-child', $existence, true ) ) {
122122
$this->assertFileExists( WP_CONTENT_DIR . "/themes/theme-file-child/{$file}" );
123123
} else {
124-
$this->assertFileNotExists( WP_CONTENT_DIR . "/themes/theme-file-child/{$file}" );
124+
$this->assertFileDoesNotExist( WP_CONTENT_DIR . "/themes/theme-file-child/{$file}" );
125125
}
126126

127127
if ( in_array( 'theme-file-parent', $existence, true ) ) {
128128
$this->assertFileExists( WP_CONTENT_DIR . "/themes/theme-file-parent/{$file}" );
129129
} else {
130-
$this->assertFileNotExists( WP_CONTENT_DIR . "/themes/theme-file-parent/{$file}" );
130+
$this->assertFileDoesNotExist( WP_CONTENT_DIR . "/themes/theme-file-parent/{$file}" );
131131
}
132132

133133
}

tests/phpunit/tests/multisite/ms-files-rewriting.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,13 @@ function test_upload_directories_after_multiple_wpmu_delete_blog_with_ms_files()
7676

7777
// The file on the main site should still exist. The file on the deleted site should not.
7878
$this->assertFileExists( $file1['file'] );
79-
$this->assertFileNotExists( $file2['file'] );
79+
$this->assertFileDoesNotExist( $file2['file'] );
8080

8181
wpmu_delete_blog( $blog_id, true );
8282

8383
// The file on the main site should still exist. The file on the deleted site should not.
8484
$this->assertFileExists( $file1['file'] );
85-
$this->assertFileNotExists( $file2['file'] );
85+
$this->assertFileDoesNotExist( $file2['file'] );
8686
}
8787
}
8888

tests/phpunit/tests/multisite/site.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -391,13 +391,13 @@ function test_upload_directories_after_multiple_wpmu_delete_blog() {
391391

392392
// The file on the main site should still exist. The file on the deleted site should not.
393393
$this->assertFileExists( $file1['file'] );
394-
$this->assertFileNotExists( $file2['file'] );
394+
$this->assertFileDoesNotExist( $file2['file'] );
395395

396396
wpmu_delete_blog( $blog_id, true );
397397

398398
// The file on the main site should still exist. The file on the deleted site should not.
399399
$this->assertFileExists( $file1['file'] );
400-
$this->assertFileNotExists( $file2['file'] );
400+
$this->assertFileDoesNotExist( $file2['file'] );
401401
}
402402

403403
function test_wpmu_update_blogs_date() {

tests/phpunit/tests/rest-api/rest-plugins-controller.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -844,7 +844,7 @@ public function test_delete_item() {
844844
$this->assertSame( 200, $response->get_status() );
845845
$this->assertTrue( $response->get_data()['deleted'] );
846846
$this->assertSame( self::PLUGIN, $response->get_data()['previous']['plugin'] );
847-
$this->assertFileNotExists( WP_PLUGIN_DIR . '/' . self::PLUGIN_FILE );
847+
$this->assertFileDoesNotExist( WP_PLUGIN_DIR . '/' . self::PLUGIN_FILE );
848848
}
849849

850850
/**

0 commit comments

Comments
 (0)