Ejemplo n.º 1
0
 /**
  * {@inheritdoc}
  * @throws \InvalidArgumentException
  */
 public function upload(SpeechContentInterface $speech)
 {
     $headers = ['Content-Type' => $speech->getContentType()];
     $uri = $this->urlGenerator->generate($speech);
     $request = new Request('POST', $uri, $headers, $speech->getStream());
     return $this->client->upload($request);
 }
Ejemplo n.º 2
0
 public function it_uploads_speech(UrlGenerator $generator, ClientInterface $client, SpeechContentInterface $speech, StreamInterface $uploadedStream, ResponseInterface $response, Uri $generatedUri)
 {
     $speech->getStream()->willReturn($uploadedStream);
     $speech->getContentType()->willReturn(null);
     $generator->generate($speech)->willReturn($generatedUri);
     $client->upload(Argument::type('Psr\\Http\\Message\\RequestInterface'))->willReturn($response);
     $this->upload($speech)->shouldReturn($response);
     $client->upload(Argument::type('Psr\\Http\\Message\\RequestInterface'))->shouldHaveBeenCalled();
     $client->upload(Argument::which('getBody', $uploadedStream->getWrappedObject()))->shouldHaveBeenCalled();
 }