Search code examples
symfonyphpunitfunctional-testing

"Click" node other than anchor in Symfony2 functional test


I have a <li> element, which has a click listener bound to it with jQuery. Is it possible to "click" this element with the client/crawler, to test the result. So far I have only found ways to follow anchor links.

Thanks


Solution

  • You can't do anything involving Javascript with a PHP Crawler like the one provided by Symfony2.

    What you must look at is functional testing with a fake browser, like CasperJS. With it, you can pilot a headless WebKit browser, and benefit of all the power of any async testing framework out there.

    • click anything, throw events, inject code in the page
    • wait for DOM node
    • perform Ajax...

    To name a few other, you should try:

    • Jasmine
    • Selenium
    • Zombie.JS