Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
27pchrisl committed Jan 18, 2024
1 parent aa693d6 commit 5ddd640
Show file tree
Hide file tree
Showing 8 changed files with 102 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/PathSegment/Batch/JSON.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public function emitJson(Transaction $transaction): void
$uri = Url::http_build_url(
ServiceProvider::endpoint(),
$requestURI,
Url::HTTP_URL_JOIN_PATH
Url::HTTP_URL_JOIN_PATH | Url::HTTP_URL_JOIN_QUERY
);
break;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Transaction/MultipartDocument.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ public function toRequest(): Request
$uri = Url::http_build_url(
ServiceProvider::endpoint(),
$requestURI,
Url::HTTP_URL_JOIN_PATH
Url::HTTP_URL_JOIN_PATH | Url::HTTP_URL_JOIN_QUERY
);
break;
}
Expand Down
18 changes: 18 additions & 0 deletions tests/Protocol/BatchJSONTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,24 @@ public function test_full_url()
);
}

public function test_query_param()
{
$this->assertJsonMetadataResponse(
(new Request)
->path('/$batch')
->post()
->body([
'requests' => [
[
'id' => 0,
'method' => 'get',
'url' => 'http://localhost/odata/flights?$top=1',
]
]
])
);
}

public function test_any_response_type()
{
$this->assertJsonMetadataResponse(
Expand Down
21 changes: 21 additions & 0 deletions tests/Protocol/BatchMultipartTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,27 @@ public function test_full_url()
);
}

public function test_query_param()
{
$this->assertTextMetadataResponse(
(new Request)
->path('/$batch')
->header('content-type', 'multipart/mixed; boundary=batch_36522ad7-fc75-4b56-8c71-56071383e77c')
->post()
->multipart(<<<MULTIPART
--batch_36522ad7-fc75-4b56-8c71-56071383e77c
Content-Type: application/http
GET http://localhost/odata/flights?\$top=1
Host: localhost
--batch_36522ad7-fc75-4b56-8c71-56071383e77c--
MULTIPART
)
);
}

public function test_absolute_path()
{
$this->assertTextMetadataResponse(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"responses": [
{
"id": 0,
"status": 200,
"headers": {
"content-type": "application/json;metadata=minimal"
},
"body": {
"@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"
}
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"headers": {
"cache-control": [
"no-cache, private"
],
"content-type": [
"application/json"
],
"odata-version": [
"4.01"
]
},
"status": 200
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

--00000000-0000-0000-0000-000000000002
content-type: application/http

HTTP/1.0 200 OK
content-type: application/json;metadata=minimal

{"@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"}
--00000000-0000-0000-0000-000000000002--
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"headers": {
"cache-control": [
"no-cache, private"
],
"content-type": [
"multipart/mixed;boundary=00000000-0000-0000-0000-000000000002"
],
"odata-version": [
"4.01"
]
},
"status": 200
}

0 comments on commit 5ddd640

Please sign in to comment.