[wp-trac] [WordPress Trac] #42065: Implement `assertNotWPError` in test suite

WordPress Trac noreply at wordpress.org
Sat Mar 17 08:54:49 UTC 2018


#42065: Implement `assertNotWPError` in test suite
------------------------------+-----------------------------
 Reporter:  danielbachhuber   |       Owner:
     Type:  enhancement       |      Status:  new
 Priority:  normal            |   Milestone:  Future Release
Component:  Build/Test Tools  |     Version:
 Severity:  normal            |  Resolution:
 Keywords:  has-patch         |     Focuses:
------------------------------+-----------------------------
Changes (by birgire):

 * keywords:  needs-patch => has-patch


Comment:

 [attachment:42065.diff] changes:

 {{{
 $this->assertNotInstanceOf( 'WP_Error', ... )
 }}}

 to

 {{{
 $this->assertNotWPError ( ... )
 }}}

 in the test files:

 - tests/phpunit/tests/post/formats.php
 - tests/phpunit/tests/customize/manager.php
 - tests/phpunit/tests/customize/nav-menu-setting.php
 - tests/phpunit/tests/image/editorImagick.php
 - tests/phpunit/tests/image/editorGd.php
 - tests/phpunit/tests/image/functions.php
 - tests/phpunit/tests/admin/includesPost.php
 - tests/phpunit/tests/ajax/CustomizeManager.php
 - tests/phpunit/includes/testcase-rest-post-type-controller.php

 This is the method's definition:

 {{{
 function assertNotWPError( $actual, $message = '' ) {
         if ( is_wp_error( $actual ) && '' === $message ) {
                 $message = $actual->get_error_message();
         }
         $this->assertNotInstanceOf( 'WP_Error', $actual, $message );
 }

 }}}

 where we see how the {{{WP_Error}}}} error message is passed on to the
 {{{$message}}} argument of the  {{{assertNotInstandeOf}}} method.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/42065#comment:4>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list