开发者

Can I test code not contained within a class with PHPUnit?

开发者 https://www.devze.com 2023-02-01 06:59 出处:网络
Iwant to test so开发者_如何学运维me functions in a php file, but that code is not in a class. Can I still test it with PHPUnit?You could create a utility class that calls the functions.

I want to test so开发者_如何学运维me functions in a php file, but that code is not in a class. Can I still test it with PHPUnit?


You could create a utility class that calls the functions.

class GlobalFunctions {
    public function call_your_function($a, $b, $c) {
        return yourfunction($a, $b, $c);
    }
}

And then write tests for that class.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号