Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
Psr18Client example
class
Psr18ClientTest
extends
TestCase
{
public
static
function
setUpBeforeClass
(
)
: void
{
TestHttpServer::
start
(
)
;
}
public
function
testSendRequest
(
)
{
$factory
=
new
Psr17Factory
(
)
;
$client
=
new
Psr18Client
(
new
NativeHttpClient
(
)
,
$factory
,
$factory
)
;
$response
=
$client
->
sendRequest
(
$factory
->
createRequest
(
'GET', 'http://localhost:8057'
)
)
;
$this
->
assertSame
(
200,
$response
->
getStatusCode
(
)
)
;
$this
->
assertSame
(
'application/json',
$response
->
getHeaderLine
(
'content-type'
)
)
;
$body
=
json_decode
(
(string)
$response
->
getBody
(
)
, true
)
;
$this
->
assertSame
(
'HTTP/1.1',
$body
[
'SERVER_PROTOCOL'
]
)
;
}