本文整理汇总了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;
}