need your help. I try to testing my login page with feature test but i got this error, even thats run normaly when code is executed. but went i test the code i got error like this.
ErrorException: Cannot modify header information - headers already sent by (output started at D:\project\e-services-disdukcapil\vendor\phpunit\phpunit\src\Util\Printer.php:104)
that's my code :
class AuthAdminTest extends FeatureTestCase
{
protected $models;
protected $seed = 'Tests\Support\Database\Seeds\AuthSeeder';
protected $basePath = APPPATH . 'Database/';
protected $namespace = 'App';
public function setUp(): void
{
parent::setUp();
$this->models = new UserAdminModel();
// Extra code to run before each test
}
public function testAdminLoginView()
{
$res = $this->get(route_to('admin-login'));
$this->assertTrue($res->isOK());
$res->assertSee(lang('login'));
}
and this is my login controller :
public function login()
{
// No need to show a login form if the user
// is already logged in.
if ($this->auth->check())
{
$redirectURL = session('redirect_url') ?? route_to('admin-dashboard');
unset($_SESSION['redirect_url']);
return redirect()->to($redirectURL);
}
// Set a return URL if none is specified
if (session('redirect_url') == site_url('logout'))
{
$_SESSION['redirect_url'] = previous_url() ?? route_to('admin-dashboard');
}
if (previous_url() == site_url('logout'))
{
$_SESSION['redirect_url'] = route_to('admin-dashboard');
}
return view($this->config->views['admin-login'], ['config' => $this->config]);
}