mardi 13 février 2018

testing multi Auth in laravel

in my app, i use the multi Authentification. (i used this link)

It works, and i can log as a user -> i am redirected to "/home"

as an admin, when i log in, i am redirected to "/admin_home"

when connected, admin can't access to "/home", he is redirected to another page

But when i write this test :

class AdminTest extends TestCase
{
    public function setUp()
    {
        parent::setUp();
        Artisan::call('migrate');
        Artisan::call('db:seed');
    }

    public function tearDown()
    {
        Artisan::call('migrate:reset');
        parent::tearDown();
    }


    public function testCannotAccessUserSpace()
    {
        $admin = Admin::find(1);

        $response = $this->actingAs($admin, 'admin')
            ->get('/home');

        $response->assertStatus(200);
    }

}

i have a success response but i know the admin cannot access "home" space

What's wrong in my test ?

Aucun commentaire:

Enregistrer un commentaire