Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F97946409
AphrontHTTPSinkTestCase.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
Tue, Jan 7, 20:53
Size
2 KB
Mime Type
text/x-php
Expires
Thu, Jan 9, 20:53 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
23450689
Attached To
rPH Phabricator
AphrontHTTPSinkTestCase.php
View Options
<?php
/*
* Copyright 2012 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
final
class
AphrontHTTPSinkTestCase
extends
PhabricatorTestCase
{
public
function
testHTTPSinkBasics
()
{
$sink
=
new
AphrontIsolatedHTTPSink
();
$sink
->
writeHTTPStatus
(
200
);
$sink
->
writeHeaders
(
array
(
array
(
'X-Test'
,
'test'
)));
$sink
->
writeData
(
'test'
);
$this
->
assertEqual
(
200
,
$sink
->
getEmittedHTTPStatus
());
$this
->
assertEqual
(
array
(
array
(
'X-Test'
,
'test'
)),
$sink
->
getEmittedHeaders
());
$this
->
assertEqual
(
'test'
,
$sink
->
getEmittedData
());
}
public
function
testHTTPSinkStatusCode
()
{
$input
=
$this
->
tryTestCaseMap
(
array
(
200
=>
true
,
'201'
=>
true
,
1
=>
false
,
1000
=>
false
,
'apple'
=>
false
,
''
=>
false
,
),
array
(
$this
,
'tryHTTPSinkStatusCode'
));
}
protected
function
tryHTTPSinkStatusCode
(
$input
)
{
$sink
=
new
AphrontIsolatedHTTPSink
();
$sink
->
writeHTTPStatus
(
$input
);
}
public
function
testHTTPSinkResponseSplitting
()
{
$input
=
$this
->
tryTestCaseMap
(
array
(
"test"
=>
true
,
"test
\n
x"
=>
false
,
"test
\r
x"
=>
false
,
"test
\0
x"
=>
false
,
),
array
(
$this
,
'tryHTTPSinkResponseSplitting'
));
}
protected
function
tryHTTPSinkResponseSplitting
(
$input
)
{
$sink
=
new
AphrontIsolatedHTTPSink
();
$sink
->
writeHeaders
(
array
(
array
(
'X-Test'
,
$input
)));
}
public
function
testHTTPHeaderNames
()
{
$input
=
$this
->
tryTestCaseMap
(
array
(
'test'
=>
true
,
'test:'
=>
false
,
),
array
(
$this
,
'tryHTTPHeaderNames'
));
}
protected
function
tryHTTPHeaderNames
(
$input
)
{
$sink
=
new
AphrontIsolatedHTTPSink
();
$sink
->
writeHeaders
(
array
(
array
(
$input
,
'value'
)));
}
}
Event Timeline
Log In to Comment