Skip to content

Commit

Permalink
changed how guzzle config is passed
Browse files Browse the repository at this point in the history
closes #2
  • Loading branch information
AndyWendt committed Jul 31, 2015
1 parent 27ca405 commit 93b566f
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions src/ApiFeatureContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,23 +89,26 @@ class ApiFeatureContext extends MinkContext implements Context, SnippetAccepting
*/
protected $query;

protected $guzzleConfig = [];

/**
* Initializes context.
* Every scenario gets it's own context object.
*
* @param array $parameters context parameters (set them up through behat.yml)
*/
public function __construct($baseUrl = null, $guzzle = [])
public function __construct($baseUri = null, $guzzle = [])
{
$config = (!empty($guzzle)) ? $guzzle : [];
if (null === $baseUrl) {
$config = [];
if (null === $baseUri) {
$config['base_uri'] = 'http://'.getenv('NOVUSSITEAPINGINX_PORT_80_TCP_ADDR');
} else {
$config['base_uri'] = $baseUrl;
$config['base_uri'] = $baseUri;
}

$this->client = new Client($config);
$this->guzzleConfig = array_merge($config, $guzzle);

$this->client = new Client();
$this->resourceParser = \App::make(\PrometheusApi\Utilities\Contracts\Uri\Parser::class);
$this->testingHelper = \App::make(\LaraPackage\RandomId\Helper::class);
}
Expand Down Expand Up @@ -804,6 +807,14 @@ protected function getScopePayload($forceUpdate = false)
return $this->arrayGet($this->responsePayload, $this->scope);
}

/**
* @param $options
*/
protected function guzzleRequestConfig(array $options)
{
return array_merge($options, $this->guzzleConfig);
}

protected function makeRequest()
{
$method = strtolower($this->httpMethod);
Expand All @@ -817,13 +828,13 @@ protected function makeRequest()
case 'POST':
$this->response = $this
->client
->$method($resource, ['headers' => $this->headers, 'body' => $this->requestPayload]);
->$method($resource, $this->guzzleRequestConfig(['headers' => $this->headers, 'body' => $this->requestPayload]));
break;

default:
$this->response = $this
->client
->$method($resource, ['headers' => $this->headers]);
->$method($resource, $this->guzzleRequestConfig(['headers' => $this->headers]));
}
} catch (BadResponseException $e) {

Expand Down

0 comments on commit 93b566f

Please sign in to comment.