forked from microsoftgraph/msgraph-sdk-php
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMockClientFactory.php
More file actions
28 lines (25 loc) · 792 Bytes
/
Copy pathMockClientFactory.php
File metadata and controls
28 lines (25 loc) · 792 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<?php
namespace Microsoft\Graph\Http\Test;
use GuzzleHttp\Client;
use GuzzleHttp\Handler\MockHandler;
use GuzzleHttp\HandlerStack;
class MockClientFactory
{
/**
* Creates a mock Guzzle client with optional mock responses
*
* @param array $clientConfig - Guzzle client Request options
* @param array $mockResponses - Accepts \GuzzleHttp\Psr7\Response and \GuzzleHttp\Exception
* @return \GuzzleHttp\Client
*/
public static function create($clientConfig = [], $mockResponses = [])
{
if ($mockResponses)
{
$stack = HandlerStack::create(new MockHandler($mockResponses));
$clientConfig['handler'] = $stack;
return new Client($clientConfig);
}
return new Client($clientConfig);
}
}