本文整理匯總了PHP中Guzzle\Http\EntityBody::fromString方法的典型用法代碼示例。如果您正苦於以下問題:PHP EntityBody::fromString方法的具體用法?PHP EntityBody::fromString怎麽用?PHP EntityBody::fromString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Guzzle\Http\EntityBody
的用法示例。
在下文中一共展示了EntityBody::fromString方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: setUp
public function setUp()
{
$this->mockRequest = new \Guzzle\Plugin\Mock\MockPlugin();
$body = \Guzzle\Http\EntityBody::fromString($this->responseBodyString);
$this->mockRequest->addResponse(new Guzzle\Http\Message\Response(200, $this->responseHeaders, $body));
$this->client = $this->getClientInstance();
$this->client->addClientSubscriber($this->mockRequest);
}
示例2: setUp
public function setUp()
{
$httpClient = $this->getMockBuilder('\\Guzzle\\Http\\Client')->getMock();
$wdavClient = $this->getMockBuilder('\\Grale\\WebDav\\WebDavClient')->getMock();
$wdavClient->expects($this->any())->method('getHttpClient')->will($this->returnValue($httpClient));
$stream = EntityBody::fromString('Hello World!');
$wdavClient->expects($this->any())->method('getStream')->will($this->returnValue($stream));
$propfind = MultiStatus::parse($wdavClient, file_get_contents(__DIR__ . '/../../fixtures/streamwrapper.opendir.xml'));
$wdavClient->expects($this->any())->method('setThrowExceptions')->will($this->returnValue($this->client));
$wdavClient->expects($this->any())->method('propfind')->will($this->returnValue($propfind));
$this->client = $wdavClient;
StreamWrapper::register(null, $this->client);
}
示例3: openAppendMode
/**
* Initialize the stream wrapper for an append stream.
*
* @param Url $url URL of the resource to be opened
* @return bool Returns true on success or false on failure
*/
protected function openAppendMode($url)
{
try {
$contents = self::$client->get($url);
$this->stream = EntityBody::fromString($contents);
$this->stream->seek(0, SEEK_END);
} catch (NoSuchResourceException $exception) {
// The resource does not exist, so use a simple write stream
return $this->openWriteOnly($url);
}
return true;
}