[wp-trac] [WordPress Unit Tests] #134: Fix intermittent failures with meta tests

WordPress Trac wp-trac at lists.automattic.com
Fri Oct 12 18:36:20 UTC 2012


#134: Fix intermittent failures with meta tests
-------------------------+----------------------------
 Reporter:  kurtpayne    |       Type:  defect
   Status:  new          |   Priority:  normal
Milestone:               |  Component:  Test Framework
 Keywords:  2nd-opinion  |
-------------------------+----------------------------
 I see intermittent failures with the meta tests like the below:

 {{{
 There were 2 failures:

 1) Tests_Post_Query::test_meta_key_or_query
 Failed asserting that two arrays are equal.
 --- Expected
 +++ Actual
 @@ @@
  Array (
 -    0 => 719403
 +    0 => 719406
      1 => 719404
      2 => 719405
 -    3 => 719406
 +    3 => 719403
  )

 /var/lib/jenkins/workspace/WordPress/tests/post/query.php:49
 /usr/bin/phpunit:46

 2) Tests_Post_Query::test_meta_key_and_query
 Failed asserting that two arrays are equal.
 --- Expected
 +++ Actual
 @@ @@
  Array (
 -    0 => 719410
 -    1 => 719414
 -    2 => 719415
 +    0 => 719414
 +    1 => 719415
 +    2 => 719410
  )
 }}}

 It appears to be an ordering issue.  The arrays contain the same elements,
 but in a different order.  The arrays are a result of `WP_Query` call with
 no `order` parameter.  MySQL does not seem to be ordering the results
 consistently.

 I propose a comparison using `array_diff()` to ensure the arrays contain
 the same elements, but ignoring the order.

-- 
Ticket URL: <http://unit-test.trac.wordpress.org/ticket/134>
WordPress Unit Tests <http://unit-test.trac.wordpress.org>
My example project


More information about the wp-trac mailing list