$serviceBuilder
$serviceBuilder :
Base testcase class for all Guzzle testcases.
getServer() : \Guzzle\Tests\Http\Server
Get the global server object used throughout the unit tests of Guzzle
setServiceBuilder(\Guzzle\Service\Builder\ServiceBuilderInterface $builder)
Set the service builder to use for tests
\Guzzle\Service\Builder\ServiceBuilderInterface | $builder | Service builder |
getServiceBuilder() : \Guzzle\Service\Builder\ServiceBuilder
Get a service builder object that can be used throughout the service tests
getWildcardObserver(\Guzzle\Common\HasDispatcherInterface $hasDispatcher) : \Guzzle\Tests\Mock\MockObserver
Get a wildcard observer for an event dispatcher
\Guzzle\Common\HasDispatcherInterface | $hasDispatcher |
setMockBasePath(string $path) : \Guzzle\Tests\GuzzleTestCase
Set the mock response base path
string | $path | Path to mock response folder |
addMockedRequest(\Guzzle\Http\Message\RequestInterface $request) : self
Mark a request as being mocked
\Guzzle\Http\Message\RequestInterface | $request |
getMockResponse(string $path) : \Guzzle\Http\Message\Response
Get a mock response for a client by mock file name
string | $path | Relative path to the mock response file |
setMockResponse(\Guzzle\Http\Client $client, string $paths) : \Guzzle\Plugin\Mock\MockPlugin
Set a mock response from a mock file on the next client request.
This method assumes that mock response files are located under the Command/Mock/ directory of the Service being tested (e.g. Unfuddle/Command/Mock/). A mock response is added to the next request sent by the client.
\Guzzle\Http\Client | $client | Client object to modify |
string | $paths | Path to files within the Mock folder of the service |
returns the created mock plugin
compareHeaders(array $filteredHeaders, array $actualHeaders) : array|boolean
Compare HTTP headers and use special markup to filter values A header prefixed with '!' means it must not exist A header prefixed with '_' means it must be ignored A header value of '*' means anything after the * will be ignored
array | $filteredHeaders | Array of special headers |
array | $actualHeaders | Array of headers to check against |
Returns an array of the differences or FALSE if none
hasSubscriber(\Guzzle\Common\HasDispatcherInterface $dispatcher, \Symfony\Component\EventDispatcher\EventSubscriberInterface $subscriber) : boolean
Check if an event dispatcher has a subscriber
\Guzzle\Common\HasDispatcherInterface | $dispatcher | |
\Symfony\Component\EventDispatcher\EventSubscriberInterface | $subscriber |
<?php
namespace Guzzle\Tests\Common\Exception;
use Guzzle\Common\Exception\ExceptionCollection;
class ExceptionCollectionTest extends \Guzzle\Tests\GuzzleTestCase
{
private function getExceptions()
{
return array(
new \Exception('Test'),
new \Exception('Testing')
);
}
public function testAggregatesExceptions()
{
$e = new ExceptionCollection();
$exceptions = $this->getExceptions();
$e->add($exceptions[0]);
$e->add($exceptions[1]);
$this->assertContains("(Exception) ./tests/Guzzle/Tests/Common/Exception/ExceptionCollectionTest.php line ", $e->getMessage());
$this->assertContains(" Test\n\n #0 ./", $e->getMessage());
$this->assertSame($exceptions[0], $e->getFirst());
}
public function testCanSetExceptions()
{
$ex = new \Exception('foo');
$e = new ExceptionCollection();
$e->setExceptions(array($ex));
$this->assertSame($ex, $e->getFirst());
}
public function testActsAsArray()
{
$e = new ExceptionCollection();
$exceptions = $this->getExceptions();
$e->add($exceptions[0]);
$e->add($exceptions[1]);
$this->assertEquals(2, count($e));
$this->assertEquals($exceptions, $e->getIterator()->getArrayCopy());
}
public function testCanAddSelf()
{
$e1 = new ExceptionCollection();
$e1->add(new \Exception("Test"));
$e2 = new ExceptionCollection('Meta description!');
$e2->add(new \Exception("Test 2"));
$e3 = new ExceptionCollection();
$e3->add(new \Exception('Baz'));
$e2->add($e3);
$e1->add($e2);
$message = $e1->getMessage();
$this->assertContains("(Exception) ./tests/Guzzle/Tests/Common/Exception/ExceptionCollectionTest.php line ", $message);
$this->assertContains("\n Test\n\n #0 ", $message);
$this->assertContains("\n\n(Guzzle\\Common\\Exception\\ExceptionCollection) ./tests/Guzzle/Tests/Common/Exception/ExceptionCollectionTest.php line ", $message);
$this->assertContains("\n\n Meta description!\n\n", $message);
$this->assertContains(" (Exception) ./tests/Guzzle/Tests/Common/Exception/ExceptionCollectionTest.php line ", $message);
$this->assertContains("\n Test 2\n\n #0 ", $message);
$this->assertContains(" (Exception) ./tests/Guzzle/Tests/Common/Exception/ExceptionCollectionTest.php line ", $message);
$this->assertContains(" Baz\n\n #0", $message);
}
}