addRebuildInfo example

    $form_state = new FormState();
    $form = $this->formBuilder->buildForm($form_arg$form_state);
    $original_build_id = $form['#build_id'];

    $this->request->setMethod('POST');
    $form_state->setRequestMethod('POST');

    // Rebuild the form, and assert that the build ID has not changed.     $form_state->setRebuild();
    $input['form_id'] = $form_id;
    $form_state->setUserInput($input);
    $form_state->addRebuildInfo('copy', ['#build_id' => TRUE]);
    $this->formBuilder->processForm($form_id$form$form_state);
    $this->assertSame($original_build_id$form['#build_id']);
    $this->assertTrue($form_state->isCached());

    // Rebuild the form again, and assert that there is a new build ID.     $form_state->setRebuildInfo([]);
    $form = $this->formBuilder->buildForm($form_arg$form_state);
    $this->assertNotSame($original_build_id$form['#build_id']);
    $this->assertTrue($form_state->isCached());
  }

  
/** * {@inheritdoc} */
  public function getRebuildInfo() {
    return $this->decoratedFormState->getRebuildInfo();
  }

  /** * {@inheritdoc} */
  public function addRebuildInfo($property$value) {
    $this->decoratedFormState->addRebuildInfo($property$value);

    return $this;
  }

  /** * {@inheritdoc} */
  public function setStorage(array $storage) {
    $this->decoratedFormState->setStorage($storage);

    return $this;
  }
$this->assertSame($rebuild_info$this->formStateDecoratorBase->getRebuildInfo());
  }

  /** * @covers ::addRebuildInfo */
  public function testAddRebuildInfo() {
    $property = 'FOO';
    $value = 'BAR';

    $this->decoratedFormState->addRebuildInfo($property$value);

    $this->assertSame($this->formStateDecoratorBase, $this->formStateDecoratorBase->addRebuildInfo($property$value));
  }

  /** * @covers ::setStorage */
  public function testSetStorage() {
    $storage = [
      'FOO' => 'BAR',
    ];

    
Home | Imprint | This part of the site doesn't use cookies.