samedi 3 mars 2018

laravel testing error, no such file or directory

I'm trying to create my first test in laravel.

    $random = str_random(12);
    $payload = [
        'name' => $random,
        'email' => $random .'@www.com',
        'password' => '123456',            

    ];

    $this->json('post', '/api/v1/register', $payload)
    ->assertStatus(200);

The method being called from this url ( /api/v1/register ) contains:

    $rules      = User::rules();
    $validation = \Validator::make( $this->input, $rules );

    if ( $validation->fails() ) {

        return true;
}else return true;

When I run the test it gives response status 500.

when I write ( echo 1; ) above this line : if ( $validation->fails() ) { it outputs (1 ) plus the 500 status response

If I write ( echo 1; )below the same line, nothing outputted, so that line the line producing the error.

I check laravel log file and this is the error: [2018-03-03 12:55:07] testing.ERROR: SQLSTATE[HY000] [2002] No such file or directory {"exception":"[object] (PDOException(code: 2002): SQLSTATE[HY000] [2002] No such file or directory at /opt/lampp/htdocs/ws/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php:67)

Note: calling the same URL from the browser or from a rest client works fine with no errors.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire