assertDataBasr

Posted 4 months 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

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

Laracasts Mascot

Hi, Have We Met Yet?

Did you know that, in addition to the forum, Laracasts includes well over 1000 lessons on modern web development? All for the price of one lunch out per month.

Sign Me Up

Channels

Reply to

Use Markdown with GitHub-flavored code blocks.