I do not 100% grasp the example in your question, however if I understand it right you want to test the SoapWrap
unit and it has SoapClient
as a collaborator.
Now when you create a test if SoapWrap::getStations()
returns an array - which it actually always does - the test will always pass. So for your first question about the failed test until it is implemented (as in Test Driven Development (TDD): Test Fails (Red); Write as little code as only needed until it passes (Yellow (or: Green)); Refactor the code (Green (or: Blue))), but you did it the wrong way. You must have written the test before writing the code, e.g. the first time you call the test, PHPunit should crash with a fatal error that the SoapWrap
class is not found and can not be instantiated because so far it has not been written.
So delete it now and try to forget the code you've done so far, re-run the test to see it fail and then write it new.
Ensure you've unit-tested the class of $StationFilter
before that, too.
For the second part of your question about the mocking: You mock the collaborators, here most likely the SoapClient::GetStations()
method. This will spare you to actually run the remote request via SOAP. That easy it is already. You mock the collaborators to test the unit.