james
james

Reputation: 3583

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

I want to test some functions in a php file, but that code is not in a class. Can I still test it with PHPUnit?

Upvotes: 1

Views: 108

Answers (1)

Stephen
Stephen

Reputation: 18964

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.

Upvotes: 1

Related Questions