Skip to content

Commit b13ef3a

Browse files
authored
Merge pull request #35 from Local-Data-Exchange/feature/updatedocment
#1171557893478913 changed the readme
2 parents 40a3a33 + 0e29275 commit b13ef3a

4 files changed

Lines changed: 49 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
# CHANGELOG
2+
## 0.1.23
3+
- Added form_params support.
24

35
## 0.1.22
46
- This version include support of call back function for prometheus config.

src/Config/api_helper.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,24 @@
146146
],
147147
],
148148
],
149+
// Sample API to test Form_params
149150

151+
'formParams' => [
152+
'name' => 'httpbin',
153+
'method' => 'POST',
154+
'uri' => '/post',
155+
'request_type' => 'form_data',
156+
'form_params' => [
157+
'parameters' => [
158+
'revision' => '{revision}',
159+
],
160+
],
161+
'mappings' => [
162+
'form_params' => [
163+
'revision' => 'param.revision',
164+
],
165+
],
166+
],
150167
'delete' => [
151168
'name' => 'httpbin',
152169
'method' => 'DELETE',

tests/ApiBuilderTest.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,5 +82,16 @@ public function testHttpBinPostXml()
8282
self::assertEquals('Barbarian', $val->attributes->class[0]);
8383
self::assertEquals('http://mockbin.org/echo', $response->meta->uri);
8484
}
85-
85+
public function testHttpBinPostFormParams()
86+
{
87+
$apibuilder = new ApiBuilder();
88+
$api = $apibuilder->api('httpbin');
89+
$api = $api->addHeaders(['Content-Type' => 'application/x-www-form-urlencoded']);
90+
$response = $api->formParams(['param' => ['revision' => 'one']]);
91+
self::assertTrue($response->success);
92+
self::assertArrayHasKey('form',$response->body);
93+
self::assertEquals('https://httpbin.org/post', $response->meta->uri);
94+
self::assertEquals($api->requestOptions['headers']['Content-Type'],'application/x-www-form-urlencoded');
95+
self::assertEquals('one',$response->meta->params['form_params']['parameters']['revision']);
96+
}
8697
}

tests/TestCase.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,25 @@ private function returnconfig()
152152
],
153153
],
154154
],
155+
// Sample API to test Form_params
155156

157+
'formParams' => [
158+
'name' => 'httpbin',
159+
'method' => 'POST',
160+
'uri' => '/post',
161+
'request_type' => 'form_data',
162+
'form_params' => [
163+
'parameters' => [
164+
'revision' => '{revision}',
165+
],
166+
],
167+
'mappings' => [
168+
'form_params' => [
169+
'revision' => 'param.revision',
170+
],
171+
],
172+
],
173+
156174
'delete' => [
157175
'name' => 'httpbin',
158176
'method' => 'DELETE',

0 commit comments

Comments
 (0)