Skip to content

Commit

Permalink
Allowed to provide API key value when calling ApiTestCase::callApiWit…
Browse files Browse the repository at this point in the history
…hKey
  • Loading branch information
acelaya committed Jan 10, 2021
1 parent fc94121 commit 36140eb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com), and this project adheres to [Semantic Versioning](https://semver.org).

## [Unreleased]
## [1.7.0] - 2021-01-10
### Added
* *Nothing*
* Update `ApiTestCase` so that it allows providing the API key value when calling `callApiWithKey`.

### Changed
* Migrated build to Github Actions.
Expand Down
10 changes: 7 additions & 3 deletions src/ApiTest/ApiTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,14 @@ protected function callApi(string $method, string $uri, array $options = []): Re
return self::$client->request($method, sprintf('%s%s', self::REST_PATH_PREFIX, $uri), $options);
}

protected function callApiWithKey(string $method, string $uri, array $options = []): ResponseInterface
{
protected function callApiWithKey(
string $method,
string $uri,
array $options = [],
string $apiKey = 'valid_api_key'
): ResponseInterface {
$headers = $options[RequestOptions::HEADERS] ?? [];
$headers['X-Api-Key'] = 'valid_api_key';
$headers['X-Api-Key'] = $apiKey;
$options[RequestOptions::HEADERS] = $headers;

return $this->callApi($method, $uri, $options);
Expand Down

0 comments on commit 36140eb

Please sign in to comment.