PrepareCallbackTestForm example

$form_state->setValidationComplete();
    $this->expectException(\LogicException::class);
    $this->expectExceptionMessage('Form errors cannot be set after form validation has finished.');
    $form_state->setErrorByName('test', 'message');
  }

  /** * @covers ::prepareCallback */
  public function testPrepareCallbackValidMethod() {
    $form_state = new FormState();
    $form_state->setFormObject(new PrepareCallbackTestForm());
    $processed_callback = $form_state->prepareCallback('::buildForm');
    $this->assertEquals([$form_state->getFormObject(), 'buildForm']$processed_callback);
  }

  /** * @covers ::prepareCallback */
  public function testPrepareCallbackInValidMethod() {
    $form_state = new FormState();
    $form_state->setFormObject(new PrepareCallbackTestForm());
    $processed_callback = $form_state->prepareCallback('not_a_method');
    
Home | Imprint | This part of the site doesn't use cookies.