Make WordPress Core

Ticket #53363: 53363-02-use-assertfileisreadable.patch

File 53363-02-use-assertfileisreadable.patch, 1.8 KB (added by jrf, 3 years ago)

Use more appropriate assertion [1] - this assertion is available PHPUnit cross-version, so can already be used

  • tests/phpunit/tests/theme.php

    From ab74560da61fe47fbe07fc998080490495c1b120 Mon Sep 17 00:00:00 2001
    From: jrfnl <jrfnl@users.noreply.github.com>
    Date: Tue, 20 Jul 2021 11:16:12 +0200
    Subject: [PATCH 1/2] Build/Tests: use more appropriate assertions [1]
    
    PHPUnit has a build in assertion to verify that a file exists and is readable. Let's use it.
    ---
     tests/phpunit/tests/theme.php | 9 +++------
     1 file changed, 3 insertions(+), 6 deletions(-)
    
    diff --git a/tests/phpunit/tests/theme.php b/tests/phpunit/tests/theme.php
    index fa4df1bf2a..7de707e3fe 100644
    a b class Tests_Theme extends WP_UnitTestCase_Base { 
    148148                        $this->assertIsArray( $theme['Template Files'] );
    149149                        $this->assertNotEmpty( $theme['Template Files'] );
    150150                        foreach ( $theme['Template Files'] as $file ) {
    151                                 $this->assertTrue( is_file( $dir . $file ) );
    152                                 $this->assertTrue( is_readable( $dir . $file ) );
     151                                $this->assertFileIsReadable( $dir . $file );
    153152                        }
    154153
    155154                        // CSS files should all exist.
    156155                        $this->assertIsArray( $theme['Stylesheet Files'] );
    157156                        $this->assertNotEmpty( $theme['Stylesheet Files'] );
    158157                        foreach ( $theme['Stylesheet Files'] as $file ) {
    159                                 $this->assertTrue( is_file( $dir . $file ) );
    160                                 $this->assertTrue( is_readable( $dir . $file ) );
     158                                $this->assertFileIsReadable( $dir . $file );
    161159                        }
    162160
    163161                        $this->assertTrue( is_dir( $dir . $theme['Template Dir'] ) );
    class Tests_Theme extends WP_UnitTestCase_Base { 
    165163
    166164                        $this->assertSame( 'publish', $theme['Status'] );
    167165
    168                         $this->assertTrue( is_file( $dir . $theme['Stylesheet Dir'] . '/' . $theme['Screenshot'] ) );
    169                         $this->assertTrue( is_readable( $dir . $theme['Stylesheet Dir'] . '/' . $theme['Screenshot'] ) );
     166                        $this->assertFileIsReadable( $dir . $theme['Stylesheet Dir'] . '/' . $theme['Screenshot'] );
    170167                }
    171168        }
    172169