Build/Test Tools: Implement `assertNotWPError()` in appropriate places in the test suite.
Props birgire Fixes #42065 git-svn-id: https://develop.svn.wordpress.org/trunk@42863 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
71d2050014
commit
3bb3d7a6c7
|
@ -200,7 +200,7 @@ abstract class WP_Test_REST_Post_Type_Controller_Testcase extends WP_Test_REST_C
|
|||
}
|
||||
|
||||
protected function check_get_posts_response( $response, $context = 'view' ) {
|
||||
$this->assertNotInstanceOf( 'WP_Error', $response );
|
||||
$this->assertNotWPError( $response );
|
||||
$response = rest_ensure_response( $response );
|
||||
$this->assertEquals( 200, $response->get_status() );
|
||||
|
||||
|
@ -232,7 +232,7 @@ abstract class WP_Test_REST_Post_Type_Controller_Testcase extends WP_Test_REST_C
|
|||
}
|
||||
|
||||
protected function check_get_post_response( $response, $context = 'view' ) {
|
||||
$this->assertNotInstanceOf( 'WP_Error', $response );
|
||||
$this->assertNotWPError( $response );
|
||||
$response = rest_ensure_response( $response );
|
||||
$this->assertEquals( 200, $response->get_status() );
|
||||
|
||||
|
@ -243,7 +243,7 @@ abstract class WP_Test_REST_Post_Type_Controller_Testcase extends WP_Test_REST_C
|
|||
}
|
||||
|
||||
protected function check_create_post_response( $response ) {
|
||||
$this->assertNotInstanceOf( 'WP_Error', $response );
|
||||
$this->assertNotWPError( $response );
|
||||
$response = rest_ensure_response( $response );
|
||||
|
||||
$this->assertEquals( 201, $response->get_status() );
|
||||
|
@ -256,7 +256,7 @@ abstract class WP_Test_REST_Post_Type_Controller_Testcase extends WP_Test_REST_C
|
|||
}
|
||||
|
||||
protected function check_update_post_response( $response ) {
|
||||
$this->assertNotInstanceOf( 'WP_Error', $response );
|
||||
$this->assertNotWPError( $response );
|
||||
$response = rest_ensure_response( $response );
|
||||
|
||||
$this->assertEquals( 200, $response->get_status() );
|
||||
|
|
|
@ -32,7 +32,7 @@ class Tests_Admin_Includes_Post extends WP_UnitTestCase {
|
|||
$_post_data['saveasdraft'] = true;
|
||||
|
||||
$_results = _wp_translate_postdata( false, $_post_data );
|
||||
$this->assertNotInstanceOf( 'WP_Error', $_results );
|
||||
$this->assertNotWPError( $_results );
|
||||
$this->assertEquals( $_post_data['post_author'], $_results['post_author'] );
|
||||
$this->assertEquals( 'draft', $_results['post_status'] );
|
||||
|
||||
|
@ -43,7 +43,7 @@ class Tests_Admin_Includes_Post extends WP_UnitTestCase {
|
|||
$_post_data['publish'] = true;
|
||||
|
||||
$_results = _wp_translate_postdata( false, $_post_data );
|
||||
$this->assertNotInstanceOf( 'WP_Error', $_results );
|
||||
$this->assertNotWPError( $_results );
|
||||
$this->assertEquals( $_post_data['post_author'], $_results['post_author'] );
|
||||
$this->assertEquals( 'pending', $_results['post_status'] );
|
||||
|
||||
|
@ -82,7 +82,7 @@ class Tests_Admin_Includes_Post extends WP_UnitTestCase {
|
|||
$_post_data['saveasdraft'] = true;
|
||||
|
||||
$_results = _wp_translate_postdata( false, $_post_data );
|
||||
$this->assertNotInstanceOf( 'WP_Error', $_results );
|
||||
$this->assertNotWPError( $_results );
|
||||
$this->assertEquals( $_post_data['post_author'], $_results['post_author'] );
|
||||
$this->assertEquals( 'draft', $_results['post_status'] );
|
||||
|
||||
|
@ -93,7 +93,7 @@ class Tests_Admin_Includes_Post extends WP_UnitTestCase {
|
|||
$_post_data['publish'] = true;
|
||||
|
||||
$_results = _wp_translate_postdata( false, $_post_data );
|
||||
$this->assertNotInstanceOf( 'WP_Error', $_results );
|
||||
$this->assertNotWPError( $_results );
|
||||
$this->assertEquals( $_post_data['post_author'], $_results['post_author'] );
|
||||
$this->assertEquals( 'publish', $_results['post_status'] );
|
||||
|
||||
|
@ -104,7 +104,7 @@ class Tests_Admin_Includes_Post extends WP_UnitTestCase {
|
|||
$_post_data['saveasdraft'] = true;
|
||||
|
||||
$_results = _wp_translate_postdata( false, $_post_data );
|
||||
$this->assertNotInstanceOf( 'WP_Error', $_results );
|
||||
$this->assertNotWPError( $_results );
|
||||
$this->assertEquals( $_post_data['post_author'], $_results['post_author'] );
|
||||
$this->assertEquals( 'draft', $_results['post_status'] );
|
||||
|
||||
|
@ -117,7 +117,7 @@ class Tests_Admin_Includes_Post extends WP_UnitTestCase {
|
|||
$_post_data['saveasdraft'] = true;
|
||||
|
||||
$_results = _wp_translate_postdata( true, $_post_data );
|
||||
$this->assertNotInstanceOf( 'WP_Error', $_results );
|
||||
$this->assertNotWPError( $_results );
|
||||
$this->assertEquals( $_post_data['post_author'], $_results['post_author'] );
|
||||
$this->assertEquals( 'draft', $_results['post_status'] );
|
||||
}
|
||||
|
|
|
@ -645,7 +645,7 @@ class Tests_Ajax_CustomizeManager extends WP_Ajax_UnitTestCase {
|
|||
$this->assertEquals( 'changeset_lock_dismissed', $this->_last_response_parsed['data'] );
|
||||
|
||||
$_POST['dismiss_autosave'] = $_GET['dismiss_autosave'] = $_REQUEST['dismiss_autosave'] = true;
|
||||
$this->assertNotInstanceOf( 'WP_Error', $r );
|
||||
$this->assertNotWPError( $r );
|
||||
$this->assertFalse( wp_get_post_autosave( $wp_customize->changeset_post_id() ) );
|
||||
$this->assertContains( 'Foo', get_post( $wp_customize->changeset_post_id() )->post_content );
|
||||
|
||||
|
@ -665,7 +665,7 @@ class Tests_Ajax_CustomizeManager extends WP_Ajax_UnitTestCase {
|
|||
'autosave' => true,
|
||||
)
|
||||
);
|
||||
$this->assertNotInstanceOf( 'WP_Error', $r );
|
||||
$this->assertNotWPError( $r );
|
||||
$autosave_revision = wp_get_post_autosave( $wp_customize->changeset_post_id() );
|
||||
$this->assertInstanceOf( 'WP_Post', $autosave_revision );
|
||||
$this->assertContains( 'Foo', get_post( $wp_customize->changeset_post_id() )->post_content );
|
||||
|
|
|
@ -495,7 +495,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
|||
'autosave' => true,
|
||||
)
|
||||
);
|
||||
$this->assertNotInstanceOf( 'WP_Error', $r );
|
||||
$this->assertNotWPError( $r );
|
||||
|
||||
// No change to data if not requesting autosave.
|
||||
$wp_customize = new WP_Customize_Manager(
|
||||
|
|
|
@ -253,7 +253,7 @@ class Test_WP_Customize_Nav_Menu_Setting extends WP_UnitTestCase {
|
|||
|
||||
$term = (array) wp_get_nav_menu_object( $menu_id );
|
||||
$this->assertNotEmpty( $term );
|
||||
$this->assertNotInstanceOf( 'WP_Error', $term );
|
||||
$this->assertNotWPError( $term );
|
||||
$this->assertEqualSets( $post_value, wp_array_slice_assoc( $term, array_keys( $value ) ) );
|
||||
$this->assertEquals( $menu_id, $term['term_id'] );
|
||||
$this->assertEquals( $menu_id, $term['term_taxonomy_id'] );
|
||||
|
|
|
@ -476,7 +476,7 @@ class Tests_Image_Editor_GD extends WP_Image_UnitTestCase {
|
|||
|
||||
$editor = wp_get_image_editor( $file );
|
||||
|
||||
$this->assertNotInstanceOf( 'WP_Error', $editor );
|
||||
$this->assertNotWPError( $editor );
|
||||
|
||||
$editor->load();
|
||||
$editor->resize( 5, 5 );
|
||||
|
@ -503,7 +503,7 @@ class Tests_Image_Editor_GD extends WP_Image_UnitTestCase {
|
|||
|
||||
$editor = wp_get_image_editor( $file );
|
||||
|
||||
$this->assertNotInstanceOf( 'WP_Error', $editor );
|
||||
$this->assertNotWPError( $editor );
|
||||
|
||||
$editor->load();
|
||||
|
||||
|
@ -531,7 +531,7 @@ class Tests_Image_Editor_GD extends WP_Image_UnitTestCase {
|
|||
$expected = imagecolorsforindex( $image, $rgb );
|
||||
|
||||
$editor = new WP_Image_Editor_GD( $file );
|
||||
$this->assertNotInstanceOf( 'WP_Error', $editor );
|
||||
$this->assertNotWPError( $editor );
|
||||
$editor->load();
|
||||
$editor->rotate( 180 );
|
||||
$save_to_file = tempnam( get_temp_dir(), '' ) . '.png';
|
||||
|
|
|
@ -465,7 +465,7 @@ class Tests_Image_Editor_Imagick extends WP_Image_UnitTestCase {
|
|||
|
||||
$editor = new WP_Image_Editor_Imagick( $file );
|
||||
|
||||
$this->assertNotInstanceOf( 'WP_Error', $editor );
|
||||
$this->assertNotWPError( $editor );
|
||||
|
||||
$editor->load();
|
||||
$editor->resize( 5, 5 );
|
||||
|
@ -492,7 +492,7 @@ class Tests_Image_Editor_Imagick extends WP_Image_UnitTestCase {
|
|||
|
||||
$editor = new WP_Image_Editor_Imagick( $file );
|
||||
|
||||
$this->assertNotInstanceOf( 'WP_Error', $editor );
|
||||
$this->assertNotWPError( $editor );
|
||||
|
||||
$editor->load();
|
||||
|
||||
|
@ -524,7 +524,7 @@ class Tests_Image_Editor_Imagick extends WP_Image_UnitTestCase {
|
|||
|
||||
$image_editor = new WP_Image_Editor_Imagick( $save_to_file );
|
||||
$image_editor->load();
|
||||
$this->assertNotInstanceOf( 'WP_Error', $image_editor );
|
||||
$this->assertNotWPError( $image_editor );
|
||||
$image_editor->rotate( 180 );
|
||||
$image_editor->save( $save_to_file );
|
||||
|
||||
|
|
|
@ -163,7 +163,7 @@ class Tests_Image_Functions extends WP_UnitTestCase {
|
|||
$file = wp_tempnam();
|
||||
$ret = wp_save_image_file( $file, $img, $mime_type, 1 );
|
||||
$this->assertNotEmpty( $ret );
|
||||
$this->assertNotInstanceOf( 'WP_Error', $ret );
|
||||
$this->assertNotWPError( $ret );
|
||||
$this->assertEquals( $mime_type, $this->get_mime_type( $ret['path'] ) );
|
||||
|
||||
// Clean up
|
||||
|
@ -205,7 +205,7 @@ class Tests_Image_Functions extends WP_UnitTestCase {
|
|||
|
||||
// Make assertions
|
||||
$this->assertNotEmpty( $ret );
|
||||
$this->assertNotInstanceOf( 'WP_Error', $ret );
|
||||
$this->assertNotWPError( $ret );
|
||||
$this->assertEquals( $mime_type, $this->get_mime_type( $ret['path'] ) );
|
||||
|
||||
// Clean up
|
||||
|
@ -249,7 +249,7 @@ class Tests_Image_Functions extends WP_UnitTestCase {
|
|||
|
||||
// Save the image as each file extension, check the mime type
|
||||
$img = wp_get_image_editor( DIR_TESTDATA . '/images/canola.jpg' );
|
||||
$this->assertNotInstanceOf( 'WP_Error', $img );
|
||||
$this->assertNotWPError( $img );
|
||||
|
||||
$temp = get_temp_dir();
|
||||
foreach ( $mime_types as $ext => $mime_type ) {
|
||||
|
@ -260,7 +260,7 @@ class Tests_Image_Functions extends WP_UnitTestCase {
|
|||
$file = wp_unique_filename( $temp, uniqid() . ".$ext" );
|
||||
$ret = $img->save( trailingslashit( $temp ) . $file );
|
||||
$this->assertNotEmpty( $ret );
|
||||
$this->assertNotInstanceOf( 'WP_Error', $ret );
|
||||
$this->assertNotWPError( $ret );
|
||||
$this->assertEquals( $mime_type, $this->get_mime_type( $ret['path'] ) );
|
||||
unlink( $ret['path'] );
|
||||
}
|
||||
|
@ -310,7 +310,7 @@ class Tests_Image_Functions extends WP_UnitTestCase {
|
|||
DIR_TESTDATA . '/images/canola.jpg',
|
||||
0, 0, 100, 100, 100, 100
|
||||
);
|
||||
$this->assertNotInstanceOf( 'WP_Error', $file );
|
||||
$this->assertNotWPError( $file );
|
||||
$this->assertFileExists( $file );
|
||||
$image = wp_get_image_editor( $file );
|
||||
$size = $image->get_size();
|
||||
|
@ -334,7 +334,7 @@ class Tests_Image_Functions extends WP_UnitTestCase {
|
|||
0, 0, 100, 100, 100, 100, false,
|
||||
DIR_TESTDATA . '/images/' . __FUNCTION__ . '.jpg'
|
||||
);
|
||||
$this->assertNotInstanceOf( 'WP_Error', $file );
|
||||
$this->assertNotWPError( $file );
|
||||
$this->assertFileExists( $file );
|
||||
$image = wp_get_image_editor( $file );
|
||||
$size = $image->get_size();
|
||||
|
|
|
@ -15,7 +15,7 @@ class Tests_Post_Formats extends WP_UnitTestCase {
|
|||
$this->assertFalse( $format );
|
||||
|
||||
$result = set_post_format( $post_id, 'aside' );
|
||||
$this->assertNotInstanceOf( 'WP_Error', $result );
|
||||
$this->assertNotWPError( $result );
|
||||
$this->assertInternalType( 'array', $result );
|
||||
$this->assertEquals( 1, count( $result ) );
|
||||
|
||||
|
@ -23,12 +23,12 @@ class Tests_Post_Formats extends WP_UnitTestCase {
|
|||
$this->assertEquals( 'aside', $format );
|
||||
|
||||
$result = set_post_format( $post_id, 'standard' );
|
||||
$this->assertNotInstanceOf( 'WP_Error', $result );
|
||||
$this->assertNotWPError( $result );
|
||||
$this->assertInternalType( 'array', $result );
|
||||
$this->assertEquals( 0, count( $result ) );
|
||||
|
||||
$result = set_post_format( $post_id, '' );
|
||||
$this->assertNotInstanceOf( 'WP_Error', $result );
|
||||
$this->assertNotWPError( $result );
|
||||
$this->assertInternalType( 'array', $result );
|
||||
$this->assertEquals( 0, count( $result ) );
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ class Tests_Post_Formats extends WP_UnitTestCase {
|
|||
$this->assertFalse( $format );
|
||||
|
||||
$result = set_post_format( $post_id, 'aside' );
|
||||
$this->assertNotInstanceOf( 'WP_Error', $result );
|
||||
$this->assertNotWPError( $result );
|
||||
$this->assertInternalType( 'array', $result );
|
||||
$this->assertEquals( 1, count( $result ) );
|
||||
// The format can be set but not retrieved until it is registered.
|
||||
|
@ -56,12 +56,12 @@ class Tests_Post_Formats extends WP_UnitTestCase {
|
|||
$this->assertEquals( 'aside', $format );
|
||||
|
||||
$result = set_post_format( $post_id, 'standard' );
|
||||
$this->assertNotInstanceOf( 'WP_Error', $result );
|
||||
$this->assertNotWPError( $result );
|
||||
$this->assertInternalType( 'array', $result );
|
||||
$this->assertEquals( 0, count( $result ) );
|
||||
|
||||
$result = set_post_format( $post_id, '' );
|
||||
$this->assertNotInstanceOf( 'WP_Error', $result );
|
||||
$this->assertNotWPError( $result );
|
||||
$this->assertInternalType( 'array', $result );
|
||||
$this->assertEquals( 0, count( $result ) );
|
||||
|
||||
|
@ -75,13 +75,13 @@ class Tests_Post_Formats extends WP_UnitTestCase {
|
|||
$this->assertFalse( has_post_format( '', $post_id ) );
|
||||
|
||||
$result = set_post_format( $post_id, 'aside' );
|
||||
$this->assertNotInstanceOf( 'WP_Error', $result );
|
||||
$this->assertNotWPError( $result );
|
||||
$this->assertInternalType( 'array', $result );
|
||||
$this->assertEquals( 1, count( $result ) );
|
||||
$this->assertTrue( has_post_format( 'aside', $post_id ) );
|
||||
|
||||
$result = set_post_format( $post_id, 'standard' );
|
||||
$this->assertNotInstanceOf( 'WP_Error', $result );
|
||||
$this->assertNotWPError( $result );
|
||||
$this->assertInternalType( 'array', $result );
|
||||
$this->assertEquals( 0, count( $result ) );
|
||||
// Standard is a special case. It shows as false when set.
|
||||
|
|
Loading…
Reference in New Issue