Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F7577922
RemoteAddressTest.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
RemoteAddressTest.php
View Options
<?php
declare
(
strict_types
=
1
);
namespace
Keruald\OmniTools\Tests\HTTP\Requests
;
use
Keruald\OmniTools\HTTP\Requests\RemoteAddress
;
use
PHPUnit\Framework\Attributes\DataProvider
;
use
PHPUnit\Framework\TestCase
;
class
RemoteAddressTest
extends
TestCase
{
///
/// Tests
///
public
function
testEmptyRequest
()
:
void
{
$address
=
new
RemoteAddress
;
$this
->
assertEmpty
(
$address
->
getClientAddress
());
$this
->
assertEmpty
(
$address
->
getAll
());
$this
->
assertFalse
(
$address
->
has
());
}
#[DataProvider("provideTenZeroZeroThreeHeaderValues")]
public
function
testGetOne
(
string
$value
)
:
void
{
$address
=
new
RemoteAddress
(
$value
);
$this
->
assertEquals
(
'10.0.0.3'
,
$address
->
getClientAddress
());
}
#[DataProvider("provideTenZeroZeroThreeHeaderValues")]
public
function
testGetAll
(
string
$value
)
:
void
{
$address
=
new
RemoteAddress
(
$value
);
$this
->
assertEquals
(
$value
,
$address
->
getAll
());
}
#[DataProvider("provideTenZeroZeroThreeHeaderValues")]
public
function
testHas
(
string
$value
)
:
void
{
$address
=
new
RemoteAddress
(
$value
);
$this
->
assertTrue
(
$address
->
has
());
}
///
/// Data provider
///
public
static
function
provideTenZeroZeroThreeHeaderValues
()
:
iterable
{
return
[
// 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'
],
];
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Thu, May 1, 02:47 (1 d, 9 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2570577
Default Alt Text
RemoteAddressTest.php (1 KB)
Attached To
Mode
rKERUALD Keruald libraries development repository
Attached
Detach File
Event Timeline
Log In to Comment