开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜