Skip to content
This repository has been archived by the owner on Sep 15, 2022. It is now read-only.

Define new step in API context to fix #215 #216

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions src/Knp/FriendlyContexts/Builder/RequestBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ class RequestBuilder implements RequestBuilderInterface

private $files;

private $client;

private static function getAcceptedMethods()
{
return [
Expand Down Expand Up @@ -271,6 +273,7 @@ public function setClient(ClientInterface $client = null)

public function getClient()
{
return $this->requestBuilders[$this->method]->getClient();
}

protected function clean()
Expand Down
11 changes: 11 additions & 0 deletions src/Knp/FriendlyContexts/Context/ApiContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,17 @@ public function iSendTheRequest()
$this->response = $e->getResponse();
}
}

/**
* @Then /^I print last URL requested$/
*/
public function iPrintLastUrlRequest()
{
$uri = $this->getRequestBuilder()->getUri();
$uri = substr($uri, 0, 1) === '/' ? substr($uri, 1) : $uri;

echo $this->getRequestBuilder()->getClient()->getBaseUrl(). DIRECTORY_SEPARATOR .$uri;
}

/**
* @Then /^I should receive a (?<httpCode>[0-9]+) response$/
Expand Down