Simpletest and brittle test cases

I’ve been thoroughly annoyed the last 2 days with Simpletest.

The mock objects have some unexpected behaviour when setting return values for their methods:

$someMock->setReturnValue('get', 123);
$someMock->setReturnValue('get', 234);

Which value does it use? 123. It doesn’t overwrite the first set value. How do we get around this problem? Like this:

$someMock->setReturnValueAt(0, 'get', 123);
$someMock->setReturnValueAt(1, 'get', 234);

setReturnValueAt() allows you to specifiy return values for any additional calls to that method. This is all dandy, but its making my test cases very brittle by creating a tight coupling between my test case and the code being tested.

What I want to be able to do is:

1) set the return value for the mock object
2) run the test that calls this method, not caring how many times the method is called (for argument sake, lets say this is a simple getter method).
3) set the return value for the mock object to something else
4) run another test

I don’t see any way of doing this other that creating a new instance of the mock object. O well.