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
This commit is contained in:
Sergey Biryukov 2021-08-07 14:15:42 +00:00
parent 05923f05d3
commit 213bbf76ed

View File

@ -148,16 +148,14 @@ class Tests_Theme extends WP_UnitTestCase {
$this->assertIsArray( $theme['Template Files'] );
$this->assertNotEmpty( $theme['Template Files'] );
foreach ( $theme['Template Files'] as $file ) {
$this->assertTrue( is_file( $dir . $file ) );
$this->assertTrue( is_readable( $dir . $file ) );
$this->assertFileIsReadable( $dir . $file );
}
// CSS files should all exist.
$this->assertIsArray( $theme['Stylesheet Files'] );
$this->assertNotEmpty( $theme['Stylesheet Files'] );
foreach ( $theme['Stylesheet Files'] as $file ) {
$this->assertTrue( is_file( $dir . $file ) );
$this->assertTrue( is_readable( $dir . $file ) );
$this->assertFileIsReadable( $dir . $file );
}
$this->assertTrue( is_dir( $dir . $theme['Template Dir'] ) );
@ -165,8 +163,7 @@ class Tests_Theme extends WP_UnitTestCase {
$this->assertSame( 'publish', $theme['Status'] );
$this->assertTrue( is_file( $dir . $theme['Stylesheet Dir'] . '/' . $theme['Screenshot'] ) );
$this->assertTrue( is_readable( $dir . $theme['Stylesheet Dir'] . '/' . $theme['Screenshot'] ) );
$this->assertFileIsReadable( $dir . $theme['Stylesheet Dir'] . '/' . $theme['Screenshot'] );
}
}