How can I write tests for file upload in PHP?

后端 未结 4 1371
小鲜肉
小鲜肉 2020-12-15 21:14

I\'m using simpleTest to write my PHP tests. I\'m writing a file upload plugin and was wondering how I may be testing it.

I would like to check that the file is corr

4条回答
  •  渐次进展
    2020-12-15 21:56

    You can generate a file upload in a programmatic manner with e.g. the curl extension.

    Since this requires PHP running under a web server, it's not much of a unit test. Consequently, the best way would be to to use PHPT tests and fill the --POST_RAW-- section with the data.

    If you don't know what to put in the --POST_RAW--, try to install the TamperData Firefox extension, do a file submission from Firefox, and copy-paste the data from the right side.

提交回复
热议问题