Re: Small annoyances of PHP: Simple fixes would make tests fail
| From: | Rowan Tommins | Date: | Mon, 22 Feb 2021 14:05:25 +0000 |
| Subject: | Re: Small annoyances of PHP: Simple fixes would make tests fail | ||
| References: | 1 2 3 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-113216@lists.php.net to get a copy of this message | ||
On 22/02/2021 10:14, Christian Schneider wrote:
Side-note: Maybe we should recommend a function to be used for tests. At my work we used to use var_export(), some of our newer tests are using json_encode() but neither is really guaranteed to be stable, right?Well, the obvious choice to me would be var_dump, which is used by the majority of PHP's internal tests (see https://externals.io/message/112967#112971 for some numbers). I was considering putting together a pull request that standardises on that for all bundled extensions, fixing the few hundred (out of thousands) that use var_export or print_r. However, I've never used PHPT-style tests outside of PHP internals, and for anything like PHPUnit or PHPSpec you would normally be testing against actual PHP values, not any string representation; so I don't really have any opinion on that scenario. Regards, -- Rowan Tommins [IMSoP]