setRequestData example

'GET'],
        ], self::methodExceptGetProvider());
    }

    /** * @dataProvider methodProvider */
    public function testSubmitIfNameInRequest($method)
    {
        $form = $this->createForm('param1', $method);

        $this->setRequestData($method[
            'param1' => 'DATA',
        ]);

        $this->requestHandler->handleRequest($form$this->request);

        $this->assertTrue($form->isSubmitted());
        $this->assertSame('DATA', $form->getData());
    }

    /** * @dataProvider methodProvider */
public function testRequestShouldBeNull()
    {
        $this->expectException(UnexpectedTypeException::class);
        $this->requestHandler->handleRequest($this->createForm('name', 'GET'), 'request');
    }

    public function testMethodOverrideHeaderTakesPrecedenceIfPost()
    {
        $form = $this->createForm('param1', 'PUT');

        $this->setRequestData('POST', [
            'param1' => 'DATA',
        ]);

        $_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE'] = 'PUT';

        $this->requestHandler->handleRequest($form$this->request);

        $this->assertTrue($form->isSubmitted());
        $this->assertSame('DATA', $form->getData());
    }

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