[wp-trac] [WordPress Unit Tests] #130: Introduce assertion for comparing sets

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


#130: Introduce assertion for comparing sets
----------------------------+------------------
 Reporter:  scribu          |       Owner:
     Type:  enhancement     |      Status:  new
 Priority:  normal          |   Milestone:
Component:  Test Framework  |  Resolution:
 Keywords:  has-patch       |
----------------------------+------------------
Changes (by kurtpayne):

 * cc: kpayne@… (added)


Comment:

 I'm a fan of this.

 Replying to [comment:3 bpetty]:
 > While this seems handy, it's not hard to use array_diff() directly

 Actually, I think scribu made a wonderful point here.

 Quoting [comment:4 scribu]:
 > a single array_diff() call is only half the test. You need 2 to make
 sure two sets are actually equal.

 ``
 Replying to [comment:3 bpetty]:
 > it keeps the code in the unit test clear

 Think this is pretty clear.  I think the name should be changed to
 `assertEqualArray`, though.  This is in line with the precedent set by
 `assertEqualXMLStructure`.

 > without using custom assertion methods that new developers that are
 plenty familiar with PHPUnit, but not familiar with WP quickly get
 confused on.
 >
 > If I see a method that starts with "assert", I'm immediately assuming
 it's a call into PHPUnit.

 I don't have data to back this up, but my impression is that there are
 more developers familiar with WP and unfamiliar with phpunit than
 developers who are familiar with phpunit and unfamiliar with WP.  I think
 you have a valid point, but I don't think it should prevent us from moving
 forward.

 +1 on moving forward with this.

 I would like to update patch to include the changes in #134, to use this
 method.

-- 
Ticket URL: <http://unit-tests.trac.wordpress.org/ticket/130#comment:5>
WordPress Unit Tests <http://unit-tests.trac.wordpress.org>
My example project


More information about the wp-trac mailing list