setLocale('pt'); $student = new TestableStudent; $student->birth_date = now()->subYears(10)->toDateString(); $this->expectException(ValidationException::class); $this->expectExceptionMessage('É obrigatório informar um responsável para estudantes menores de idade.'); $student->fireCreatingEvent(); } public function test_it_allows_a_minor_with_a_responsible_when_creating(): void { $student = (new TestableStudent) ->withResponsibleForCreation(['name' => 'Responsável']); $student->birth_date = now()->subYears(10)->toDateString(); $student->fireCreatingEvent(); $this->assertTrue($student->isMinor()); } public function test_it_allows_an_adult_without_a_responsible_when_creating(): void { $student = new TestableStudent; $student->birth_date = now()->subYears(18)->toDateString(); $student->fireCreatingEvent(); $this->assertFalse($student->isMinor()); } } class TestableStudent extends Student { public function fireCreatingEvent(): mixed { return $this->fireModelEvent('creating'); } }