Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F92660587
AphrontMultipartParserTestCase.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Fri, Nov 22, 12:28
Size
1 KB
Mime Type
text/x-php
Expires
Sun, Nov 24, 12:28 (2 d)
Engine
blob
Format
Raw Data
Handle
22481185
Attached To
rPHU libphutil
AphrontMultipartParserTestCase.php
View Options
<?php
final
class
AphrontMultipartParserTestCase
extends
PhutilTestCase
{
public
function
testParser
()
{
$map
=
array
(
array
(
'data'
=>
'simple.txt'
,
'variables'
=>
array
(
array
(
'a'
,
'b'
),
),
),
);
$data_dir
=
dirname
(
__FILE__
).
'/data/'
;
foreach
(
$map
as
$test_case
)
{
$data
=
Filesystem
::
readFile
(
$data_dir
.
$test_case
[
'data'
]);
$data
=
str_replace
(
"
\n
"
,
"
\r\n
"
,
$data
);
$parser
=
id
(
new
AphrontMultipartParser
())
->
setContentType
(
'multipart/form-data; boundary=ABCDEFG'
);
$parser
->
beginParse
();
$parser
->
continueParse
(
$data
);
$parts
=
$parser
->
endParse
();
$variables
=
array
();
foreach
(
$parts
as
$part
)
{
if
(!
$part
->
isVariable
())
{
continue
;
}
$variables
[]
=
array
(
$part
->
getName
(),
$part
->
getVariableValue
(),
);
}
$expect_variables
=
idx
(
$test_case
,
'variables'
,
array
());
$this
->
assertEqual
(
$expect_variables
,
$variables
);
}
}
}
Event Timeline
Log In to Comment