lundi 23 mars 2020

Testing method which need log in

I want to testing some method like user (method need log in user).

$user = User::find(1);
$response = $this->actingAs($user)->json('POST', '/store/post', [
            'title' => 'Hello World',
            'description' => 'Hello World. We are Anonymous.',
            'user_id' => 1
]);

$response
    ->assertStatus(201)
    ->assertJson([
        'created' => true,
    ]);

I have this error (I don't know hov I can add all error so I show parts of that):

1) Tests\Feature\ExampleTest::testBasicExample

Illuminate\Database\QueryException: could not find driver (SQL: PRAGMA foreign_keys = ON;)
//...
Caused by
Doctrine\DBAL\Driver\PDOException: could not find driver
//...
Caused by
PDOException: could not find driver

This same problem I have, if I tryed use Factory like on docs. How I can solve my problem?

Aucun commentaire:

Enregistrer un commentaire