Make WordPress Core

Opened 12 years ago

Closed 12 years ago

Last modified 3 years ago

#28486 closed enhancement (fixed)

Base unit test does not have setExpectedDeprecated method

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

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 12 years ago.
28486.2.diff​ (1.1 KB ) - added by prasoon2211 12 years ago.
Version 2
28486.3.diff​ (1.3 KB ) - added by prasoon2211 12 years ago.
Version 3

Download all attachments as: .zip

Change History (14)

#1 @DrewAPicture
12 years ago

  • Keywords needs-patch added

+1 makes sense to me.

#2 @wonderboymusic
12 years ago

  • Milestone Awaiting Review → Future Release

#3 @boonebgorges
12 years ago

Also setExpectedIncorrectUsage().

#4 @prasoon2211
12 years ago

Hey guys. New guy here :)

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

#5 @jdgrimes
12 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.

#6 @prasoon2211
12 years ago

I forgot the test for the other method!

#7 @prasoon2211
12 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
12 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
12 years ago

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

#10 @boonebgorges
12 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
12 years ago

  • Resolution → fixed
  • Status reviewing → 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.