php - Mocking raw POST data -


I am writing cases of PHPUnit testing for a web application. As the tests run in a command line environment, I am joking about several predefined variables such as $ _ POST , $ _ GET , $ _ server < / Strong>, etc. My test is to ensure that my controller class reads properly JSON input (which is sent as raw via POST POST and php: // input ). The question is, how can I manipulate the value of php: // input without running a web server? Post data, whatever is fed to stdin of PHP, tells CONTENT_LENGTH PHP on the environment variable to read how many bytes are I to read (so to change the post data, you just pipe in some different)

GET data is in the QUERY_STRING environment variable.

Look for other environment variables is useful for using PHP to populate things like $ _SERVER


Comments

Popular posts from this blog

c# - How to capture HTTP packet with SharpPcap -

php - Multiple Select with Explode: only returns the word "Array" -

php - jQuery AJAX Post not working -