Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 0.1.5

Request #14963 Improve testability - simulate responses (dependency injection)
Submitted: 2008-11-06 10:53 UTC
From: doconnor Assigned:
Status: Open Package: Services_Hatena (version CVS)
PHP Version: 5.2.6 OS:
Roadmaps: (Not assigned)    
Comments Add Comment Add patch

Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know! Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem : 28 + 34 = ?

 [2008-11-06 10:53 UTC] doconnor (Daniel O'Connor)
Description: ------------ At the moment, Services_Hatena instantiates XML_RPC clients in the middle of methods to get code. Basically, classes do: class Foo extends Services_Hatena { public function execute() { // new XML_RPC_Client() in here } } If you were to change the API to expect you to instantiate an XML_RPC_Client in the constructor, testability is markedly improved - you can inject a mock client which provides dummy results, but otherwise asserts your package functions correctly. IE - You could do: $service = new Services_Hatena_Bookmarknum(new XML_RPC_Client()); $service = new Services_Hatena_Bookmarknum(new Mock_XML_RPC_Client()); (or pass it in to the factory method) If the factory doesn't get passed any particular arguments, you could still instantiate the relevant XML_RPC client. This would prevent Bug #14872 from ever occurring again.