[wp-trac] [WordPress Trac] #26475: Hierarchical meta box display issues when messing around with new terms

WordPress Trac noreply at wordpress.org
Tue Mar 17 15:05:50 UTC 2015


#26475: Hierarchical meta box display issues when messing around with new terms
--------------------------+-----------------------------
 Reporter:  ericlewis     |       Owner:
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Future Release
Component:  Taxonomy      |     Version:  3.8
 Severity:  normal        |  Resolution:
 Keywords:  has-patch     |     Focuses:
--------------------------+-----------------------------
Changes (by tyxla):

 * keywords:  has-patch needs-unit-tests => has-patch


Comment:

 @boonebgorges, yeah, unit tests would be great for this case indeed. I
 actually intended to create some tests that would cover that use case, but
 I quickly got dissuaded.

 Basically, what `wp_terms_checklist()` does is to output the term checkbox
 list HTML - the `<li>`s with the `<input>`s / `<label>`s and `<ul>`s for
 going into hierarchy depth. Also, each checkbox cah be checked, and there
 can be additional classes and there are many attributes.

 This would make any unit tests of the `wp_terms_checklist()` function very
 fragile and unstable, unreliable when any changes are done to the output.
 For example even if a single space is added somewhere in the
 `Walker_Category_Checklist` class (it is used for creating the
 `wp_terms_checklist()` hierarchy), this would cause these tests to fail.

 Therefore you can guess that any tests of that function will be very ugly
 themselves. That's why I didn't post any test here.

 So I'll add the test that I've written for that functionality, but IMHO
 such tests should not be committed - they're too ugly, clumsy and fragile.

 In my opinion, the better way to go with this would be to completely
 rewrite `wp_terms_checklist()` to use another proxy function that would
 only return the term hierarchy. Then we would add tests to that proxy
 function without bothering with the output HTML. But this would be the
 subject of another ticket, I think. Let me know if you feel I'm correct
 about that and I'll open that ticket and gladly take care of it, as well
 as of its tests.

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


More information about the wp-trac mailing list