Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Mock non deterministic built-in PHP functions (e.g. time() or rand()) with Mockery.

License

NotificationsYou must be signed in to change notification settings

php-mock/php-mock-mockery

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

45 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

.github/workflows/tests.yml

Mock PHP built-in functions with Mockery

This package integrates the function mock libraryPHP-Mock with Mockery.

Installation

UseComposer:

composer require --dev php-mock/php-mock-mockery

Usage

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().

Example

namespacefoo;usephpmock\mockery\PHPMockery;$mock = PHPMockery::mock(__NAMESPACE__,"time")->andReturn(3);assert (3 ==time());\Mockery::close();

Restrictions

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 fortime() in the namespacefoo is 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 callPHPMockery::define()before that first call. This would define a side effectless namespaced function.

License and authors

This project is free and under the WTFPL.Responsable for this project is Markus Malkuschmarkus@malkusch.de.

Donations

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

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published

Contributors2

  •  
  •  

Languages


[8]ページ先頭

©2009-2025 Movatter.jp