Google\Cloud\Tests\Snippets\Speech\SpeechClientTest::testBeginRecognizeOperation PHP Method

testBeginRecognizeOperation() public method

    public function testBeginRecognizeOperation()
    {
        $snippet = $this->snippetFromMethod(SpeechClient::class, 'beginRecognizeOperation');
        $snippet->addLocal('speech', $this->client);
        $snippet->replace('__DIR__  . \'/audio.flac\'', $this->testFile);
        $this->connection->asyncRecognize(Argument::any())->shouldBeCalled()->willReturn(['done' => false, 'name' => 'foo']);
        $results = [['alternatives' => 'foo']];
        $this->connection->getOperation(Argument::any())->shouldBeCalled()->willReturn(['done' => true, 'name' => 'foo', 'response' => ['results' => $results]]);
        $this->client->setConnection($this->connection->reveal());
        $res = $snippet->invoke();
        $this->assertEquals(print_r($results[0]['alternatives'], true), $res->output());
    }