PHPUnit
laravel

Laravel 5.4 と JWTAuth テスト

ソースコード

https://github.com/toknsi/apispacms

        $userActingAs = factory(User::class)->create();
        //$this->actingAs($userActingAs);
        //echo $userActingAs->email;
        //echo $userActingAs->password;  
        //echo $userActingAs->id;                
        $token = JWTAuth::attempt(['email' => $userActingAs->email,'password'=>'secret']);
        $this->call('POST', '/api/contents', 
        ['json' => ' { "type": "string" }'] , [] ,[],
        ['HTTP_Authorization' => 'Bearer '.$token])
        ->assertStatus(200)->assertJson(['user_id' =>$userActingAs->id]);