Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
<?php
namespace Knp\Bundle\LastTweetsBundle\Tests\Twitter\LastTweetsFetcher;
use Knp\Bundle\LastTweetsBundle\Twitter\LastTweetsFetcher\ApiFetcher;
use Knp\Bundle\LastTweetsBundle\Twitter\Tweet;
class ApiFetcherTest extends \PHPUnit_Framework_TestCase
{
const CLASSNAME = 'Knp\Bundle\LastTweetsBundle\Twitter\LastTweetsFetcher\ApiFetcher';
public function testRealFetchWithLimit()
{
$fixture = json_encode(array(
'one' => array('id' => 1, 'id_str' => 1, 'text' => 'asdasdasd', 'created_at' => 'Thu Apr 04 11:58:04 +0000 2012'),
'two' => array('id' => 2, 'id_str' => 2, 'text' => 'asdasdasd2', 'created_at' => 'Thu Apr 05 12:45:43 +0000 2012'),
'three' => array('id' => 3, 'id_str' => 3, 'text' => 'asdasdasd3', 'created_at' => 'Thu Apr 06 13:22:28 +0000 2012'),
'four' => array('id' => 4, 'id_str' => 4, 'text' => 'asdasdasd4', 'created_at' => 'Thu Apr 07 14:36:01 +0000 2012')
));
$mockedBrowser = $this->getMockedBrowser();
$mockedResponse = $this->getMockedResponse($fixture);
$mockedBrowser->expects($this->exactly(2))
->method('get')
->will($this->returnValue($mockedResponse));
$fetcher = new ApiFetcher($mockedBrowser);
$tweets = $fetcher->fetch(array('knplabs', 'knplabsru'), 4);
$this->assertCount(4, $tweets);
}
protected function getMockedBrowser()
{
$browser = $this->getMock('Buzz\Browser');
return $browser;
}
protected function getMockedResponse($fixture)
{
$response = $this->getMock('Buzz\Browser\Message\Response', array('getContent'));
$response->expects($this->atLeastOnce())
->method('getContent')
->will($this->returnValue($fixture));
return $response;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.