[wp-trac] [WordPress Trac] #30522: WP_UnitTestCase::assertEqualSets can pass incorrectly

WordPress Trac noreply at wordpress.org
Thu Nov 27 15:35:53 UTC 2014


#30522: WP_UnitTestCase::assertEqualSets can pass incorrectly
------------------------------+------------------------------
 Reporter:  dd32              |       Owner:
     Type:  defect (bug)      |      Status:  new
 Priority:  normal            |   Milestone:  Awaiting Review
Component:  Build/Test Tools  |     Version:
 Severity:  normal            |  Resolution:
 Keywords:  has-patch         |     Focuses:
------------------------------+------------------------------

Comment (by bobbingwide):

 If I remember correctly, see Nov 6 slack archive, I reported one of the
 problems with the PHPUnit tests  tests could be that assertEqualSets
 ignores duplicate keys so doesn't notice get_pages() returning
 array(3,4,5,5) when it should be  array(3,4,5);


 I believe there is a need to include a test that ensures the arrays are
 the same without involving sorting.
 e.g. for a query where you want to get posts 1,4,3,2 in that order, then
 the expected array should be ( 1,4,3,2 ) in that order.

 Q. Can't assertEquals be used for that specific test?

 I received a response from @dancameron who said

 I wrote the tests in r30096 for #12668. I believe `assertEquals` respects
 order and `assertEqualSets` does not. It's possible my tests are wrong
 though, even though they succeeded pre & post. Let me know what you find
 and I can take a look; maybe a new ticket is in order (?).

 If the answer to my above Q. is No, then I believe that this is the ticket
 that I should have raised.

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


More information about the wp-trac mailing list