PHP测试包括仅输出的文件

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?

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.

If your application is a web application (i.e.: outputs content that requires a browser to be readable), then PHPUnit is integrated with Selenium, which is a Web Application Testing System. It's indeed very useful, especially since it has a Firefox plugin.

You can read more on PHPUnit and Selenium in the PHPUnit Manual.

If your templates (i.e.: include files) are used in command line scripts, then use output_buffering and regular expression assertions or regular assertions (i.e.: assertRegExp, assertEquals).