guests_may_not_create_threads

Posted 10 months ago by hjortur17

Hi, I'm having trouble getting me tests to run. It always respond with this:

Failed asserting that exception of type "Illuminate\Database\QueryException" matches expected exception "Illuminate\Auth\AuthenticationException". Message was: "SQLSTATE[23000]: Integrity constraint violation: 19 NOT NULL constraint failed: threads.user_id

And this is my code:

/** @test */
    function guests_may_not_create_threads()
    {
        $this->expectException('Illuminate\Auth\AuthenticationException');

        $thread = factory('App\Thread')->make();

        $this->post('/frettir', $thread->toArray());
    }

And the Controller has

public function __contstuct()
       {
              $this->middleware('auth')->only('store');
       }

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