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 { |
148 | 148 | $this->assertIsArray( $theme['Template Files'] ); |
149 | 149 | $this->assertNotEmpty( $theme['Template Files'] ); |
150 | 150 | 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 ); |
153 | 152 | } |
154 | 153 | |
155 | 154 | // CSS files should all exist. |
156 | 155 | $this->assertIsArray( $theme['Stylesheet Files'] ); |
157 | 156 | $this->assertNotEmpty( $theme['Stylesheet Files'] ); |
158 | 157 | 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 ); |
161 | 159 | } |
162 | 160 | |
163 | 161 | $this->assertTrue( is_dir( $dir . $theme['Template Dir'] ) ); |
… |
… |
class Tests_Theme extends WP_UnitTestCase_Base { |
165 | 163 | |
166 | 164 | $this->assertSame( 'publish', $theme['Status'] ); |
167 | 165 | |
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'] ); |
170 | 167 | } |
171 | 168 | } |
172 | 169 | |