WordPress.org

Make WordPress Core

Opened 6 years ago

Closed 6 years ago

#28486 closed enhancement (fixed)

Base unit test does not have setExpectedDeprecated method

Reported by: rmccue Owned by: boonebgorges
Milestone: 4.2 Priority: normal
Severity: normal Version: 3.7
Component: Build/Test Tools Keywords: has-patch
Focuses: Cc:

Description

The @expectedDeprecated annotation was added in #25282, but does not have a method to accompany it.

This does not match the format used by PHPUnit, where @expectedException matches to setExpectedException().

We should add setExpectedDeprecated as a functional way to set this data.

Attachments (3)

28486.diff (1.1 KB) - added by prasoon2211 6 years ago.
28486.2.diff (1.1 KB) - added by prasoon2211 6 years ago.
Version 2
28486.3.diff (1.3 KB) - added by prasoon2211 6 years ago.
Version 3

Download all attachments as: .zip

Change History (14)

#1 @DrewAPicture
6 years ago

  • Keywords needs-patch added

+1 makes sense to me.

#2 @wonderboymusic
6 years ago

  • Milestone changed from Awaiting Review to Future Release

#3 @boonebgorges
6 years ago

Also setExpectedIncorrectUsage().

@prasoon2211
6 years ago

#4 @prasoon2211
6 years ago

Hey guys. New guy here :)

Anyway, I tried to make a patch (attached). Is it okay?

#5 @jdgrimes
6 years ago

Welcome @prasoon2211!

In 28486.diff, I don't think that it is necessary to have all of the add_action() calls. The actions will be hooked up by the expectDeprecated() method (called in setUp()). So maybe all you would need is the array_push() calls.

Also, it might be nice to add some tests for these methods in /tests/phpunit/tests/includes/helpers.php.

@prasoon2211
6 years ago

Version 2

#6 @prasoon2211
6 years ago

I forgot the test for the other method!

@prasoon2211
6 years ago

Version 3

#7 @prasoon2211
6 years ago

@jdgrimes: Thanks for the input! 28486.3.diff has been attached. Let me know if there's anything more to be done.

#8 @jdgrimes
6 years ago

  • Keywords has-patch added; needs-patch removed

28486.3.diff looks good. Now we just need to wait for someone with commit access to come along...

#9 @boonebgorges
6 years ago

  • Milestone changed from Future Release to 4.2
  • Owner set to boonebgorges
  • Status changed from new to reviewing

#10 @boonebgorges
6 years ago

This is looking good. I'm going to write some docs and make the tests a little more verbose (they're currently a little tricky ;) )

#11 @boonebgorges
6 years ago

  • Resolution set to fixed
  • Status changed from reviewing to closed

In 31306:

Introduce setExpectedDeprecated() and setExpectedIncorrectUsage() methods to `WP_UnitTestCase.

These methods provide a procedural alternative to the @expectedDeprecated
and @expectedIncorrectUsage test annotations, and parallel PHPUnit's native
setExpectedException().

Props prasoon2211, jdgrimes.
Fixes #28486.

Note: See TracTickets for help on using tickets.