Skip to content

Commit 5ddd640

Browse files
committed
WIP
1 parent aa693d6 commit 5ddd640

File tree

8 files changed

+102
-2
lines changed

8 files changed

+102
-2
lines changed

src/PathSegment/Batch/JSON.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public function emitJson(Transaction $transaction): void
7171
$uri = Url::http_build_url(
7272
ServiceProvider::endpoint(),
7373
$requestURI,
74-
Url::HTTP_URL_JOIN_PATH
74+
Url::HTTP_URL_JOIN_PATH | Url::HTTP_URL_JOIN_QUERY
7575
);
7676
break;
7777
}

src/Transaction/MultipartDocument.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ public function toRequest(): Request
162162
$uri = Url::http_build_url(
163163
ServiceProvider::endpoint(),
164164
$requestURI,
165-
Url::HTTP_URL_JOIN_PATH
165+
Url::HTTP_URL_JOIN_PATH | Url::HTTP_URL_JOIN_QUERY
166166
);
167167
break;
168168
}

tests/Protocol/BatchJSONTest.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,24 @@ public function test_full_url()
6060
);
6161
}
6262

63+
public function test_query_param()
64+
{
65+
$this->assertJsonMetadataResponse(
66+
(new Request)
67+
->path('/$batch')
68+
->post()
69+
->body([
70+
'requests' => [
71+
[
72+
'id' => 0,
73+
'method' => 'get',
74+
'url' => 'http://localhost/odata/flights?$top=1',
75+
]
76+
]
77+
])
78+
);
79+
}
80+
6381
public function test_any_response_type()
6482
{
6583
$this->assertJsonMetadataResponse(

tests/Protocol/BatchMultipartTest.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,27 @@ public function test_full_url()
102102
);
103103
}
104104

105+
public function test_query_param()
106+
{
107+
$this->assertTextMetadataResponse(
108+
(new Request)
109+
->path('/$batch')
110+
->header('content-type', 'multipart/mixed; boundary=batch_36522ad7-fc75-4b56-8c71-56071383e77c')
111+
->post()
112+
->multipart(<<<MULTIPART
113+
--batch_36522ad7-fc75-4b56-8c71-56071383e77c
114+
Content-Type: application/http
115+
116+
GET http://localhost/odata/flights?\$top=1
117+
Host: localhost
118+
119+
120+
--batch_36522ad7-fc75-4b56-8c71-56071383e77c--
121+
MULTIPART
122+
)
123+
);
124+
}
125+
105126
public function test_absolute_path()
106127
{
107128
$this->assertTextMetadataResponse(
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"responses": [
3+
{
4+
"id": 0,
5+
"status": 200,
6+
"headers": {
7+
"content-type": "application/json;metadata=minimal"
8+
},
9+
"body": {
10+
"@context": "http://localhost/odata/$metadata#flights",
11+
"value": [
12+
{
13+
"id": 1,
14+
"origin": "lhr",
15+
"destination": "lax",
16+
"gate": null,
17+
"duration": "PT11H25M0S"
18+
}
19+
],
20+
"@nextLink": "http://localhost/odata/flights?top=1&skip=1"
21+
}
22+
}
23+
]
24+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"headers": {
3+
"cache-control": [
4+
"no-cache, private"
5+
],
6+
"content-type": [
7+
"application/json"
8+
],
9+
"odata-version": [
10+
"4.01"
11+
]
12+
},
13+
"status": 200
14+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
2+
--00000000-0000-0000-0000-000000000002
3+
content-type: application/http
4+
5+
HTTP/1.0 200 OK
6+
content-type: application/json;metadata=minimal
7+
8+
{"@context":"http://localhost/odata/$metadata#flights","value":[{"id":1,"origin":"lhr","destination":"lax","gate":null,"duration":"PT11H25M0S"}],"@nextLink":"http://localhost/odata/flights?top=1&skip=1"}
9+
--00000000-0000-0000-0000-000000000002--
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"headers": {
3+
"cache-control": [
4+
"no-cache, private"
5+
],
6+
"content-type": [
7+
"multipart/mixed;boundary=00000000-0000-0000-0000-000000000002"
8+
],
9+
"odata-version": [
10+
"4.01"
11+
]
12+
},
13+
"status": 200
14+
}

0 commit comments

Comments
 (0)