Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release #19

Merged
merged 2 commits into from
Feb 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions src/Context/ApiContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,58 @@
}
}

/**
* @Then the :headerName response headers contains :headerValue
*/
public function theResponseHeadersContains(string $headerName, string $headerValue): void

Check warning on line 307 in src/Context/ApiContext.php

View check run for this annotation

Codecov / codecov/patch

src/Context/ApiContext.php#L307

Added line #L307 was not covered by tests
{
$this->checkResponseHeader($headerName, $headerValue);

Check warning on line 309 in src/Context/ApiContext.php

View check run for this annotation

Codecov / codecov/patch

src/Context/ApiContext.php#L309

Added line #L309 was not covered by tests
}

/**
* @And the :headerName response headers contains :headerValue
*/
public function theAndResponseHeadersContains(string $headerName, string $headerValue): void

Check warning on line 315 in src/Context/ApiContext.php

View check run for this annotation

Codecov / codecov/patch

src/Context/ApiContext.php#L315

Added line #L315 was not covered by tests
{
$this->checkResponseHeader($headerName, $headerValue);

Check warning on line 317 in src/Context/ApiContext.php

View check run for this annotation

Codecov / codecov/patch

src/Context/ApiContext.php#L317

Added line #L317 was not covered by tests
}

protected function checkResponseHeader(string $headerName, string $headerValue): void

Check warning on line 320 in src/Context/ApiContext.php

View check run for this annotation

Codecov / codecov/patch

src/Context/ApiContext.php#L320

Added line #L320 was not covered by tests
{
$givenHeaderName = $this->stringManager->substituteValues(
$this->savedValues,
trim($headerName),

Check warning on line 324 in src/Context/ApiContext.php

View check run for this annotation

Codecov / codecov/patch

src/Context/ApiContext.php#L322-L324

Added lines #L322 - L324 were not covered by tests
);
$givenHeaderValue = $this->stringManager->substituteValues(
$this->savedValues,
trim($headerValue),

Check warning on line 328 in src/Context/ApiContext.php

View check run for this annotation

Codecov / codecov/patch

src/Context/ApiContext.php#L326-L328

Added lines #L326 - L328 were not covered by tests
);

$response = $this->getResponse();

Check warning on line 331 in src/Context/ApiContext.php

View check run for this annotation

Codecov / codecov/patch

src/Context/ApiContext.php#L331

Added line #L331 was not covered by tests

if (!$response->headers->has($givenHeaderName)) {
$message = sprintf(
'Response header %s does not exists',
$givenHeaderName,

Check warning on line 336 in src/Context/ApiContext.php

View check run for this annotation

Codecov / codecov/patch

src/Context/ApiContext.php#L333-L336

Added lines #L333 - L336 were not covered by tests
);

throw new RuntimeException($message);

Check warning on line 339 in src/Context/ApiContext.php

View check run for this annotation

Codecov / codecov/patch

src/Context/ApiContext.php#L339

Added line #L339 was not covered by tests
}

$responseHeaderValue = $response->headers->get($givenHeaderName);

Check warning on line 342 in src/Context/ApiContext.php

View check run for this annotation

Codecov / codecov/patch

src/Context/ApiContext.php#L342

Added line #L342 was not covered by tests

if (null === $responseHeaderValue || !substr_count($responseHeaderValue, $givenHeaderValue) > 0) {
$message = sprintf(
'Response header %s does not match. Expected: %s, given value: %s',
$givenHeaderName,
$givenHeaderValue,
$responseHeaderValue,

Check warning on line 349 in src/Context/ApiContext.php

View check run for this annotation

Codecov / codecov/patch

src/Context/ApiContext.php#L344-L349

Added lines #L344 - L349 were not covered by tests
);

throw new RuntimeException($message);

Check warning on line 352 in src/Context/ApiContext.php

View check run for this annotation

Codecov / codecov/patch

src/Context/ApiContext.php#L352

Added line #L352 was not covered by tests
}
}

protected function convertRunnableCodeParams(array $requestParams): array
{
foreach ($requestParams as $key => $value) {
Expand Down
Loading