assertDataBasr

Published 1 month ago by PxlFxr

Hi, guys. I found similar question https://laracasts.com/discuss/channels/testing/using-assertdatabasehas-with-laravel-dusk

But that seems not working for me.

There my code

use DatabaseMigrations;

  public function testRegister()
    {

        $user = factory(\App\User::class)->make();

        $this->browse(function (Browser $browser) use ($user) {

            $pswd = str_random(10);

            $browser->visit('/')
                    ->resize(1920, 1080)
                    ->press('@reg-btn')
                    ->type('name', $user->name)
                    ->type('email', $user->email)
                    ->type('password', $pswd)
                    ->type('password_confirmation', $pswd)
                    ->screenshot('reg_form_typed')
                    ->press('@reg-form-submit')
                    ->pause(1000)
                    ->screenshot('reg_form_pressed')
                    ->assertSeeIn('.personal__link .label', 'ЛК');
        });


        $this->assertDatabaseHas('user', ['email'=>$user->email]);
    }

After this executed, i see this

Caused by
PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'craft_test.user' doesn't exist

How can i make assertDatabaseHas? Seems to be, migration rollback in test data base is done after $browse

Best Answer (As Selected By PxlFxr)
tykus

Are you sure your table is called user, and not users?

tykus
tykus
1 month ago (574,630 XP)

Are you sure your table is called user, and not users?

PxlFxr

Oh, sh~ Yes, your are right, this thread must be deleted.

Please sign in or create an account to participate in this conversation.