In my unit test, i'm looking to stub the behaviour of php's inbuilt file_get_contents() method.
Is there a way to stub native methods in PHP (such as file_get_contents() or print_r()) and the likes?
In my unit test, i'm looking to stub the behaviour of php's inbuilt file_get_contents() method.
Is there a way to stub native methods in PHP (such as file_get_contents() or print_r()) and the likes?
You aren't clear about what 'stub' means.
Do you mean getting doc for functions, like:
/**
* (PHP 5 >= 5.1.0)<br/>
* Sets the default timezone used by all date/time functions in a script
* @link http://php.net/manual/en/function.date-default-timezone-set.php
* @param timezone_identifier string <p>
* The timezone identifier, like UTC or
* Europe/Lisbon. The list of valid identifiers is
* available in the .
* </p>
* @return bool This function returns false if the
* timezone_identifier isn't valid, or true
* otherwise.
*/
function date_default_timezone_set ($timezone_identifier) {}
?
If by "stub" you mean replace, there is a PHP override_function function; it's part of PECL though. You can also rename them.