Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:100235 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 73573 invoked from network); 16 Aug 2017 20:47:41 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 16 Aug 2017 20:47:41 -0000 Authentication-Results: pb1.pair.com header.from=dlundgren@syberisle.net; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=dlundgren@syberisle.net; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain syberisle.net designates 96.126.116.40 as permitted sender) X-PHP-List-Original-Sender: dlundgren@syberisle.net X-Host-Fingerprint: 96.126.116.40 mail.syberisle.net Received: from [96.126.116.40] ([96.126.116.40:43354] helo=li341-40.members.linode.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 37/28-34801-B6FA4995 for ; Wed, 16 Aug 2017 16:47:39 -0400 Received: from localhost (admin.local [127.0.0.1]) by li341-40.members.linode.com (Postfix) with ESMTP id D3AC825477 for ; Wed, 16 Aug 2017 16:47:36 -0400 (EDT) X-Virus-Scanned: Debian amavisd-new at syberisle.net Received: from li341-40.members.linode.com ([127.0.0.1]) by localhost (syberisle.net [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id NUV5gh2su6PP for ; Wed, 16 Aug 2017 16:47:36 -0400 (EDT) Received: from oo-laptop.local (cpe-65-29-233-211.wi.res.rr.com [65.29.233.211]) (Authenticated sender: dlundgren@syberisle.net) by li341-40.members.linode.com (Postfix) with ESMTPSA id DD6262524B for ; Wed, 16 Aug 2017 16:47:35 -0400 (EDT) To: internals@lists.php.net References: Message-ID: <4a087c99-9bd8-a368-f88f-25bc0c12dcf4@syberisle.net> Date: Wed, 16 Aug 2017 15:47:34 -0500 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Subject: Re: [PHP-DEV] Easy method of overriding built-in php functions. From: dlundgren@syberisle.net (David Lundgren) 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