Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F13144737
EnvTagTest.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
EnvTagTest.php
View Options
<?php
namespace
Keruald\Yaml\Tests\Tags
;
use
Keruald\Yaml\Parser
;
use
Keruald\Yaml\Tags\EnvTag
;
use
PHPUnit\Framework\TestCase
;
class
EnvTagTest
extends
TestCase
{
private
EnvTag
$tag
;
protected
function
setUp
()
:
void
{
$this
->
tag
=
new
EnvTag
();
$_ENV
[
"ORBEON_DB_HOST"
]
=
"localhost"
;
$_ENV
[
"ORBEON_DB_PORT"
]
=
"5432"
;
$_SERVER
[
"ORBEON_DB_NAME"
]
=
"orbeon_db"
;
}
public
function
testHandle
()
{
$this
->
assertEquals
(
"localhost"
,
$this
->
tag
->
handle
(
"ORBEON_DB_HOST"
));
}
public
function
testHandleWithServerVariable
()
{
$this
->
assertEquals
(
"orbeon_db"
,
$this
->
tag
->
handle
(
"ORBEON_DB_NAME"
));
}
public
function
testHandleWithMissingVariable
()
{
$this
->
assertEquals
(
"5432"
,
$this
->
tag
->
handle
(
"ORBEON_DB_PORT"
));
}
///
/// Integration
///
public
function
testFullParse
()
{
$yamlContent
=
<<<YAML
database:
host: !env ORBEON_DB_HOST
port: !env ORBEON_DB_PORT
name: !env ORBEON_DB_NAME
pool_size: 10
YAML;
$expected
=
[
"database"
=>
[
"host"
=>
"localhost"
,
"port"
=>
"5432"
,
"name"
=>
"orbeon_db"
,
"pool_size"
=>
10
,
],
];
$parser
=
new
Parser
();
$parser
->
withTagClass
(
EnvTag
::
class
);
$actual
=
$parser
->
parse
(
$yamlContent
);
$this
->
assertEquals
(
$expected
,
$actual
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Fri, Nov 21, 17:05 (3 h, 12 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3152080
Default Alt Text
EnvTagTest.php (1 KB)
Attached To
Mode
rKERUALD Keruald libraries development repository
Attached
Detach File
Event Timeline
Log In to Comment