You are a developer and looking for Shopware projects?
Apply Now!
HarFileResponseFactory example
class
HarFileResponseFactoryTest
extends
TestCase
{
private
string
$fixtureDir
;
protected
function
setUp
(
)
: void
{
$this
->fixtureDir = \
dirname
(
__DIR__
)
.'/Fixtures/har';
}
public
function
testResponseGeneration
(
)
{
$factory
=
new
HarFileResponseFactory
(
"{
$this
->fixtureDir
}
/symfony.com_archive.har"
)
;
$client
=
new
MockHttpClient
(
$factory
, 'https://symfony.com'
)
;
$response
=
$client
->
request
(
'GET', '/releases.json'
)
;
$this
->
assertSame
(
200,
$response
->
getStatusCode
(
)
)
;
$body
=
$response
->
toArray
(
)
;
$headers
=
$response
->
getHeaders
(
)
;
$this
->
assertCount
(
23,
$headers
)
;
$this
->
assertArrayHasKey
(
'symfony_versions',
$body
)
;
}