Make WordPress Core

Opened 5 months ago

Last modified 5 months ago

#42065 new enhancement

Implement `assertNotWPError` in test suite

Reported by: danielbachhuber Owned by:
Milestone: Future Release Priority: normal
Severity: normal Version:
Component: Build/Test Tools Keywords: needs-patch
Focuses: Cc:


WP_Error often returns useful information about why a function is failed.

However, an assertion like $this->assertNotInstanceOf( 'WP_Error', $file ); isn't helpful to the test runner because it doesn't communicate the information conveyed by the WP_Error object.

Currently, someone running the test has to add some var_dump() debug (or similar) to read the contents of the returned error object.

It would be helpful to have an assertNotWPError assertion that communicated the contents of the WP_Error object when it actually is one.

Inspired by #42064

Change History (3)

#1 @johnbillion
5 months ago

It's already there but there are a bunch of places in core that don't use it.

#2 @danielbachhuber
5 months ago

@johnbillion Should've grepped. Can we clean those up?

#3 @johnbillion
5 months ago

  • Keywords needs-patch added
  • Summary changed from Introduce `assertNotWPError` in test suite to Implement `assertNotWPError` in test suite

Yep definitely.

Note: See TracTickets for help on using tickets.