--cgi option needed for this test, type 'pear help run-tests'
My phpt file was as follows:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--TEST-- | |
Example test emulating a file upload | |
--SKIPIF-- | |
<?php if (php_sapi_name()=='cli') die('skip'); ?> | |
--POST_RAW-- | |
Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryfywL8UCjFtqUBTQn | |
------WebKitFormBoundaryfywL8UCjFtqUBTQn | |
Content-Disposition: form-data; name="file"; filename="example.txt" | |
Content-Type: text/plain | |
Some file data .... | |
------WebKitFormBoundaryfywL8UCjFtqUBTQn | |
Content-Disposition: form-data; name="submit" | |
Upload | |
------WebKitFormBoundaryfywL8UCjFtqUBTQn-- | |
--FILE-- | |
<?php | |
var_dump($_FILES['file']['name']); | |
?> | |
--EXPECT-- | |
string(11) "example.txt" |
sudo apt-get install php5-cgi
This 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