From 5ff16465f23f2f13edd3cb799f2061a699d09d03 Mon Sep 17 00:00:00 2001 From: John Blackbourn Date: Sun, 27 Sep 2015 21:28:26 +0000 Subject: [PATCH] Introduce `WP_UnitTestCase::assertNotWPError()` for when a test needs to assert that something is, well, not a `WP_Error`. See #33978 git-svn-id: https://develop.svn.wordpress.org/trunk@34638 602fd350-edb4-49c9-b593-d223f7449a82 --- tests/phpunit/includes/testcase.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/phpunit/includes/testcase.php b/tests/phpunit/includes/testcase.php index b93149f4b1..f5a7db8362 100644 --- a/tests/phpunit/includes/testcase.php +++ b/tests/phpunit/includes/testcase.php @@ -301,6 +301,13 @@ class WP_UnitTestCase extends PHPUnit_Framework_TestCase { $this->assertInstanceOf( 'WP_Error', $actual, $message ); } + function assertNotWPError( $actual, $message = '' ) { + if ( is_wp_error( $actual ) && '' === $message ) { + $message = $actual->get_error_message(); + } + $this->assertNotInstanceOf( 'WP_Error', $actual, $message ); + } + function assertEqualFields( $object, $fields ) { foreach( $fields as $field_name => $field_value ) { if ( $object->$field_name != $field_value ) {