Skip to content

Commit 2b0fc59

Browse files
committed
test: Retriever
1 parent 147f32b commit 2b0fc59

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

tests/RetrieverTest.php

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php
2+
3+
namespace Ahc\Env\Test;
4+
5+
use Ahc\Env\Retriever;
6+
7+
class RetrieverTest extends \PHPUnit_Framework_TestCase
8+
{
9+
public function testLoad()
10+
{
11+
putenv('TEST=true');
12+
putenv('REST=false');
13+
putenv('NULL=null');
14+
putenv('[email protected]');
15+
putenv('MAX_LIMIT=1000');
16+
17+
$this->assertTrue(Retriever::getEnv('TEST'));
18+
$this->assertFalse(Retriever::getEnv('REST'));
19+
$this->assertNull(Retriever::getEnv('NULL'));
20+
$this->assertEquals(
21+
22+
Retriever::getEnv('ADMIN_EMAIL', null, FILTER_VALIDATE_EMAIL)
23+
);
24+
$this->assertSame(1000, Retriever::getEnv('MAX_LIMIT', null, FILTER_VALIDATE_INT));
25+
26+
$_SERVER += [
27+
'USE_CYPHER' => 'true',
28+
];
29+
30+
$this->assertTrue(Retriever::getEnv('USE_CYPHER'));
31+
32+
$_ENV += [
33+
'DEFAULT_PAYMENT' => 'paypal',
34+
];
35+
36+
$this->assertSame('paypal', Retriever::getEnv('DEFAULT_PAYMENT'));
37+
}
38+
}

0 commit comments

Comments
 (0)