[wp-trac] [WordPress Trac] #29827: Leftover taxonomies break later tests

WordPress Trac noreply at wordpress.org
Thu Oct 2 13:24:20 UTC 2014


#29827: Leftover taxonomies break later tests
------------------------------+---------------------------
 Reporter:  boonebgorges      |       Owner:  boonebgorges
     Type:  defect (bug)      |      Status:  accepted
 Priority:  normal            |   Milestone:  4.1
Component:  Build/Test Tools  |     Version:
 Severity:  normal            |  Resolution:
 Keywords:  2nd-opinion       |     Focuses:
------------------------------+---------------------------
Changes (by boonebgorges):

 * milestone:  Future Release => 4.1


Comment:

 Tore my hair out a bit more over this one.

 nacin's suggestion of catching everything on the 'register_taxonomy' and
 'register_post_type' hooks won't work. Some test classes call
 create_initial_taxonomies(), and it's likely that other tests do weird
 things where they reregister builtin post types. When that happens, and
 they get added to the $registered_taxonomy/post_type list, they later get
 unregistered, which is not what we want.

 So, I tried something like this: during setUp(), record all existing
 taxonomies, then during tearDown(), unregister `array_diff( $existing,
 get_taxonomies() )`. But this causes problems that are similar to (though
 a bit less pervasive than) nacin's suggestion. I started to look though
 the tests to see where they were doing messy stuff, but that's such an
 enormous task that I'd rather avoid it.

 [attachment:29827.3.patch] goes back to the initial suggestion, and adds
 support for post types, which requires a rewrite rule flush. This is
 pretty foolproof, and speed difference is pretty negligible.

 This change caused one error in a test (test_get_the_taxonomies()), which
 can be traced back to the fact that `create_initial_taxonomies()` does not
 explicitly declare 'hierarchical=false' for 'post_tag', and
 `register_taxonomy()` only sets this key if you are using a non-default
 permastruct. I'm fairly sure this is a bug, so patch attached, but this
 could use the eyes of someone more familiar with how rewrite rules should
 be regenerated between tests. (Note that the PHPUnit error only occurs
 when you run the whole suite - so comment out my taxonomy.php fix and run
 it to see what I'm talking about.)

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


More information about the wp-trac mailing list