Skip to content
This repository has been archived by the owner on Apr 2, 2024. It is now read-only.

Commit

Permalink
Reload internal object with response on update
Browse files Browse the repository at this point in the history
  • Loading branch information
luciferous committed Mar 7, 2011
1 parent f8e66e3 commit 4d4c14b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Services/Twilio/InstanceResource.php
Expand Up @@ -14,7 +14,9 @@ public function update($params, $value = NULL) {
if (!is_array($params)) {
$params = array($params => $value);
}
$this->proxy->createData($this->sid, $params);
$object = $this->proxy->createData($this->sid, $params);
$this->_load($object);
return $this;
}
public function setObject($object) {
$this->_load($object);
Expand Down
18 changes: 18 additions & 0 deletions tests/TwilioTest.php
Expand Up @@ -255,6 +255,24 @@ function testUnmute() {
}
}

function testResourcePropertiesReflectUpdates() {
$http = m::mock();
$http->shouldReceive('get')->once()
->with('/2010-04-01/Accounts/AC123.json')
->andReturn(array(200, array('Content-Type' => 'application/json'),
json_encode(array('friendly_name' => 'foo'))
));
$http->shouldReceive('post')->once()
->with('/2010-04-01/Accounts/AC123.json', m::any(), m::any())
->andReturn(array(200, array('Content-Type' => 'application/json'),
json_encode(array('friendly_name' => 'bar'))
));
$client = new Services_Twilio('AC123', '123', '2010-04-01', $http);
$this->assertEquals('foo', $client->account->friendly_name);
$client->account->update('FriendlyName', 'bar');
$this->assertEquals('bar', $client->account->friendly_name);
}

//function testAccessingNonExistentPropertiesErrorsOut
}

Expand Down

0 comments on commit 4d4c14b

Please sign in to comment.