[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/externals/twilio-php/tests/resources/ -> SMSMessagesTest.php (source)

   1  <?php
   2  
   3  use \Mockery as m;
   4  
   5  class SMSMessagesTest extends PHPUnit_Framework_TestCase {
   6      protected $formHeaders = array('Content-Type' => 'application/x-www-form-urlencoded');
   7  
   8      function testCreateMessage() {
   9          $http = m::mock(new Services_Twilio_TinyHttp);
  10          $http->shouldReceive('post')->once()
  11              ->with('/2010-04-01/Accounts/AC123/SMS/Messages.json', $this->formHeaders,
  12                  'From=%2B1222&To=%2B44123&Body=Hi+there')
  13              ->andReturn(array(200, array('Content-Type' => 'application/json'),
  14                  json_encode(array('sid' => 'SM123'))
  15              ));
  16          $client = new Services_Twilio('AC123', '123', '2010-04-01', $http);
  17          $sms = $client->account->sms_messages->create('+1222', '+44123', 'Hi there');
  18          $this->assertSame('SM123', $sms->sid);
  19      }
  20  
  21      function testBadMessageThrowsException() {
  22          $this->setExpectedException('Services_Twilio_RestException');
  23          $http = m::mock(new Services_Twilio_TinyHttp);
  24          $http->shouldReceive('post')->once()
  25              ->with('/2010-04-01/Accounts/AC123/SMS/Messages.json', $this->formHeaders,
  26                  'From=%2B1222&To=%2B44123&Body=' . str_repeat('hi', 81))
  27              ->andReturn(array(400, array('Content-Type' => 'application/json'),
  28                  json_encode(array(
  29                      'status' => '400',
  30                      'message' => 'Too long',
  31                  ))
  32              ));
  33          $client = new Services_Twilio('AC123', '123', null, $http);
  34          $sms = $client->account->sms_messages->create('+1222', '+44123',
  35              str_repeat('hi', 81));
  36      }
  37  }
  38  


Generated: Sun Nov 30 09:20:46 2014 Cross-referenced by PHPXref 0.7.1