mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-12 04:40:26 +00:00
Tests: Use more appropriate assertions in various tests.
This replaces instances of `assertTrue( is_array( ... ) )` with `assertIsArray()` to use native PHPUnit functionality. Follow-up to [51331]. See #53363. git-svn-id: https://develop.svn.wordpress.org/trunk@51335 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -760,11 +760,11 @@ abstract class WP_UnitTestCase_Base extends PHPUnit\Framework\TestCase {
|
||||
* @param array $array Array to check.
|
||||
*/
|
||||
public function assertNonEmptyMultidimensionalArray( $array ) {
|
||||
$this->assertTrue( is_array( $array ) );
|
||||
$this->assertIsArray( $array );
|
||||
$this->assertNotEmpty( $array );
|
||||
|
||||
foreach ( $array as $sub_array ) {
|
||||
$this->assertTrue( is_array( $sub_array ) );
|
||||
$this->assertIsArray( $sub_array );
|
||||
$this->assertNotEmpty( $sub_array );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ class Tests_Admin_includesPlugin extends WP_UnitTestCase {
|
||||
'DomainPath' => '',
|
||||
);
|
||||
|
||||
$this->assertTrue( is_array( $data ) );
|
||||
$this->assertIsArray( $data );
|
||||
|
||||
foreach ( $default_headers as $name => $value ) {
|
||||
$this->assertTrue( isset( $data[ $name ] ) );
|
||||
|
||||
@@ -58,7 +58,7 @@ class Tests_Import_Parser extends WP_Import_UnitTestCase {
|
||||
$parser = new $p;
|
||||
$result = $parser->parse( $file );
|
||||
|
||||
$this->assertTrue( is_array( $result ), $message );
|
||||
$this->assertIsArray( $result, $message );
|
||||
$this->assertSame( 'http://localhost/', $result['base_url'], $message );
|
||||
$this->assertEquals(
|
||||
array(
|
||||
@@ -151,7 +151,7 @@ class Tests_Import_Parser extends WP_Import_UnitTestCase {
|
||||
$parser = new $p;
|
||||
$result = $parser->parse( $file );
|
||||
|
||||
$this->assertTrue( is_array( $result ), $message );
|
||||
$this->assertIsArray( $result, $message );
|
||||
$this->assertSame( 'http://localhost/', $result['base_url'], $message );
|
||||
$this->assertSame( $result['categories'][0]['category_nicename'], 'alpha', $message );
|
||||
$this->assertSame( $result['categories'][0]['cat_name'], 'alpha', $message );
|
||||
|
||||
@@ -72,7 +72,7 @@ class WP_Test_REST_Schema_Initialization extends WP_Test_REST_TestCase {
|
||||
public function test_expected_routes_in_schema() {
|
||||
$routes = rest_get_server()->get_routes();
|
||||
|
||||
$this->assertTrue( is_array( $routes ), '`get_routes` should return an array.' );
|
||||
$this->assertIsArray( $routes, '`get_routes` should return an array.' );
|
||||
$this->assertTrue( ! empty( $routes ), 'Routes should not be empty.' );
|
||||
|
||||
$routes = array_filter( array_keys( $routes ), array( $this, 'is_builtin_route' ) );
|
||||
|
||||
@@ -28,7 +28,7 @@ class Tests_Taxonomy extends WP_UnitTestCase {
|
||||
$tax = get_taxonomy( $taxonomy );
|
||||
// Should return an object with the correct taxonomy object type.
|
||||
$this->assertTrue( is_object( $tax ) );
|
||||
$this->assertTrue( is_array( $tax->object_type ) );
|
||||
$this->assertIsArray( $tax->object_type );
|
||||
$this->assertSame( array( 'post' ), $tax->object_type );
|
||||
}
|
||||
}
|
||||
@@ -110,7 +110,7 @@ class Tests_Taxonomy extends WP_UnitTestCase {
|
||||
$tax = get_taxonomy( $taxonomy );
|
||||
// Should return an object with the correct taxonomy object type.
|
||||
$this->assertTrue( is_object( $tax ) );
|
||||
$this->assertTrue( is_array( $tax->object_type ) );
|
||||
$this->assertIsArray( $tax->object_type );
|
||||
$this->assertSame( array( 'link' ), $tax->object_type );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -248,7 +248,7 @@ class Tests_Term_GetTheTerms extends WP_UnitTestCase {
|
||||
// Re-activate term counting so this doesn't affect other tests.
|
||||
wp_defer_term_counting( false );
|
||||
|
||||
$this->assertTrue( is_array( $terms ) );
|
||||
$this->assertIsArray( $terms );
|
||||
$this->assertSame( array( $term_id ), wp_list_pluck( $terms, 'term_id' ) );
|
||||
}
|
||||
|
||||
@@ -283,7 +283,7 @@ class Tests_Term_GetTheTerms extends WP_UnitTestCase {
|
||||
// Re-activate term counting so this doesn't affect other tests.
|
||||
wp_defer_term_counting( false );
|
||||
|
||||
$this->assertTrue( is_array( $terms ) );
|
||||
$this->assertIsArray( $terms );
|
||||
$this->assertSame( array( $term_ids[1] ), wp_list_pluck( $terms, 'term_id' ) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -145,16 +145,16 @@ class Tests_Theme extends WP_UnitTestCase {
|
||||
$this->assertNotEmpty( $theme['Stylesheet'] );
|
||||
|
||||
// Template files should all exist.
|
||||
$this->assertTrue( is_array( $theme['Template Files'] ) );
|
||||
$this->assertTrue( count( $theme['Template Files'] ) > 0 );
|
||||
$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 ) );
|
||||
}
|
||||
|
||||
// CSS files should all exist.
|
||||
$this->assertTrue( is_array( $theme['Stylesheet Files'] ) );
|
||||
$this->assertTrue( count( $theme['Stylesheet Files'] ) > 0 );
|
||||
$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 ) );
|
||||
|
||||
@@ -155,7 +155,7 @@ class Tests_User extends WP_UnitTestCase {
|
||||
);
|
||||
|
||||
// There is already some stuff in the array.
|
||||
$this->assertTrue( is_array( get_user_meta( self::$author_id ) ) );
|
||||
$this->assertIsArray( get_user_meta( self::$author_id ) );
|
||||
|
||||
foreach ( $vals as $k => $v ) {
|
||||
update_user_meta( self::$author_id, $k, $v );
|
||||
|
||||
Reference in New Issue
Block a user