create([ 'password' => bcrypt('password'), 'province_id' => Province::factory() ]); $response = $this->postJson('/server/auth/login', [ 'username' => $user->username, 'password' => 'password', 'telephone_id' => $this->faker->numerify('TID####') ]); $response->assertOk() ->assertJson([ 'message' => __('messages.successful'), ]); $this->assertAuthenticatedAs($user); } public function test_username_is_required() { $response = $this->postJson('/server/auth/login', [ 'password' => 'password', ]); $response->assertUnprocessable() ->assertInvalid([ 'username' => __('validation.required', ['attribute' => 'نام کاربری']), ]); } public function test_password_is_required() { $response = $this->postJson('/server/auth/login', [ 'username' => $this->faker->lexify('?????'), ]); $response->assertUnprocessable() ->assertInvalid([ 'password' => __('validation.required', ['attribute' => 'رمز عبور']) ]); } public function test_telephone_id_is_required() { $response = $this->postJson('/server/auth/login', [ 'username' => $this->faker->lexify('?????'), 'password' => 'password', ]); $response->assertUnprocessable() ->assertInvalid([ 'telephone_id' => __('validation.required', ['attribute' => 'کد تلفن']) ]); } }