Re: Easy method of overriding built-in php functions.
| From: | David Lundgren | Date: | Wed, 16 Aug 2017 20:47:34 +0000 |
| Subject: | Re: Easy method of overriding built-in php functions. | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-100235@lists.php.net to get a copy of this message | ||
On 8/16/17 3:02 PM, Ryan Jentzsch wrote:
> I am aware of Advanced PHP debugger but what I need this type of
> functionality for is mocking and testing.
If you're using namespaces you can try overriding the built-in functions
that way. I've done this successfully in my own library for mocking ldap
and imap function calls (https://git.io/v7ALm)
Original post about the idea.
http://www.manuel-strehl.de/dev/overwrite_PHP_built-in_functions.en.html
> As an example I want to use PHPUnit mocking feature to create a mock
> of a class. However in the constructor of this class is the following
> line to get the expected JSON string:
There is the php-mock library, which appears to have integration for
PHPUnit, Mockery, and Prophecy. I can't vouch for it as I've not used it
yet.
https://github.com/php-mock/php-mock
Dave
--
David Lundgren
dlundgren@syberisle.net
GPG: 0x26F54D7F