tags:

views:

30

answers:

0

I'm implementing the specification pattern. I've written an unsatisfying test for my LogicalAnd specification. The test is 'acceptsAnyNumberOfSpecificationAsParts'. How can I make this test independent of the order of the containing specifications? One caveat: I'm not 'getting' the containing parts and I'm not willing too.

I currently have:

first = new LogicalAnd(Spec1, Spec2, Spec3)
second = Spec1.lAnd(Spec2).lAnd(Spec3)
assertEquals(first, second)

and works, but is implementation dependent since changing the order of the Specs will fail the test. Working in PHP also doesn't help me much.