Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F18126557
ServiceTest.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
ServiceTest.php
View Options
<?php
declare
(
strict_types
=
1
);
namespace
Nasqueron\SAAS\Tests
;
use
Nasqueron\SAAS\SaaSException
;
use
Nasqueron\SAAS\Service
;
use
Nasqueron\SAAS\Tests\Mocks\TestService
;
use
PHPUnit\Framework\TestCase
;
final
class
ServiceTest
extends
TestCase
{
/**
* @var \Nasqueron\SAAS\Service
*/
private
$service
;
/**
* @var \Nasqueron\SAAS\Service
*/
private
$notExistingService
;
protected
function
setUp
()
{
$this
->
service
=
new
TestService
(
"service.acme.tld"
);
$this
->
notExistingService
=
new
TestService
(
"bipbip.acme.tld"
);
}
public
function
testIsExisting
()
{
$this
->
assertTrue
(
$this
->
service
->
isExisting
());
$this
->
assertFalse
(
$this
->
notExistingService
->
isExisting
());
}
/**
* @dataProvider hostProvider
*/
public
function
testGetServerHost
(
$host
,
$expected
)
{
$_SERVER
[
"HTTP_HOST"
]
=
$host
;
$this
->
assertEquals
(
$expected
,
Service
::
getServerHost
());
}
public
function
hostProvider
()
:
iterable
{
yield
[
"service.acme.tld"
,
"service.acme.tld"
];
yield
[
"service.acme.tld:1234"
,
"service.acme.tld"
];
yield
[
"127.0.0.1"
,
"127.0.0.1"
];
yield
[
"127.0.0.1:1234"
,
"127.0.0.1"
];
yield
[
""
,
""
];
yield
[
":1234"
,
""
];
}
public
function
testGetUriForNginxServer
()
{
$_SERVER
[
'REQUEST_URI'
]
=
"/foo"
;
$this
->
assertEquals
(
"/foo"
,
Service
::
getUri
());
}
public
function
testGetUriForInternalPHPServer
()
{
$_SERVER
[
'DOCUMENT_URI'
]
=
"/foo"
;
$this
->
assertEquals
(
"/foo"
,
Service
::
getUri
());
}
public
function
testGetUriWhenThereIsNot
()
{
unset
(
$_SERVER
[
'DOCUMENT_URI'
]);
unset
(
$_SERVER
[
'REQUEST_URI'
]);
$this
->
expectException
(
SaasException
::
class
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Fri, Dec 19, 22:17 (1 d, 2 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3263639
Default Alt Text
ServiceTest.php (1 KB)
Attached To
Mode
rSAASSVC SaaS base entry point
Attached
Detach File
Event Timeline
Log In to Comment