env returns an environment variable
This commit is contained in:
parent
61e3dfa0ec
commit
52d8e4c626
|
@ -1,2 +1,8 @@
|
|||
<?php
|
||||
|
||||
if (!function_exists('env')) {
|
||||
function env(string $name): ?string
|
||||
{
|
||||
return $_ENV[$name];
|
||||
}
|
||||
}
|
||||
|
|
24
tests/EnvironmentTest.php
Normal file
24
tests/EnvironmentTest.php
Normal file
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\Opdavies\PhpHelpers;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class EnvironmentTest extends TestCase
|
||||
{
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
// Ensure that the enviornment variables are empty before each test.
|
||||
$_ENV = [];
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function it_gets_an_environment_variable()
|
||||
{
|
||||
$_ENV['APP_ENV'] = 'prod';
|
||||
|
||||
$this->assertSame('prod', env('APP_ENV'));
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue