php - Mocking a non class method in phpunit -
i've run situation phpunit. have class includes php file contains non class methods. in class have method calls function. below example of setup.
class foo { public function getinfo() { .... $this->getfunctions(); $data = functionfromrequire(); .... } public function getfunctions() { return require_once '/path/to/file/functions.php'; } }
phpunit getmock mocks class functions. there anyway mock non class functions phpunit? google results seem take me mocking class functions. in advance!
in short, phpunit did not have functionality mock namespaces find. did refactoring @markdwhite suggested. created new class included old file. used magic __call() , call_user_func_array() php functions in newly created class. since there many namespace functions manually redo. hope helps else!
Comments
Post a Comment