howto: run tests in browser
Notice: This thread is very old.
- Jan Tvrdík
- Nette guru | 2595
You need to configure web server to process PHP in *.phpt
files
and then you can just open it in a browser. Because tests usually do not output
anything you don't need to add <pre>
or change content type
to text/plain
.
- Milo
- Nette Core | 1283
As @JanTvrdík wrote, the best way is to configure Apache/Nginx to
handle *.phpt
too. If not possible, do it by some script with only
require 'path/to/test.phpt';
. But be careful about security. The
purpose is just to run test file as an ordinary PHP script.
In test's bootstrap, you can distinguish between current environments and do setup (Content-Type for example):
if (getenv(Tester\Environment::RUNNER)) {
# Running by Tester (e.g. vendor/bin/tester tests/MyTest.phpt)
} elseif (PHP_SAPI === 'cli') {
# Running as ordinary CLI script (e.g. php tests/MyTest.phpt)
} else {
# Browser
}