setProgrammedBypassAccessCheck example

->shouldBeCalled();

    $this->assertSame($programmed$this->formStateDecoratorBase->isProgrammed());
  }

  /** * @covers ::setProgrammedBypassAccessCheck * * @dataProvider providerSingleBooleanArgument */
  public function testSetProgrammedBypassAccessCheck($programmed_bypass_access_check) {
    $this->decoratedFormState->setProgrammedBypassAccessCheck($programmed_bypass_access_check)
      ->shouldBeCalled();

    $this->assertSame($this->formStateDecoratorBase, $this->formStateDecoratorBase->setProgrammedBypassAccessCheck($programmed_bypass_access_check));
  }

  /** * @covers ::isBypassingProgrammedAccessChecks * * @dataProvider providerSingleBooleanArgument */
  public function testIsBypassingProgrammedAccessChecks($programmed_bypass_access_check) {
    
/** * {@inheritdoc} */
  public function isProgrammed() {
    return $this->decoratedFormState->isProgrammed();
  }

  /** * {@inheritdoc} */
  public function setProgrammedBypassAccessCheck($programmed_bypass_access_check = TRUE) {
    $this->decoratedFormState->setProgrammedBypassAccessCheck($programmed_bypass_access_check);

    return $this;
  }

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

  
// Programmatically submit the form with a value for the restricted field.     // Since programmed_bypass_access_check is set to TRUE by default, the     // field is accessible and can be set.     \Drupal::formBuilder()->submitForm('\Drupal\form_test\Form\FormTestProgrammaticForm', $form_state);
    $values = $form_state->get('programmatic_form_submit');
    $this->assertEquals('dummy value', $values['field_restricted'], 'The value for the restricted field is stored correctly.');

    // Programmatically submit the form with a value for the restricted field     // with programmed_bypass_access_check set to FALSE. Since access     // restrictions apply, the restricted field is inaccessible, and the value     // should not be stored.     $form_state->setProgrammedBypassAccessCheck(FALSE);
    \Drupal::formBuilder()->submitForm('\Drupal\form_test\Form\FormTestProgrammaticForm', $form_state);
    $values = $form_state->get('programmatic_form_submit');
    $this->assertNotSame('dummy value', $values['field_restricted'], 'The value for the restricted field is not stored.');

  }

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