Skip to content
This repository has been archived by the owner on Apr 20, 2021. It is now read-only.

Modified iSendARequestToWithParameters in case GET request send params a... #96

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
21 changes: 21 additions & 0 deletions src/Context/RestContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,16 @@ public function iSendARequestToWithParameters($method, $url, TableNode $datas)

parse_str(implode('&', $parameters), $parameters);

if (stristr($method, 'GET')) {
$parametersArray = array();
foreach ($parameters as $key => $value) {
$parametersArray[] = $key.'='.$value;
}

$url .= (!strstr($url, '?') ? '?' : '&').implode('&', $parametersArray);
$parameters = array();
}

$client->request($method, $this->locatePath($url), $parameters);
$client->followRedirects(true);

Expand Down Expand Up @@ -265,4 +275,15 @@ private function getHttpHeaders()
CASE_LOWER
);
}

/**
* @Then /^the response should contain '([^']*)'$/
*/
public function theResponseShouldContain($expected)
{
$expected = str_replace('\\"', '"', $expected);
$actual = $this->getSession()->getPage()->getContent();
$message = sprintf('The string "%s" is not containd by the response of the current request', $expected);
$this->assertContains($expected, $actual, $message);
}
}