|
We've been talking about input forms (html elements), and then php scripts to process a submitted form:
<!-- inside form.php (or, form.html) --> <form submit='submit.php' action="post"> Login: <input type='text' name='userid' /> <br /> Remember me?: <input type='checkbox' name='remember' value='yep' /> … </form> |
<!-- inside submit.php --> <?php echo "Hey there ", $_POST['userid']; if (array_has_index('remember',$_POST)) { echo "How could I ever forget?"; // $_POST['remember'] = 'yep' } ?> |
Our functions have test cases, and this helps gives us confidence before we ever deploy to the web. But what about form-handlers? The result from form-handler is a long page that includes various bits from the form. It's too tedious to make this a check/expect sort of test, since the details of the html part of the output aren't relevant (and might change). Moreover, generating the page requires the POST data, that were entered by hand back in the form. But we would like to be able to check that the form-handler without going through the web, and also eyeball-check the result on certain inputs w/o having to continually re-type the inputs and call up the form.
Solution:
Make a php program which simply initializes
Awesome sauce: We can run these handler-tests locally, or over the web. The former is useful when the latter isn't showing up as expected.Although we use these to manually test our handler, they are not unit tests (they're not automated). Admittedly, the filename topic-handle-sample-input-N.php might be better a more descriptive name than just topic-handle-test-N.php, but we'll concede to a shorter, more convenient name. video from distance lecture (breeze), 2017-feb-14 (1h23m), REVIEWING this info
This page licensed CC-BY 4.0 Ian Barland Page last generated 2018.Jan.31 (Wed) | Please mail any suggestions (incl. typos, broken links) to ibarlandradford.edu |