Option for SB only on bids; add the new file type #642 (#643)

Option for SB only on bids; add the new file type #642
This commit is contained in:
Nabeel S
2020-03-27 11:49:19 -04:00
committed by GitHub
parent f3fe3a56ba
commit 4a3ec38919
15 changed files with 746 additions and 56 deletions

View File

@@ -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]);