I'm building an application in Symfony with a sql server running on a vagrant virtual box.
The application works, but I have to write some functional tests. I followed the instructions on the site of Symfony itself but the test fails. In my first test I'm asserting that the response code is 200 but I get a 500 because the server "actively refused the connection". When using postman, or just my browser, the route returns everything that it should.
Here is my test code:
public function testGetMessageList()
{
$client = static::createClient(array(), array(
'PHP_AUTH_USER' => 'jonas',
'PHP_AUTH_PW' => 'joskebammens',
'SERVER_PORT' => '8000',
));
$client->request('GET', '/messages');
//var_dump($client->getResponse());
var_dump($client->getRequest());
$this->assertEquals(200, $client->getResponse()->getStatusCode());
}
The var_dump of the request shows me, among other variables, this:
public $server =>
class Symfony\Component\HttpFoundation\ServerBag#128 (1) {
protected $parameters =>
array(19) {
'SERVER_NAME' =>
string(9) "localhost"
'SERVER_PORT' =>
int(80)
'HTTP_HOST' =>
string(9) "localhost"
'HTTP_USER_AGENT' =>
string(18) "Symfony BrowserKit"
'HTTP_ACCEPT' =>
string(63) "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
'HTTP_ACCEPT_LANGUAGE' =>
string(14) "en-us,en;q=0.5"
'HTTP_ACCEPT_CHARSET' =>
string(30) "ISO-8859-1,utf-8;q=0.7,*;q=0.7"
'REMOTE_ADDR' =>
string(9) "127.0.0.1"
'SCRIPT_NAME' =>
string(0) ""
'SCRIPT_FILENAME' =>
string(0) ""
'SERVER_PROTOCOL' =>
string(8) "HTTP/1.1"
'REQUEST_TIME' =>
int(1541148564)
'PHP_AUTH_USER' =>
string(5) "jonas"
'PHP_AUTH_PW' =>
string(12) "joskebammens"
[0] =>
string(0) ""
'PATH_INFO' =>
string(0) ""
'REQUEST_METHOD' =>
string(3) "GET"
'REQUEST_URI' =>
string(9) "/messages"
'QUERY_STRING' =>
string(0) ""
}
}
I can't seem to change any variables other than the authentication ones. My vagrant is on 192.168.33.22, sql on port 3306. And my php server is on localhost:8000.
Does anyone know what I could do or what I am doing wrong?
Thanks
Aucun commentaire:
Enregistrer un commentaire