Testing Zend_Controller wich is using Twitter API

Posted by ArneRie on Stack Overflow See other posts from Stack Overflow or by ArneRie
Published on 2010-12-30T06:52:37Z Indexed on 2010/12/30 6:53 UTC
Read the original article Hit count: 274

Filed under:
|
|
|

Hi,

iam trying to write an unit test for an Controller wich calls the Twitter API through an Service class.

/**
 * 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, i have no idea to repleace the authenticate action inside the service for the unit test. I dont want to call the Twitter API while the tests run.

Is there any Mocking Framework wich can do such things?

© Stack Overflow or respective owner

Related posts about php

Related posts about zend