Testing actions that require authentication do not work as describe cakephp manual.
I found this solution, is it the correct one ?
use App\Model\Entity\User;
...
public function testLogout()
{
$user=new User();
$user->id=1;
$this->session(['Auth' => $user]);
$this->get ( '/Users/logout' );
$this->assertRedirect(['controller' => 'Users', 'action' => 'login']);
}
Aucun commentaire:
Enregistrer un commentaire