public function test_index_returns_all_users_by_get() { User::where('id', '>=', 1)->delete(); $users = factory(User::class, 3)->create(); $user = $users->first(); //$this->actingAs($user); $this->get('api/v1/user'); $this->seeStatusCode(200); $this->seeJson(['per_page' => 50]); foreach ($users as $user) { $this->seeJson(['username' => $user->username]); } }
/** * Determine if the user is authorized to make this request. * * @return bool */ public function authorize() { $id = $this->route('user'); return User::where('id', $id)->exists(); }