mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2025-10-16 12:05:38 +00:00
Tests: Use more appropriate assertions in various tests.
This replaces instances of `assertTrue( is_numeric( ... ) )` with `assertIsNumeric()` to use native PHPUnit functionality. Follow-up to [51335], [51337], [51367], [51397], [51403], [51404], [51436]. See #53363. git-svn-id: https://develop.svn.wordpress.org/trunk@51438 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
cc5e3f7811
commit
56a90eb273
@ -205,7 +205,7 @@ class Tests_Ajax_DeleteComment extends WP_Ajax_UnitTestCase {
|
||||
$this->fail( 'Expected exception: WPAjaxDieStopException' );
|
||||
} catch ( WPAjaxDieStopException $e ) {
|
||||
$this->assertSame( 10, strlen( $e->getMessage() ) );
|
||||
$this->assertTrue( is_numeric( $e->getMessage() ) );
|
||||
$this->assertIsNumeric( $e->getMessage() );
|
||||
} catch ( Exception $e ) {
|
||||
$this->fail( 'Unexpected exception type: ' . get_class( $e ) );
|
||||
}
|
||||
@ -255,7 +255,7 @@ class Tests_Ajax_DeleteComment extends WP_Ajax_UnitTestCase {
|
||||
$this->fail( 'Expected exception: WPAjaxDieStopException' );
|
||||
} catch ( WPAjaxDieStopException $e ) {
|
||||
$this->assertSame( 10, strlen( $e->getMessage() ) );
|
||||
$this->assertTrue( is_numeric( $e->getMessage() ) );
|
||||
$this->assertIsNumeric( $e->getMessage() );
|
||||
} catch ( Exception $e ) {
|
||||
$this->fail( 'Unexpected exception type: ' . get_class( $e ) );
|
||||
}
|
||||
|
||||
@ -1214,7 +1214,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
$this->assertSame( $manager->changeset_uuid(), get_post( $post_id )->post_name, 'Expected that the "__trashed" suffix to not be added.' );
|
||||
wp_set_current_user( self::$admin_user_id );
|
||||
$this->assertSame( 'publish', get_post_meta( $post_id, '_wp_trash_meta_status', true ) );
|
||||
$this->assertTrue( is_numeric( get_post_meta( $post_id, '_wp_trash_meta_time', true ) ) );
|
||||
$this->assertIsNumeric( get_post_meta( $post_id, '_wp_trash_meta_time', true ) );
|
||||
|
||||
foreach ( array_keys( $expected_actions ) as $action_name ) {
|
||||
$this->assertSame( $expected_actions[ $action_name ] + $action_counts[ $action_name ], did_action( $action_name ), "Action: $action_name" );
|
||||
|
||||
@ -1198,7 +1198,7 @@ class Tests_Functions extends WP_UnitTestCase {
|
||||
for ( $i = 0; $i < 20; $i += 1 ) {
|
||||
$id = wp_unique_id();
|
||||
$this->assertIsString( $id );
|
||||
$this->assertTrue( is_numeric( $id ) );
|
||||
$this->assertIsNumeric( $id );
|
||||
$ids[] = $id;
|
||||
}
|
||||
$this->assertSame( $ids, array_unique( $ids ) );
|
||||
|
||||
@ -79,7 +79,7 @@ class Tests_Post extends WP_UnitTestCase {
|
||||
|
||||
// Insert a post and make sure the ID is OK.
|
||||
$id = wp_insert_post( $post );
|
||||
$this->assertTrue( is_numeric( $id ) );
|
||||
$this->assertIsNumeric( $id );
|
||||
$this->assertTrue( $id > 0 );
|
||||
|
||||
// Fetch the post and make sure it matches.
|
||||
@ -135,7 +135,7 @@ class Tests_Post extends WP_UnitTestCase {
|
||||
$id = wp_insert_post( $post );
|
||||
$this->post_ids[] = $id;
|
||||
// dmp( _get_cron_array() );
|
||||
$this->assertTrue( is_numeric( $id ) );
|
||||
$this->assertIsNumeric( $id );
|
||||
$this->assertTrue( $id > 0 );
|
||||
|
||||
// Fetch the post and make sure it matches.
|
||||
@ -258,7 +258,7 @@ class Tests_Post extends WP_UnitTestCase {
|
||||
$id = wp_insert_post( $post );
|
||||
$this->post_ids[] = $id;
|
||||
// dmp( _get_cron_array() );
|
||||
$this->assertTrue( is_numeric( $id ) );
|
||||
$this->assertIsNumeric( $id );
|
||||
$this->assertTrue( $id > 0 );
|
||||
|
||||
// Fetch the post and make sure it matches.
|
||||
@ -379,7 +379,7 @@ class Tests_Post extends WP_UnitTestCase {
|
||||
$id = wp_insert_post( $post );
|
||||
$this->post_ids[] = $id;
|
||||
// dmp( _get_cron_array() );
|
||||
$this->assertTrue( is_numeric( $id ) );
|
||||
$this->assertIsNumeric( $id );
|
||||
$this->assertTrue( $id > 0 );
|
||||
|
||||
// Fetch the post and make sure it matches.
|
||||
|
||||
@ -420,7 +420,7 @@ class Tests_Taxonomy extends WP_UnitTestCase {
|
||||
'taxonomy' => 'category',
|
||||
'cat_name' => 'test1',
|
||||
);
|
||||
$this->assertTrue( is_numeric( wp_insert_category( $cat, true ) ) );
|
||||
$this->assertIsNumeric( wp_insert_category( $cat, true ) );
|
||||
}
|
||||
|
||||
function test_insert_category_update() {
|
||||
|
||||
@ -153,7 +153,7 @@ class Tests_Term extends WP_UnitTestCase {
|
||||
$initial_count = wp_count_terms( array( 'taxonomy' => 'category' ) );
|
||||
|
||||
$t = wp_insert_category( array( 'cat_name' => $term ) );
|
||||
$this->assertTrue( is_numeric( $t ) );
|
||||
$this->assertIsNumeric( $t );
|
||||
$this->assertNotWPError( $t );
|
||||
$this->assertTrue( $t > 0 );
|
||||
$this->assertEquals( $initial_count + 1, wp_count_terms( array( 'taxonomy' => 'category' ) ) );
|
||||
|
||||
@ -159,7 +159,7 @@ class Tests_Theme_GetThemeStarterContent extends WP_UnitTestCase {
|
||||
|
||||
foreach ( $hydrated_starter_content['posts'] as $key => $post ) {
|
||||
$this->assertIsString( $key );
|
||||
$this->assertFalse( is_numeric( $key ) );
|
||||
$this->assertIsNotNumeric( $key );
|
||||
$this->assertIsArray( $post );
|
||||
$this->assertArrayHasKey( 'post_type', $post );
|
||||
$this->assertArrayHasKey( 'post_title', $post );
|
||||
|
||||
@ -482,7 +482,7 @@ class Tests_User extends WP_UnitTestCase {
|
||||
|
||||
// Insert a post and make sure the ID is OK.
|
||||
$post_id = wp_insert_post( $post );
|
||||
$this->assertTrue( is_numeric( $post_id ) );
|
||||
$this->assertIsNumeric( $post_id );
|
||||
|
||||
setup_postdata( get_post( $post_id ) );
|
||||
|
||||
|
||||
@ -67,7 +67,7 @@ class Tests_User_WpDeleteUser extends WP_UnitTestCase {
|
||||
|
||||
// Insert a post and make sure the ID is OK.
|
||||
$post_id = wp_insert_post( $post );
|
||||
$this->assertTrue( is_numeric( $post_id ) );
|
||||
$this->assertIsNumeric( $post_id );
|
||||
$this->assertTrue( $post_id > 0 );
|
||||
|
||||
$post = get_post( $post_id );
|
||||
@ -83,7 +83,7 @@ class Tests_User_WpDeleteUser extends WP_UnitTestCase {
|
||||
|
||||
// Insert a post and make sure the ID is OK.
|
||||
$nav_id = wp_insert_post( $post );
|
||||
$this->assertTrue( is_numeric( $nav_id ) );
|
||||
$this->assertIsNumeric( $nav_id );
|
||||
$this->assertTrue( $nav_id > 0 );
|
||||
|
||||
$post = get_post( $nav_id );
|
||||
|
||||
Loading…
Reference in New Issue
Block a user