コード例 #1
0
ファイル: PayloadTest.php プロジェクト: newage/AudioManager
 public function testHeaders()
 {
     $authenticate = $this->getMockBuilder('AudioManager\\Adapter\\Ivona\\Authenticate')->disableOriginalConstructor()->setMethods(['getHeader', 'setPostData'])->getMock();
     $authenticate->method('setPostData')->with($this->anything())->will($this->returnSelf());
     $authenticate->method('getHeader')->with($this->stringContains(Payload::SERVICE_TYPE_SPEECH))->will($this->returnValue(['X-Amz-Date:', 'Authorization:']));
     $options = $this->getMockBuilder('AudioManager\\Adapter\\Ivona\\Options')->disableOriginalConstructor()->setMethods(['getAuthenticate', 'getPostData', 'getUserAgent'])->getMock();
     $options->method('getAuthenticate')->will($this->returnValue($authenticate));
     $options->method('getPostData')->will($this->returnValue(['data' => true]));
     $options->method('getUserAgent')->will($this->returnValue(Options::DEFAULT_USERAGENT));
     $expectedArray = ["Content-Type: application/json", "Host: tts.eu-west-1.ivonacloud.com", "User-Agent: TestClient 1.0", "X-Amz-Date:", "Authorization:"];
     $this->payload->setOptions($options);
     $headers = $this->payload->getHeaders(Payload::SERVICE_TYPE_SPEECH);
     $this->assertEquals($expectedArray, $headers);
 }
コード例 #2
0
ファイル: Ivona.php プロジェクト: newage/AudioManager
 /**
  * Initialize payload
  * @param $text
  * @return Payload
  */
 private function initPayload($text)
 {
     $payload = new Payload();
     $payload->setOptions($this->getOptions());
     $payload->setQueryText($text);
     return $payload->createPayload();
 }