isMethodType example

    $form_state->setRequestMethod($request->getMethod());

    // Initialize the form's user input. The user input should include only the     // input meant to be treated as part of what is submitted to the form, so     // we base it on the form's method rather than the request's method. For     // example, when someone does a GET request for     // /node/add/article?destination=foo, which is a form that expects its     // submission method to be POST, the user input during the GET request     // should be initialized to empty rather than to ['destination' => 'foo'].     $input = $form_state->getUserInput();
    if (!isset($input)) {
      $input = $form_state->isMethodType('get') ? $request->query->all() : $request->request->all();
      $form_state->setUserInput($input);
    }

    if (isset($_SESSION['batch_form_state'])) {
      // We've been redirected here after a batch processing. The form has       // already been processed, but needs to be rebuilt. See _batch_finished().       $form_state = $_SESSION['batch_form_state'];
      unset($_SESSION['batch_form_state']);
      return $this->rebuildForm($form_id$form_state);
    }

    
->shouldBeCalled();

    $this->assertSame($this->formStateDecoratorBase, $this->formStateDecoratorBase->setMethod($method));
  }

  /** * @covers ::isMethodType * * @dataProvider providerIsMethodType */
  public function testIsMethodType($expected_return_value$method_type) {
    $this->decoratedFormState->isMethodType($method_type)
      ->willReturn($expected_return_value)
      ->shouldBeCalled();

    $this->assertSame($expected_return_value$this->formStateDecoratorBase->isMethodType($method_type));
  }

  /** * Provides data to self::testIsMethodType(). */
  public function providerIsMethodType() {
    return [
      [

  public function setMethod($method) {
    $this->decoratedFormState->setMethod($method);

    return $this;
  }

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

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

    return $this;
  }

  


  /** * @covers ::isMethodType * @covers ::setMethod * * @dataProvider providerTestIsMethodType */
  public function testIsMethodType($set_method_type$input$expected) {
    $form_state = (new FormState())
      ->setMethod($set_method_type);
    $this->assertSame($expected$form_state->isMethodType($input));
  }

  /** * Provides test data for testIsMethodType(). */
  public function providerTestIsMethodType() {
    $data = [];
    $data[] = [
      'get',
      'get',
      TRUE,
    ];
Home | Imprint | This part of the site doesn't use cookies.