mercredi 28 octobre 2020

Laravel Testing - How to run command with RefreshDatabase with seed

in Laravel I need to run db:seed after refreshdatabase

I write this code, all tables deleted and then run my migration successfully.

My question is How to run my command after seed?

class ExampleTest extends TestCase
{

    use RefreshDatabase;

    
    public function testDbSeed()
    {
        Artisan::call('db:seed');
        $resultAsText = Artisan::output();
        $this->assertTrue(true);
    }

then i need to run my CUSTOM command :

php artisan permission:sync

    public function testPermissionSync()
    {
        Artisan::call('permission:sync');
        $resultAsText = Artisan::output();
        $this->assertTrue(true);
    }

if this command running my main page opened

and below test asserted

    /**
     * A basic test example.
     *
     * @return void
     */
    public function testBasicTest()
    {

        $response = $this->get('/');

        $response->assertStatus(200);
    }

but this test not passed and assert is 403

Aucun commentaire:

Enregistrer un commentaire