3

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 Answer 1

5

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.

Sign up to request clarification or add additional context in comments.

2 Comments

I will have to look into that...i was kind of hoping for a phpunit extension so as to include the tests in the runner and have results shown alongside unit tests in netbeans i will accept your answer tomorrow if no one else answers...thanks for the reply :)
note that you can also perform phpunit assertions on the response, and you can also get a crawler to crawl the HTML returned by the server (and, of course, perform assertions on it)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.