Option for SB only on bids; add the new file type #642
This commit is contained in:
@@ -132,19 +132,22 @@ class TestCase extends Illuminate\Foundation\Testing\TestCase
|
||||
/**
|
||||
* Return a mock Guzzle Client with a response loaded from $mockFile
|
||||
*
|
||||
* @param $mockFile
|
||||
* @param array|string $files
|
||||
*/
|
||||
public function mockGuzzleClient($mockFile): void
|
||||
public function mockGuzzleClient($files): void
|
||||
{
|
||||
$mock = new MockHandler([
|
||||
new Response(
|
||||
200,
|
||||
[
|
||||
'Content-Type' => 'application/json; charset=utf-8',
|
||||
],
|
||||
$this->readDataFile($mockFile)
|
||||
),
|
||||
]);
|
||||
if (!is_array($files)) {
|
||||
$files = [$files];
|
||||
}
|
||||
|
||||
$responses = [];
|
||||
foreach ($files as $file) {
|
||||
$responses[] = new Response(200, [
|
||||
'Content-Type' => 'application/json; charset=utf-8',
|
||||
], $this->readDataFile($file));
|
||||
}
|
||||
|
||||
$mock = new MockHandler($responses);
|
||||
|
||||
$handler = HandlerStack::create($mock);
|
||||
$guzzleClient = new Client(['handler' => $handler]);
|
||||
@@ -152,19 +155,22 @@ class TestCase extends Illuminate\Foundation\Testing\TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $filename
|
||||
* @param array|string $files The filename or files to respond with
|
||||
*/
|
||||
public function mockXmlResponse($filename)
|
||||
public function mockXmlResponse($files)
|
||||
{
|
||||
$mock = new MockHandler([
|
||||
new Response(
|
||||
200,
|
||||
[
|
||||
'Content-Type' => 'text/xml',
|
||||
],
|
||||
$this->readDataFile($filename)
|
||||
),
|
||||
]);
|
||||
if (!is_array($files)) {
|
||||
$files = [$files];
|
||||
}
|
||||
|
||||
$responses = [];
|
||||
foreach ($files as $file) {
|
||||
$responses[] = new Response(200, [
|
||||
'Content-Type' => 'text/xml',
|
||||
], $this->readDataFile($file));
|
||||
}
|
||||
|
||||
$mock = new MockHandler($responses);
|
||||
|
||||
$handler = HandlerStack::create($mock);
|
||||
$guzzleClient = new Client(['handler' => $handler]);
|
||||
|
||||
Reference in New Issue
Block a user