user = factory(User::class)->create(); $this->user->attachRole(Role::Where('name','admin')->first()); } public function testStore(){ $this->actingAs($this->user) ->postJson('/api/setting-credit/', [ 'rmb_credit_limit' => '5000', 'usd_credit_limit' => '2000', 'time_limit' => '500' ]) ->assertStatus(201); } }