Does PHPUnit have a Scriptable Web Browser and Web Tests

273 Views Asked by At

Does PHPUnit have a Scriptable Web Browser and Web Test capabilities, e.g. to fetch a page from a PHP script served on localhost, and then to click on elements, fill out & submit forms and assert the returned page content?

I am familiar with SimpleTest, and it has excellent classes and assertions for this. Also, the Zend framework seems to have a PHPUnit extension. However, I cannot find docs/examples of how to do web testing with PHPUnit (out-of-the-box) to cover functionality like sessions, form handling, clicking, navigation, ajax, etc..

I am looking for a way to have PHPUnit test my server side PHP code through HTML, thus testing my application from the vantage point of a user/visitor. I am not looking for a browser extension or any other kind of record & playback test framework like Selinium.

1

There are 1 best solutions below

1
Sherri On

Sounds like what you are looking to write are acceptance tests. Codeception is a popular tool for this in PHP & is built on top of PHPUnit. It lets you write tests that can navigate your pages & look like:

class FirstCest
{
    public function frontpageWorks(AcceptanceTester $I)
    {
        $I->amOnPage('/');
        $I->click('View More');
        $I->see('Details');
    }
}

https://codeception.com/