RU beehive logo ITEC dept promo banner
ITEC 325
2018fall
ibarland

testing forms

We've been talking about input forms (html elements), and then php scripts to process a submitted form:

testing a form-handler

video: easily testing a form-handler (18m38s)

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 $_POST, and then require's the form-handler. Recall the sample form from last lecture (and recall what happens when it submits). Then, inspect:

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
logo for creative commons by-attribution license
This page licensed CC-BY 4.0 Ian Barland
Page last generated
Please mail any suggestions
(incl. typos, broken links)
to ibarlandradford.edu
Rendered by Racket.