The way we’ve been developing, many of our PHP files are included only with the expectation that they will output content; no methods are called, etc. My question is, what’s the “correct” way to test this with PHPUnit? Should I have the require placed in the setUp so that it waits till then to run, or is that considered bad mojo?
The way we’ve been developing, many of our PHP files are included only with
Share
That’s about the only way you can test it. I assume you’re planning to use output buffering to capture the content produced so that you can check it against expectations.
The best way is probably to refactor your code so as much work as possible is being done in self-contained classes / functions that return results to the caller, suitable for being tested from PHPUnit in a more conventional way.