Does anyone know why Guzzle strips off /local/restful/web/app_dev.php part from the full base URL which is http://localhost/local/restful/web/app_dev.php? I have to give /local/restful/web/app_dev.php/api/v1/user.json in my Gherkin line to make the test pass which is a patchy solution and breaks other developers' tests.
Any workaround?
_My settings:_
Base URL: http://localhost/local/restful/web/app_dev.php
Api URL: http://localhost/local/restful/web/app_dev.php/api/v1/user.json
_ERROR_
When I send a "POST" request to "/api/v1/user.json"
Client error response
[status code] 404
[reason phrase] Not Found
[url] http://localhost/api/v1/user.json (Guzzle\Http\Exception\ClientErrorResponseException)
_Gherkin_
When I send a "POST" request to "/api/v1/user.json"
_FeatureContext_
class FeatureContext extends MinkContext implements KernelAwareContext
{
public function __construct()
{
//Output is: http://localhost/local/restful/web/app_dev.php
//echo $base_url;
$this->client = new Client('http://localhost/local/restful/web/app_dev.php');
}
/**
* @When /^I send a "([^"]*)" request to "([^"]*)"$/
*/
public function iSendARequestTo($method, $uri)
{
$request = $this->client->createRequest($method, $uri);
$this->response = $this->client->send($request);
}
}
You need to use a relative path in order to merge it into the path of the base URL. So use api/v1/user.json instead of /api/v1/user.json. This pseudo-code shows how Guzzle combines relative URLs into a base URL: http://tools.ietf.org/html/rfc3986#section-5.2.2.
Excellent. That works.
there are actually 2 things to consider:
//
Most helpful comment
there are actually 2 things to consider:
//