Amp\ArtaxTest\ClientHttpBinIntegrationTest::testFormEncodedBodyRequest PHP Method

testFormEncodedBodyRequest() public method

    public function testFormEncodedBodyRequest()
    {
        //$this->markTestSkipped();
        $uri = 'http://httpbin.org/post';
        $client = new Client();
        $body = new FormBody();
        $field1 = 'test val';
        $field2 = 'val2';
        $body->addField('field1', $field1);
        $body->addField('field2', $field2);
        $request = (new Request())->setBody($body)->setUri($uri)->setMethod('POST');
        $promise = $client->request($request);
        $response = \Amp\wait($promise);
        $this->assertInstanceOf('Amp\\Artax\\Response', $response);
        $result = json_decode($response->getBody(), true);
        $this->assertEquals($field1, $result['form']['field1']);
        $this->assertEquals($field2, $result['form']['field2']);
        $this->assertEquals('application/x-www-form-urlencoded', $result['headers']['Content-Type']);
    }