Saturday, January 22, 2011

Pear run-tests: Setting --cgi option to test file uploads using phpt

In PHP, file uploads can be tested using phpt files as explained here. However, when I wanted to execute phpt test with --POST_RAW-- or --POST-- sections, pear run-tests was giving an error that: --cgi option needed for this test, type 'pear help run-tests' My phpt file was as follows: The layout of phpt files is explained here. To overcome this problem I installed php5-cgi package for ubuntusudo apt-get install php5-cgiThis allowed for correct execution of the testpear run-tests --cgi=/usr/lib/cgi-bin/php5 example-upload.phpt
Running 1 tests
PASS Example test emulating a file upload[example-upload.phpt]
TOTAL TIME: 00:00
1 PASSED TESTS
0 SKIPPED TESTS