1
0
mirror of https://github.com/guzzle/guzzle.git synced 2025-02-27 03:24:15 +01:00
guzzle/tests/Guzzle/Tests/Service/Mock/MockClient.php
Michael Dowling c0dc85de35 Breaking / Potentially breaking changes:
1. Adopting a marker interface for Guzzle exceptions.
        A. All exceptions emitted from Guzzle are now wrapped with a Guzzle namespaced exception.
        B. Guzzle\Common\GuzzleExceptionInterface was renamed to Guzzle\Common\GuzzleException
        C. Guzzle\Common\ExceptionCollection was renamed to Guzzle\Common\Exception\ExceptionCollection
    2. Using Header objects for Request and Response objects
        A. When you call $request->getHeader('X'), you will get back a Guzzle\Http\Message\Header object that contains all of the headers that case insensitively match.  This object can be cast to a string or iterated like an array.  You can pass true in the second argument to retrieve the header as a string.
        B. Removing the old Guzzle\Common\Collection based searching arguments from most of the request and response header methods.  All retrievals are case-insensitive and return Header objects.
    3. Changing the two headers added by the cache plugin to just one header with key and ttl.
    4. Changing Guzzle\Http\Message\Response::factory() to fromMessage().
    5. Removing the NullObject return value from ServiceDescriptions and instead simply returning null

New Features / enhancements:

    1. Adding Guzzle\Http\Message\AbstractMessage::addHeaders()
    2. Making it simpler to create service descriptions using a unified factory method that delegates to other factories.
    3. Better handling of ports and hosts in Guzzle\Http\Url

Note: This is a noisy diff because I'm removing trailing whitespace and adding a new line at the end of each source file.
2012-04-22 00:17:49 -07:00

37 lines
975 B
PHP

<?php
namespace Guzzle\Tests\Service\Mock;
use Guzzle\Service\Inspector;
use Guzzle\Service\Client;
/**
* Mock Guzzle Service
*/
class MockClient extends Client
{
/**
* Factory method to create a new mock client
*
* @param array|Collection $config Configuration data. Array keys:
* base_url - Base URL of web service
* api_version - API version
* scheme - URI scheme: http or https
* * username - API username
* * password - API password
* * subdomain - Unfuddle account subdomain
*
* @return MockClient
*/
public static function factory($config)
{
$config = Inspector::prepareConfig($config, array(
'base_url' => '{{scheme}}://127.0.0.1:8124/{{api_version}}/{{subdomain}}',
'scheme' => 'http',
'api_version' => 'v1'
), array('username', 'password', 'subdomain'));
return new self($config->get('base_url'), $config);
}
}