Stub icon indicating copy to clipboard operation
Stub copied to clipboard

Support for argument expectations in Stubs

Open rbait opened this issue 5 years ago • 3 comments

Basic support for argument expectactions in Stubs, by chaining a with() method to Expected. This is something we were really missing compared to plain PHPUnit mocks, and turned out to be not that hard to add.

Syntax: Stub\Expected::once()->with('argument', 1, new StdClass)

Fully backwards compatible and unit tests have been added

rbait avatar Jul 28 '20 22:07 rbait

@SamMousa no problem, I'll also wait a bit for more feedback so I can fix it all in one go

rbait avatar Jul 29 '20 20:07 rbait

Added both requested PHPDocs

rbait avatar Aug 22 '20 13:08 rbait

To be honest, I'm a bit confused. What can be changed in this repo in order to fix those docs? I suppose not much? And it doesn't make sense to update the docs on the website without the functionality being present right?

It seems https://codeception.com/docs/reference/Stub doesn't really have much documentation about Expected. Looks like it's all on https://codeception.com/docs/reference/Mock, so probably makes more sense to add it in there?

As for https://codeception.com/docs/05-UnitTests#Test-Doubles, it's also not mentioning anything about Expected, but references the other pages, so I guess it's fine to leave that one as-is.

Please suggest which way you'd like me to proceed so we can get this PR merged.

On a side note, this PR fixes issue https://github.com/Codeception/Stub/issues/32

rbait avatar Jan 24 '21 09:01 rbait