I'm doing some tests with PHPUnit, but I have some problems especially when testing the Controller.
I want to test a route of a Controller by just calling the route and check if the response is a HTTP-Status 200. But alwas the Console has the smae errors.
It says something about a token that is missing. I don't have a clue what kind of token this is.
Also this is the 401 Error he gets.
My PHPUnit-Test looks like this:
namespace App\Tests\Controller;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
class PersonControllerTest extends WebTestCase { private $client;
protected function setUp()
{
$this->client = static::createClient([], [
'PHP_AUTH_USER' => 'user',
'PHP_AUTH_PW' => 'pass',
]);
}
public function testCreate()
{
$this->client->request('GET','/create');
$this->assertEquals(200, $this->client->getResponse()->getStatusCode());
}
public function testIndex()
{
$this->client->request('GET','/');
$this->assertEquals(200, $this->client->getResponse()->getStatusCode());
}
}
I have tried it with the authentication in the setUp Method -> didn't work.
Do you have any clue?
Thanks for all Answers or/and Comments