'09120000000']); } public function test_passes_with_valid_code_for_session_phone(): void { OtpCode::factory()->create(['phone' => '09120000000', 'code' => '1234']); $this->assertPasses(VerifyOtpRequest::class, ['otp_code' => '1234']); } public function test_fails_without_code(): void { $this->assertFailsOn('otp_code', VerifyOtpRequest::class, []); } public function test_fails_when_code_is_not_four_digits(): void { OtpCode::factory()->create(['phone' => '09120000000', 'code' => '123']); $this->assertFailsOn('otp_code', VerifyOtpRequest::class, ['otp_code' => '123']); $this->assertFailsOn('otp_code', VerifyOtpRequest::class, ['otp_code' => 'abcd']); } public function test_fails_with_wrong_code(): void { OtpCode::factory()->create(['phone' => '09120000000', 'code' => '1234']); $this->assertFailsOn('otp_code', VerifyOtpRequest::class, ['otp_code' => '0000']); } public function test_fails_with_expired_code(): void { OtpCode::factory()->expired()->create(['phone' => '09120000000', 'code' => '1234']); $this->assertFailsOn('otp_code', VerifyOtpRequest::class, ['otp_code' => '1234']); } public function test_fails_when_code_belongs_to_another_phone(): void { OtpCode::factory()->create(['phone' => '09130000000', 'code' => '1234']); $this->assertFailsOn('otp_code', VerifyOtpRequest::class, ['otp_code' => '1234']); } }