[wp-trac] [WordPress Trac] #59482: Tests: Introduce Reflection API helper methods.

WordPress Trac noreply at wordpress.org
Tue Jan 9 17:24:28 UTC 2024


#59482: Tests: Introduce Reflection API helper methods.
--------------------------------------+-----------------------
 Reporter:  costdev                   |       Owner:  costdev
     Type:  enhancement               |      Status:  assigned
 Priority:  normal                    |   Milestone:  6.5
Component:  Build/Test Tools          |     Version:
 Severity:  normal                    |  Resolution:
 Keywords:  has-patch has-unit-tests  |     Focuses:
--------------------------------------+-----------------------

Comment (by hellofromTonya):

 Some intentional thoughts about the proposal (not yet at the PR
 implementation):

 I support adding this test API. Make it easier for contributors while
 keeping consistency and resetting values and visibility after testing.

 I think it can be improved and possibly extended for things like resetting
 and helpers for `static`.

 Naming:

 I'm thinking the `reflect_and_*` naming could be confusing for
 contributors. Instead, using the PHP class name could help to align it for
 better understanding and ease of recognizing its relation to the PHP
 Reflection API:

 * `get_reflectionproperty_value()`
 * `set_reflectionproperty_value()`
 * `invoke_reflectionmethod()`

 Extending:

 Statics are handled slightly differently than objects. Might be good to
 extend the API to include statics such as
 `get_static_reflectionproperty_value()`.

 Resetting:

 Instantiating and resetting visibility and values with each API method
 call might get too heavy for the test suite performance. Instead, @costdev
 have you considered storing the details and then resetting (visibilities
 and values) at `tear_down()`?

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


More information about the wp-trac mailing list