Make WordPress Core

Changeset 58221


Ignore:
Timestamp:
05/28/2024 05:25:06 AM (5 months ago)
Author:
peterwilsoncc
Message:

Build/Test Tools: Assert files exist/do not exist directly.

Replaces various boolean assertions wrapping file_exists() with either assertFileExists() or assertFileDoesNotExist() as appropriate for the test.

Props peterwilsoncc, mukesh27.
See #60705.

Location:
trunk/tests/phpunit/tests
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/fonts/font-library/fontLibraryHooks.php

    r57868 r58221  
    4747        wp_delete_post( $font_face_id, true );
    4848
    49         $this->assertFalse( file_exists( $font_path ), 'The font file should have been deleted when the post was deleted.' );
    50         $this->assertTrue( file_exists( $other_font_path ), 'The other font file should exist.' );
     49        $this->assertFileDoesNotExist( $font_path, 'The font file should have been deleted when the post was deleted.' );
     50        $this->assertFileExists( $other_font_path, 'The other font file should exist.' );
    5151    }
    5252
  • trunk/tests/phpunit/tests/privacy/wpPrivacyDeleteOldExportFiles.php

    r55337 r58221  
    114114        wp_privacy_delete_old_export_files();
    115115
    116         $this->assertFalse( file_exists( self::$expired_export_file ) );
     116        $this->assertFileDoesNotExist( self::$expired_export_file );
    117117    }
    118118
     
    125125        wp_privacy_delete_old_export_files();
    126126
    127         $this->assertTrue( file_exists( self::$active_export_file ) );
     127        $this->assertFileExists( self::$active_export_file );
    128128    }
    129129
     
    136136        wp_privacy_delete_old_export_files();
    137137
    138         $this->assertTrue( file_exists( self::$index_path ) );
     138        $this->assertFileExists( self::$index_path );
    139139    }
    140140
     
    148148
    149149        wp_privacy_delete_old_export_files();
    150         $this->assertTrue( file_exists( self::$active_export_file ) );
    151         $this->assertTrue( file_exists( self::$expired_export_file ) );
     150        $this->assertFileExists( self::$active_export_file );
     151        $this->assertFileExists( self::$expired_export_file );
    152152
    153153        remove_filter( 'wp_privacy_export_expiration', array( $this, 'filter_export_file_expiration_time' ) );
  • trunk/tests/phpunit/tests/privacy/wpPrivacyGeneratePersonalDataExportFile.php

    r58097 r58221  
    290290        wp_privacy_generate_personal_data_export_file( self::$export_request_id );
    291291
    292         $this->assertTrue( file_exists( self::$exports_dir . 'index.php' ) );
     292        $this->assertFileExists( self::$exports_dir . 'index.php' );
    293293    }
    294294
     
    301301        wp_privacy_generate_personal_data_export_file( self::$export_request_id );
    302302
    303         $this->assertTrue( file_exists( $this->export_file_name ) );
     303        $this->assertFileExists( $this->export_file_name );
    304304    }
    305305
     
    409409
    410410        wp_privacy_generate_personal_data_export_file( self::$export_request_id );
    411         $this->assertTrue( file_exists( $this->export_file_name ) );
     411        $this->assertFileExists( $this->export_file_name );
    412412
    413413        // Create a temporary export directory for the test's export files.
Note: See TracChangeset for help on using the changeset viewer.