Ejemplo n.º 1
0
 public function testRead()
 {
     $content = 'JSON';
     $request = $this->getMockBuilder('AudioManager\\Request\\CurlRequest')->setMethods(['execute'])->getMock();
     $request->method('execute')->will($this->returnValue($content));
     $payload = $this->getMockBuilder('AudioManager\\Adapter\\Ivona\\Payload')->setMethods(['getServiceUrl', 'getPayload', 'getHeaders'])->getMock();
     $payload->method('getServiceUrl')->will($this->returnValue('http://'));
     $payload->method('getPayload')->will($this->returnValue('{"payload":"json"}'));
     $payload->method('getHeaders')->will($this->returnValue([]));
     $this->adapter->setHandle($request);
     $this->adapter->setPayload($payload);
     $result = $this->adapter->read('text');
     $this->assertEquals($content, $result);
 }
Ejemplo n.º 2
0
 /**
  * @return \AudioManager\Adapter\AdapterInterface
  * @throws RuntimeException
  */
 public function __invoke()
 {
     $adapterName = strtolower($this->config->get('voice.provider', self::VOICE_PROVIDER_GOOGLE));
     switch ($adapterName) {
         case self::VOICE_PROVIDER_GOOGLE:
             $adapter = new Google();
             $adapter->getOptions()->setLanguage('en');
             $adapter->getOptions()->setEncoding('UTF-8');
             break;
         case self::VOICE_PROVIDER_IVONA:
             $secretKey = $this->config->get('voice.' . $adapterName . '.secret_key', '');
             $accessKey = $this->config->get('voice.' . $adapterName . '.access_key', '');
             $adapter = new Ivona();
             $adapter->getOptions()->setSecretKey($secretKey);
             $adapter->getOptions()->setAccessKey($accessKey);
             break;
         default:
             throw new ErrorException('Not implemented functionality for voice provider: ' . $adapterName);
     }
     return $adapter;
 }