public function iSendARequestWithFormData($method, $url, PyStringNode $body)
    {
        $url = $this->prepareUrl($url);
        $body = $this->replacePlaceHolder(trim($body));

        $fields = array();
        parse_str(implode('&', explode("\n", $body)), $fields);

        if (version_compare(ClientInterface::VERSION, '6.0', '>=')) {
            $this->request = new Request($method, $url, ['Content-Type' => 'application/x-www-form-urlencoded'], http_build_query($fields, null, '&'));
        } else {
            $this->request = $this->getClient()->createRequest($method, $url);
            /** @var \GuzzleHttp\Post\PostBodyInterface $requestBody */
            $requestBody = $this->request->getBody();
            foreach ($fields as $key => $value) {
                $requestBody->setField($key, $value);
            }
        }

        $this->sendRequest();
    }
public function iSendARequestWithFormData($method, $url, PyStringNode $body)
    {
        $url = $this->prepareUrl($url);
        $body = $this->replacePlaceHolder(trim($body));

        $fields = array();
        parse_str(implode('&', explode("\n", $body)), $fields);

        if (version_compare(ClientInterface::VERSION, '6.0', '>=')) {
            $this->request = new Request($method, $url, ['Content-Type' => 'application/x-www-form-urlencoded'], http_build_query($fields, null, '&'));
        } else {
            $this->request = $this->getClient()->createRequest($method, $url);
            /** @var \GuzzleHttp\Post\PostBodyInterface $requestBody */
            $requestBody = $this->request->getBody();
            foreach ($fields as $key => $value) {
                $requestBody->setField($key, $value);
            }
        }

        $this->sendRequest();
    }
public function iSendARequestWithFormData ( $ method , $ url , PyStringNode $ body ) { $ url = $ this -> prepareUrl ( $ url ) ; $ body = $ this -> replacePlaceHolder ( trim ( $ body ) ) ; $ fields = array ( ) ; parse_str ( implode ( '&' , explode ( "\n" , $ body ) ) , $ fields ) ; if ( version_compare ( ClientInterface :: VERSION , '6.0' , '>=' ) ) { $ this -> request = new Request ( $ method , $ url , [ 'Content-Type' => 'application/x-www-form-urlencoded' ] , http_build_query ( $ fields , null , '&' ) ) ; } else { $ this -> request = $ this -> getClient ( ) -> createRequest ( $ method , $ url ) ; /** @var \GuzzleHttp\Post\PostBodyInterface $requestBody */ $ requestBody = $ this -> request -> getBody ( ) ; foreach ( $ fields as $ key => $ value ) { $ requestBody -> setField ( $ key , $ value ) ; } } $ this -> sendRequest ( ) ; }
Sends HTTP request to specific URL with form data from PyString.

@param string       $method request method
@param string       $url    relative url
@param PyStringNode $body   request body

@When /^(?:I )?send a ([A-Z]+) request to "([^"]+)" with form data:$/
Sends HTTP request to specific URL with form data from PyString .