NavigationUser login |
I Want a goto and I Want it NOW!This evening I was working on testing some code that is called by AJAX. It returns a string which is either "OK", if everything is fine or something else, if it isn't. If something else is returned the user is alerted. So to test this I pull it into my test framework - except that the calls to "exit" mess everything up and make the test framework exit too. wget and curl are too clunky so, proceeding with the elegant solution I need to change the code so that instead of exiting it jumps to the end of the script, that way it will return to the test suite even if there is a problem. I'm sure PHP has a GOTO so go look in the documentation - its 5.30 - nightmare! So instead move the AJAX code into a function and change the exit calls to be returns. Ta-da unit testable AJAX. Still this is a milestone. The first time in my life I ever wanted a goto.
|
Recent blog posts |