Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork5
Mock non deterministic built-in PHP functions (e.g. time() or rand()) with Mockery.
License
php-mock/php-mock-mockery
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
This package integrates the function mock libraryPHP-Mock with Mockery.
UseComposer:
composer require --dev php-mock/php-mock-mockery
PHPMockery::mock()let's you build a function mock which can be equipedwith Mockery's expectations. After your test you'll have to disable all createdfunction mocks by callingMockery::close().
namespacefoo;usephpmock\mockery\PHPMockery;$mock = PHPMockery::mock(__NAMESPACE__,"time")->andReturn(3);assert (3 ==time());\Mockery::close();
This library comes with the same restrictions as the underlyingphp-mock:
Onlyunqualified function calls in a namespace context can be mocked.E.g. a call for
time()in the namespacefoois mockable,a call for\time()is not.The mock has to be defined before the first call to the unqualified functionin the tested class. This is documented inBug #68541.In most cases you can ignore this restriction. But if you happen to run intothis issue you can call
PHPMockery::define()before that first call. This would define a side effectless namespaced function.
This project is free and under the WTFPL.Responsable for this project is Markus Malkuschmarkus@malkusch.de.
If you like this project and feel generous donate a few Bitcoins here:1335STSwu9hST4vcMRppEPgENMHD2r1REK
About
Mock non deterministic built-in PHP functions (e.g. time() or rand()) with Mockery.
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Sponsor this project
Uh oh!
There was an error while loading.Please reload this page.
Packages0
Uh oh!
There was an error while loading.Please reload this page.
Contributors2
Uh oh!
There was an error while loading.Please reload this page.