From 29d678d08b6baf21ff9d5f69ef15c4eaae0b551a Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Fri, 6 Aug 2021 21:45:32 +0000 Subject: [PATCH] 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 * https://github.com/sebastianbergmann/phpunit/issues/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 --- tests/phpunit/tests/admin/includesPlugin.php | 2 +- tests/phpunit/tests/ajax/MediaEdit.php | 2 +- tests/phpunit/tests/functions.php | 2 +- tests/phpunit/tests/image/editorImagick.php | 2 +- tests/phpunit/tests/link/themeFile.php | 4 ++-- tests/phpunit/tests/multisite/ms-files-rewriting.php | 4 ++-- tests/phpunit/tests/multisite/site.php | 4 ++-- tests/phpunit/tests/rest-api/rest-plugins-controller.php | 2 +- 8 files changed, 11 insertions(+), 11 deletions(-) diff --git a/tests/phpunit/tests/admin/includesPlugin.php b/tests/phpunit/tests/admin/includesPlugin.php index d4b07d3f4f..ebba733f23 100644 --- a/tests/phpunit/tests/admin/includesPlugin.php +++ b/tests/phpunit/tests/admin/includesPlugin.php @@ -403,7 +403,7 @@ class Tests_Admin_includesPlugin extends WP_UnitTestCase { * @covers ::get_mu_plugins */ public function test_get_mu_plugins_when_mu_plugins_directory_does_not_exist() { - $this->assertFileNotExists( WPMU_PLUGIN_DIR ); + $this->assertFileDoesNotExist( WPMU_PLUGIN_DIR ); $this->assertSame( array(), get_mu_plugins() ); } diff --git a/tests/phpunit/tests/ajax/MediaEdit.php b/tests/phpunit/tests/ajax/MediaEdit.php index aa6e6786a6..5bdee5e14b 100644 --- a/tests/phpunit/tests/ajax/MediaEdit.php +++ b/tests/phpunit/tests/ajax/MediaEdit.php @@ -96,7 +96,7 @@ class Tests_Ajax_MediaEdit extends WP_Ajax_UnitTestCase { } foreach ( $files_that_shouldnt_exist as $file ) { - $this->assertFileNotExists( $file, 'IMAGE_EDIT_OVERWRITE is leaving garbage image files behind.' ); + $this->assertFileDoesNotExist( $file, 'IMAGE_EDIT_OVERWRITE is leaving garbage image files behind.' ); } } } diff --git a/tests/phpunit/tests/functions.php b/tests/phpunit/tests/functions.php index e6b8580dc8..06320930b9 100644 --- a/tests/phpunit/tests/functions.php +++ b/tests/phpunit/tests/functions.php @@ -173,7 +173,7 @@ class Tests_Functions extends WP_UnitTestCase { // Check number is appended for file already exists. $this->assertFileExists( $testdir . 'test-image.png', 'Test image does not exist' ); $this->assertSame( 'test-image-1.png', wp_unique_filename( $testdir, 'test-image.png' ), 'Number not appended correctly' ); - $this->assertFileNotExists( $testdir . 'test-image-1.png' ); + $this->assertFileDoesNotExist( $testdir . 'test-image-1.png' ); // Check special chars. $this->assertSame( 'testtest-image.png', wp_unique_filename( $testdir, 'testtést-imagé.png' ), 'Filename with special chars failed' ); diff --git a/tests/phpunit/tests/image/editorImagick.php b/tests/phpunit/tests/image/editorImagick.php index dd3987a2cb..32f651fd29 100644 --- a/tests/phpunit/tests/image/editorImagick.php +++ b/tests/phpunit/tests/image/editorImagick.php @@ -607,7 +607,7 @@ class Tests_Image_Editor_Imagick extends WP_Image_UnitTestCase { $directory = realpath( DIR_TESTDATA ) . '/images/nonexistent-directory'; $editor = new WP_Image_Editor_Imagick( $file ); - $this->assertFileNotExists( $directory ); + $this->assertFileDoesNotExist( $directory ); $loaded = $editor->load(); $this->assertNotWPError( $loaded ); diff --git a/tests/phpunit/tests/link/themeFile.php b/tests/phpunit/tests/link/themeFile.php index 5e0b7786d0..3e78a655e3 100644 --- a/tests/phpunit/tests/link/themeFile.php +++ b/tests/phpunit/tests/link/themeFile.php @@ -121,13 +121,13 @@ class Tests_Link_ThemeFile extends WP_UnitTestCase { if ( in_array( 'theme-file-child', $existence, true ) ) { $this->assertFileExists( WP_CONTENT_DIR . "/themes/theme-file-child/{$file}" ); } else { - $this->assertFileNotExists( WP_CONTENT_DIR . "/themes/theme-file-child/{$file}" ); + $this->assertFileDoesNotExist( WP_CONTENT_DIR . "/themes/theme-file-child/{$file}" ); } if ( in_array( 'theme-file-parent', $existence, true ) ) { $this->assertFileExists( WP_CONTENT_DIR . "/themes/theme-file-parent/{$file}" ); } else { - $this->assertFileNotExists( WP_CONTENT_DIR . "/themes/theme-file-parent/{$file}" ); + $this->assertFileDoesNotExist( WP_CONTENT_DIR . "/themes/theme-file-parent/{$file}" ); } } diff --git a/tests/phpunit/tests/multisite/ms-files-rewriting.php b/tests/phpunit/tests/multisite/ms-files-rewriting.php index dd0f3560db..89cd341fb2 100644 --- a/tests/phpunit/tests/multisite/ms-files-rewriting.php +++ b/tests/phpunit/tests/multisite/ms-files-rewriting.php @@ -76,13 +76,13 @@ if ( is_multisite() ) : // The file on the main site should still exist. The file on the deleted site should not. $this->assertFileExists( $file1['file'] ); - $this->assertFileNotExists( $file2['file'] ); + $this->assertFileDoesNotExist( $file2['file'] ); wpmu_delete_blog( $blog_id, true ); // The file on the main site should still exist. The file on the deleted site should not. $this->assertFileExists( $file1['file'] ); - $this->assertFileNotExists( $file2['file'] ); + $this->assertFileDoesNotExist( $file2['file'] ); } } diff --git a/tests/phpunit/tests/multisite/site.php b/tests/phpunit/tests/multisite/site.php index 557da8c06a..6f5873b4a2 100644 --- a/tests/phpunit/tests/multisite/site.php +++ b/tests/phpunit/tests/multisite/site.php @@ -391,13 +391,13 @@ if ( is_multisite() ) : // The file on the main site should still exist. The file on the deleted site should not. $this->assertFileExists( $file1['file'] ); - $this->assertFileNotExists( $file2['file'] ); + $this->assertFileDoesNotExist( $file2['file'] ); wpmu_delete_blog( $blog_id, true ); // The file on the main site should still exist. The file on the deleted site should not. $this->assertFileExists( $file1['file'] ); - $this->assertFileNotExists( $file2['file'] ); + $this->assertFileDoesNotExist( $file2['file'] ); } function test_wpmu_update_blogs_date() { diff --git a/tests/phpunit/tests/rest-api/rest-plugins-controller.php b/tests/phpunit/tests/rest-api/rest-plugins-controller.php index b9051115c4..4bfda0b3c6 100644 --- a/tests/phpunit/tests/rest-api/rest-plugins-controller.php +++ b/tests/phpunit/tests/rest-api/rest-plugins-controller.php @@ -844,7 +844,7 @@ class WP_REST_Plugins_Controller_Test extends WP_Test_REST_Controller_Testcase { $this->assertSame( 200, $response->get_status() ); $this->assertTrue( $response->get_data()['deleted'] ); $this->assertSame( self::PLUGIN, $response->get_data()['previous']['plugin'] ); - $this->assertFileNotExists( WP_PLUGIN_DIR . '/' . self::PLUGIN_FILE ); + $this->assertFileDoesNotExist( WP_PLUGIN_DIR . '/' . self::PLUGIN_FILE ); } /**