Skip to content

Instantly share code, notes, and snippets.

@favrik
Last active December 21, 2015 02:49
Show Gist options
  • Save favrik/6238024 to your computer and use it in GitHub Desktop.
Save favrik/6238024 to your computer and use it in GitHub Desktop.
Using https://github.com/php-test-helpers/php-test-helpers we can rename functions to help unit testing. This is a utility function.
<?php
function stub_function($function) {
if (!function_exists($function)) {
// Create dummy function.
$string = 'function ' . $function . "() {}";
eval($string);
}
rename_function($function, $function . '_orig');
rename_function($function . '_stub', $function);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment