3
votes

I see WebTestCase and Symfony come up a lot...I have some unit tests in PHPUnit already but really need higher level tests...I do not need anything fancy like Selenium (the UI is done in ExtJS but this could change entirely to Polymer in the future) I just need to post data and check the JSON results.

Can this be done via PHPUnit or do I need to bring in Symfony and it's WebTestCase?

Testing RESTful web services using PHPUnit

Note: I am actually looking to test the services -- no mocked objects desired -- I need to login when the test suite is first run -- store the SESSION ID and go through each test...

1

1 Answers

4
votes

I have achieved success in writing PHP functional tests using Guzzle.

It allows you to perform HTTP requests like this:

$client = new GuzzleHttp\Client();
$response = $client->get('http://guzzlephp.org');

And the $client will maintain the PHPSESSIONID across requests, allowing you to perform authenticated requests by logging in and then performing requests with the same client.