News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Chris Hartjes' Blog:
Testing Web Services in Zend Framework 1.x
May 03, 2011 @ 09:20:45

In a new post to his blog Chris Hartjes shares a technique he figured out for testing web services in Zend Framework 1.x - in his case, a remote application he wanted to mock out with test doubles that would give different responses based on the parameters given.

Reading the existing PHPUnit documentation did not provide me with enough hints on how to solve this particular problem, so while I dug around duckduckgoing for a solution I asked Twitter for help. One blog post and 3 tweets later, I had the underpinnings for my test. Check it out. A walk-through is probably required in order to explain what I did.

The sample test (code included in the post) sets up a mock object to abstract the service connection, loads in some fixture data for the different responses (based on request) and an "expectation object" for the GET request on the mock object. This object and the data is then passed to a handler that responds with the right dataset. The example code is here on github in two methods - testGetTracks and setMultipleMatching.

0 comments voice your opinion now!
testing unittest webservice zendframework testdoubles mockobjects


blog comments powered by Disqus

Similar Posts

SmartyCode.com: Enable your Zend Framework App with Conditional GET! (Make it green)

Kamran Usman's Blog: Zend is going the Wrong Way I think

Alexander Netkachev's Blog: Controller/Action versus Folder/Page

Pádraic Brady's Blog: Complex Views with the Zend Framework - Part 4: The View Factory

Chris Hartjes' Blog: A New Way Of Judging Frameworks: Where are the tests?


Community Events





Don't see your event here?
Let us know!


list conference introduction symfony framework code development laravel release interview language voicesoftheelephpant zendserver podcast api series bugfix deployment community tips

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework