-
Notifications
You must be signed in to change notification settings - Fork 11.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #27048 from laravel/env-tests
[5.7] Added a couple of tests for environment file loading
- Loading branch information
Showing
2 changed files
with
49 additions
and
0 deletions.
There are no files selected for viewing
48 changes: 48 additions & 0 deletions
48
tests/Foundation/Bootstrap/LoadEnvironmentVariablesTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php | ||
|
||
namespace Illuminate\Tests\Foundation; | ||
|
||
use Mockery as m; | ||
use PHPUnit\Framework\TestCase; | ||
use Illuminate\Foundation\Application; | ||
use Illuminate\Foundation\Bootstrap\LoadEnvironmentVariables; | ||
|
||
class LoadEnvironmentVariablesTest extends TestCase | ||
{ | ||
public function tearDown() | ||
{ | ||
m::close(); | ||
} | ||
|
||
protected function getAppMock($file) | ||
{ | ||
$app = m::mock(Application::class); | ||
|
||
$app->shouldReceive('configurationIsCached') | ||
->once()->with()->andReturn(false); | ||
$app->shouldReceive('runningInConsole') | ||
->once()->with()->andReturn(false); | ||
$app->shouldReceive('environmentPath') | ||
->once()->with()->andReturn(__DIR__.'/../fixtures'); | ||
$app->shouldReceive('environmentFile') | ||
->once()->with()->andReturn($file); | ||
|
||
return $app; | ||
} | ||
|
||
public function testCanLoad() | ||
{ | ||
$this->expectOutputString(''); | ||
|
||
(new LoadEnvironmentVariables)->bootstrap($this->getAppMock('.env')); | ||
|
||
$this->assertSame('BAR', env('FOO')); | ||
} | ||
|
||
public function testCanFailSilent() | ||
{ | ||
$this->expectOutputString(''); | ||
|
||
(new LoadEnvironmentVariables)->bootstrap($this->getAppMock('BAD_FILE')); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
FOO=BAR |