Is there a headless browser library for PHP? Would like something that has a JS engine built into it. FOSS preferred.
PhantomJS - http://phantomjs.org/
PhantomJS is a headless WebKit with JavaScript API. It has fast and native support for various web standards: DOM handling, CSS selector, JSON, Canvas, and SVG.
You can couple it with something like php-PhantomjsRunner (now deprecated) if you want or bake your own.
When setup and ready to start testing with PhantomJS, pick out one of the various Testing Frameworks at your disposal.
I recently also came across this tutorial from tutsplus should it help anyone.