Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F4792512
CoreTest.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
CoreTest.php
View Options
<?php
namespace
Keruald
;
class
CoreTest
extends
\PHPUnit_Framework_Testcase
{
///
/// Client information
///
function
test_extract_client_ip_from_header
()
{
$values
=
[
//Each value should return 10.0.0.3
'10.0.0.3'
,
'10.0.0.3,10.0.0.4'
,
'10.0.0.3, 10.0.0.4'
,
'10.0.0.3, 10.0.0.4, lorem ipsum dolor'
,
];
foreach
(
$values
as
$value
)
{
$this
->
assertEquals
(
'10.0.0.3'
,
extract_client_ip_from_header
(
$value
)
);
}
$this
->
assertEmpty
(
extract_client_ip_from_header
(
''
)
);
}
function
test_get_remote_addr
()
{
$this
->
assertEmpty
(
get_remote_addr
());
$_SERVER
=
[
'REMOTE_ADDR'
=>
'10.0.0.2'
];
$this
->
assertEquals
(
'10.0.0.2'
,
get_remote_addr
());
$_SERVER
+=
[
'HTTP_X_FORWARDED_FOR'
=>
'10.0.0.3'
,
'HTTP_CLIENT_IP'
=>
'10.0.0.4'
,
];
$this
->
assertEquals
(
'10.0.0.3'
,
get_remote_addr
(),
"HTTP_X_FORWARDED_FOR must be prioritized."
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Fri, Feb 28, 20:13 (4 h, 55 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2444256
Default Alt Text
CoreTest.php (1 KB)
Attached To
Mode
rKGF Keruald global functions
Attached
Detach File
Event Timeline
Log In to Comment