[wp-trac] [WordPress Trac] #29718: Improved coverage for WP_Tax_Query unit tests

WordPress Trac noreply at wordpress.org
Mon Sep 22 13:19:30 UTC 2014


#29718: Improved coverage for WP_Tax_Query unit tests
--------------------------+------------------------------
 Reporter:  boonebgorges  |       Owner:
     Type:  enhancement   |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  Taxonomy      |     Version:
 Severity:  normal        |  Resolution:
 Keywords:  has-patch     |     Focuses:
--------------------------+------------------------------

Comment (by boonebgorges):

 > it might be worth taking a more dynamic tack to testing taxonomy APIs
 using random, factory-generated taxonomies (hierarchical or non-
 hierarchical as needed) whenever possible.

 Thanks for this idea. I had the same basic thought when looking at these
 tests, but decided to go the conservative route for the time being. That
 being said, the general principle here ought to be that you should be
 testing as few things as possible per test. In the case of taxonomies, you
 correctly note that built-in taxonomies are "special" in terms of their
 core treatment. This suggests that the baseline is a generated (non-built-
 in) taxonomy, with 'post_tag' and 'category' being tested only when there
 is a reason to believe that they differ from the baseline.

 I'm not sure whether it makes technical sense to have a factory for
 taxonomies, given that (a) they're not database objects, and (b) they
 pollute the global and so need a different cleanup method than a MySQL
 transaction rollback. So I'd suggest that, for now, we can do the
 following in any relevant test (or even setUp()/tearDown() class methods):

 {{{
 register_taxonomy( 'foo', 'post' );

 // test

 _unregister_taxonomy( 'foo' );
 }}}

 If others prefer this, I can rewrite the patch to use this technique
 instead of 'post_tag' and 'category'.

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


More information about the wp-trac mailing list