Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'correct-paging-with-iterator'

  • Loading branch information...
commit ab14675fe495762250adbb66f840efef8080fc13 2 parents f2cbe22 + f40f331
Kevin Burke authored
View
2  Services/Twilio/ListResource.php
@@ -107,7 +107,7 @@ public function getPage(
) {
$list_name = $this->getResourceName();
if ($deep_paging_uri !== null) {
- $page = $this->client->retrieveData($deep_paging_uri, $filters, true);
+ $page = $this->client->retrieveData($deep_paging_uri, array(), true);
} else {
$page = $this->client->retrieveData($this->uri, array(
'Page' => $page,
View
1  tests/ResourcesTest.php
@@ -245,7 +245,6 @@ function testBadMessageThrowsException() {
}
}
-
class CallsTest extends PHPUnit_Framework_TestCase
{
/**
View
39 tests/TwilioTest.php
@@ -378,4 +378,43 @@ function testDeepPagingUsesAfterSid() {
}
}
+ function testIteratorWithFiltersPagesCorrectly() {
+ $http = m::mock(new Services_Twilio_TinyHttp);
+ $recordingsBase = '/2010-04-01/Accounts/AC123/Recordings.json';
+ $firstPageUri = $recordingsBase . '?Page=0&PageSize=1&DateCreated%3E=2011-01-01';
+ $secondPageUri = $recordingsBase . '?DateCreated%3E=2011-01-01&Page=1&PageSize=1';
+ $thirdPageUri = $recordingsBase . '?DateCreated%3E=2011-01-01&Page=2&PageSize=1';
+ $http->shouldReceive('get')->once()
+ ->with($firstPageUri)
+ ->andReturn(array(200, array('Content-Type' => 'application/json'),
+ json_encode(array(
+ 'next_page_uri' => $secondPageUri,
+ 'recordings' => array(array(
+ 'sid' => 'RE123',
+ 'duration' => 7,
+ ))
+ ))
+ ));
+ $http->shouldReceive('get')->once()
+ ->with($secondPageUri)
+ ->andReturn(array(200, array('Content-Type' => 'application/json'),
+ json_encode(array(
+ 'next_page_uri' => $thirdPageUri,
+ 'recordings' => array(array(
+ 'sid' => 'RE123',
+ 'duration' => 7,
+ ))
+ ))
+ ));
+ $http->shouldReceive('get')->once()
+ ->with($thirdPageUri)
+ ->andReturn(array(400, array('Content-Type' => 'application/json'),
+ '{"status":400,"message":"foo", "code": "20006"}'
+ ));
+
+ $client = new Services_Twilio('AC123', '123', '2010-04-01', $http);
+ foreach ($client->account->recordings->getIterator(0, 1, array('DateCreated>' => '2011-01-01')) as $recording) {
+ $this->assertSame($recording->duration, 7);
+ }
+ }
}
Please sign in to comment.
Something went wrong with that request. Please try again.