/** * Tests that form errors during submission throw an exception. * * @covers ::setErrorByName * * @expectedException \LogicException * @expectedExceptionMessage Form errors cannot be set after form validation has finished. */ public function testFormErrorsDuringSubmission() { $form_state = new FormState(); $form_state->setValidationComplete(); $form_state->setErrorByName('test', 'message'); }