本文整理汇总了PHP中Guzzle\Plugin\Mock\MockPlugin::addException方法的典型用法代码示例。如果您正苦于以下问题:PHP MockPlugin::addException方法的具体用法?PHP MockPlugin::addException怎么用?PHP MockPlugin::addException使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Guzzle\Plugin\Mock\MockPlugin
的用法示例。
在下文中一共展示了MockPlugin::addException方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testUnreachableException
public function testUnreachableException()
{
$mock = new MockPlugin();
$mock->addException(new CurlException('connect to host'));
$client = new Client();
$client->addSubscriber($mock);
$varnish = new Varnish(array('http://127.0.0.1:123'), 'my_hostname.dev', $client);
try {
$varnish->purge('/paths')->flush();
} catch (ExceptionCollection $exceptions) {
$this->assertCount(1, $exceptions);
$this->assertInstanceOf('\FOS\HttpCache\Exception\ProxyUnreachableException', $exceptions->getFirst());
}
$mock->clearQueue();
$mock->addResponse(new Response(200));
// Queue must now be empty, so exception above must not be thrown again.
$varnish->purge('/path')->flush();
}
示例2: testGetRequestTokenThrowsException
/**
* @expectedException \Rabus\Bundle\Twitter\SignInBundle\Service\TwitterApiException
*/
public function testGetRequestTokenThrowsException()
{
$this->factoryMock->expects($this->any())->method('getOAuthConnection')->will($this->returnValue($this->bootstrapClient()));
$this->mockPlugin->addException(new CurlException());
$this->bootstrapGateway()->getRequestToken('http://www.example.com/twitter/callback');
}