public function testExecuteWithJsonBody() { $method = $this->createMock(AbstractMethodWithBodyStub::class); $method->expects($this->once())->method('getMethodName')->willReturn('/someMethod'); $method->expects($this->once())->method('getHttpMethod')->willReturn('POST'); $method->expects($this->once())->method('getParams')->willReturn(['param1' => 'value1', 'param2' => 'value2']); $method->expects($this->once())->method('buildResult')->willReturn('result'); $method->expects($this->once())->method('jsonSerialize')->willReturn(['jsonParam1' => 'jsonValue1', 'jsonParam2' => 'jsonValue2']); $responseData = json_encode(['ok' => true, 'result' => 'result'], JSON_UNESCAPED_UNICODE); $this->setUpHttpClient($responseData); $api = new Api($this->telegramToken, $this->httpClient); $coroutine = new Coroutine($api->execute($method)); $result = $coroutine->wait(); $this->assertEquals('result', $result); }
/** * {@inheritdoc} */ public function seek($offset, $whence = SEEK_SET) { if (!$this->isSeekable()) { throw new RuntimeException('Stream is not seekable'); } $promise = new Coroutine($this->stream->seek($offset, $whence)); try { return $promise->wait(); } catch (\Exception $exception) { throw new RuntimeException('Error seeking stream', 0, $exception); } }