Skip to content

Commit 213bbf7

Browse files
Tests: Use more appropriate assertions in get_themes() tests.
This replaces instances of `assertTrue( is_file( ... ) )` followed by `assertTrue( is_readable( ... ) )` with `assertFileIsReadable()` to use native PHPUnit functionality. The `assertFileIsReadable()` method was introduced in PHPUnit 5.6. As the minimum supported PHPUnit version has been raised to PHPUnit 5.7.21, it can now be used. Follow-up to [51543], [51574]. Props jrf. See #53363. git-svn-id: https://develop.svn.wordpress.org/trunk@51579 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 05923f0 commit 213bbf7

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

tests/phpunit/tests/theme.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -148,25 +148,22 @@ function test_get_themes_contents() {
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'] ) );
164162
$this->assertTrue( is_dir( $dir . $theme['Stylesheet Dir'] ) );
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

0 commit comments

Comments
 (0)