I’m trying to write a unit test for my Controller which calls the Twitter API using Zend_Service.
/**
* Authenticate Step 1 for Twitter
*/
public function authenticateAction()
{
$this->service->authenticate();
}
The Service does:
/**
* Authenticate with twitter
*
* @return void
*/
public function authenticate()
{
$consumer = new Zend_Oauth_Consumer($this->config);
$token = $consumer->getRequestToken();
$this->session->twitterRequestToken = serialize($token);
$consumer->redirect();
exit;
}
My Problem is that I have no idea how to replace the authenticate action inside the service for the unit test. I don’t want to call the Twitter API while the tests run.
Is there any Mocking Framework which can do such things?
Zend_Service_Twitter uses Zend_Http_Client so you can stub it in your test case