Codeception / Stub

Flexible Stub wrapper for PHPUnit's Mock Builder
MIT License
295 stars 17 forks source link

Support for argument expectations in Stubs #26

Open rbait opened 4 years ago

rbait commented 4 years ago

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 commented 4 years ago

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

rbait commented 4 years ago

Added both requested PHPDocs

rbait commented 3 years ago

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