Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F2894772
PhutilJSONTestCase.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Advanced/Developer...
View Handle
View Hovercard
Size
925 B
Referenced Files
None
Subscribers
None
PhutilJSONTestCase.php
View Options
<?php
final
class
PhutilJSONTestCase
extends
PhutilTestCase
{
public
function
testEmptyArrayEncoding
(
)
{
$serializer
=
new
PhutilJSON
(
)
;
$expect
=
<<<EOJSON
{
"x": []
}
EOJSON
;
$this
->
assertEqual
(
$expect
,
$serializer
->
encodeFormatted
(
array
(
'x'
=>
array
(
)
)
)
,
pht
(
'Empty arrays should serialize as `%s`, not `%s`.'
,
'[]'
,
'{}'
)
)
;
}
public
function
testNestedObjectEncoding
(
)
{
$expect
=
<<<EOJSON
{
"empty-object": {},
"pair-object": {
"duck": "quack"
}
}
EOJSON
;
$empty_object
=
new
stdClass
(
)
;
$pair_object
=
new
stdClass
(
)
;
$pair_object
->
duck
=
'quack'
;
$input
=
(object)
array
(
'empty-object'
=>
$empty_object
,
'pair-object'
=>
$pair_object
,
)
;
$serializer
=
new
PhutilJSON
(
)
;
$this
->
assertEqual
(
$expect
,
$serializer
->
encodeFormatted
(
$input
)
,
pht
(
'Serialization of PHP-object JSON values.'
)
)
;
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sun, Jan 19, 20:27 (1 w, 5 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1117793
Default Alt Text
PhutilJSONTestCase.php (925 B)
Attached To
Mode
rARC Arcanist
Attached
Detach File
Event Timeline
Log In to Comment