I’ve written a few little functions to help me sanitise content before including it in automatically generated JavaScript. The idea is to prevent code injection.
You can see the tests for my function in the scriptify_test.php file on ProgClub Member Net (where jsphp.co is hosted). You can view the scriptify unit tests in pcrepo.
Unit testing is fun! :)