Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
fromJsonString example
$response
->
setData
(
[
[
1, 2, 3
]
]
)
;
$this
->
assertEquals
(
'[[1,2,3]]',
$response
->
getContent
(
)
)
;
$response
->
setEncodingOptions
(
\JSON_FORCE_OBJECT
)
;
$this
->
assertEquals
(
'{"0":{"0":1,"1":2,"2":3}}',
$response
->
getContent
(
)
)
;
}
public
function
testItAcceptsJsonAsString
(
)
{
$response
= JsonResponse::
fromJsonString
(
'{"foo":"bar"}'
)
;
$this
->
assertSame
(
'{"foo":"bar"}',
$response
->
getContent
(
)
)
;
}
public
function
testSetCallbackInvalidIdentifier
(
)
{
$this
->
expectException
(
\InvalidArgumentException::
class
)
;
$response
=
new
JsonResponse
(
'foo'
)
;
$response
->
setCallback
(
'+invalid'
)
;
}
public
function
testSetContent
(
)
{