public function testGetPostData()
 {
     $ortcConfig = new OrtcConfig();
     $ortcConfig->setApplicationKey('abcede');
     $ortcConfig->setPrivateKey('123456');
     $ortcConfig->setMaxChunkSize(10);
     $request = new SendMessageRequest();
     $request->setOrtcConfig($ortcConfig);
     $request->setAuthToken('wxyz123');
     $request->setMessage('{message:foo bar}');
     $request->setChannelName('channel_name');
     $postData = $request->getPostData();
     $this->assertEquals(2, count($postData));
     $this->assertEquals(5, count($postData[0]));
     $this->assertEquals('abcede', $postData[0]['AK']);
     $this->assertEquals('123456', $postData[0]['PK']);
     $this->assertEquals('wxyz123', $postData[0]['AT']);
     $this->assertEquals('channel_name', $postData[0]['C']);
     $this->assertRegExp('/^[A-Za-z0-9]{8}_1-2_\\{message:f$/', $postData[0]['M']);
     $this->assertEquals(5, count($postData[1]));
     $this->assertEquals('abcede', $postData[1]['AK']);
     $this->assertEquals('123456', $postData[1]['PK']);
     $this->assertEquals('wxyz123', $postData[1]['AT']);
     $this->assertEquals('channel_name', $postData[1]['C']);
     $this->assertRegExp('/^[A-Za-z0-9]{8}_2-2_oo bar\\}$/', $postData[1]['M']);
 }
Esempio n. 2
0
 /**
  * create OrtcConfig from laravel config
  */
 protected function createOrtcConfig(array $config)
 {
     $ortcConfig = new OrtcConfig();
     $ortcConfig->setApplicationKey($config['credentials']['application_key']);
     $ortcConfig->setPrivateKey($config['credentials']['private_key']);
     $ortcConfig->setBalancerUrl($config['api']['balancer_url']);
     $ortcConfig->setAuthenticationPath($config['api']['authentication']['path']);
     $ortcConfig->setSendPath($config['api']['send_message']['path']);
     $ortcConfig->setMaxChunkSize($config['api']['send_message']['max_chunk_size']);
     $ortcConfig->setBatchPoolSize($config['api']['send_message']['batch_pool_size']);
     $ortcConfig->setPreMessageString($config['api']['send_message']['pre_message_string']);
     $ortcConfig->setVerifySsl($config['api']['verify_ssl']);
     $this->ortcConfig = $ortcConfig;
 }