[wp-trac] [WordPress Trac] #28486: Base unit test does not have setExpectedDeprecated method

WordPress Trac noreply at wordpress.org
Mon Feb 19 14:20:48 UTC 2024


#28486: Base unit test does not have setExpectedDeprecated method
------------------------------+---------------------------
 Reporter:  rmccue            |       Owner:  boonebgorges
     Type:  enhancement       |      Status:  closed
 Priority:  normal            |   Milestone:  4.2
Component:  Build/Test Tools  |     Version:  3.7
 Severity:  normal            |  Resolution:  fixed
 Keywords:  has-patch         |     Focuses:
------------------------------+---------------------------

Comment (by jnvrllms):

 The absence of a setExpectedDeprecated method in PHPUnit is indeed a
 notable oversight, especially considering the consistent pattern of having
 functional counterparts for various annotations. This omission becomes
 particularly apparent with the introduction of the @expectedDeprecated
 annotation. In PHPUnit, the @expectedException annotation has a
 corresponding setExpectedException method, which allows developers to
 programmatically set the expected exception for a test case.

 In the absence of setExpectedDeprecated, developers are left with a
 discrepancy in functionality when attempting to handle deprecated code
 warnings in their unit tests. While they can use @expectedDeprecated, the
 lack of a functional counterpart limits their ability to programmatically
 define the expected deprecated behavior within the test methods
 themselves.

 Adding a setExpectedDeprecated method would provide consistency and
 convenience, aligning with PHPUnit's design philosophy. This addition
 would allow developers to dynamically set the expected deprecated features
 within their test methods, offering greater flexibility and control over
 their testing scenarios.

 By introducing setExpectedDeprecated, PHPUnit would empower developers to
 seamlessly handle deprecated code warnings in their unit tests, ensuring
 comprehensive test coverage and facilitating smoother migration paths when
 updating codebases. This enhancement aligns with PHPUnit's commitment to
 providing robust testing tools and further streamlines the testing process
 for developers.

 Overall, the addition of setExpectedDeprecated would be a welcomed
 improvement to PHPUnit, addressing a notable gap in functionality and
 enhancing the testing experience for developers working with deprecated
 code.

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


More information about the wp-trac mailing list