Created
June 25, 2015 09:11
-
-
Save Heolink/9506cd9d726dbaf333c4 to your computer and use it in GitHub Desktop.
Utiliser un fichier .env.testing dans les tests phpunit
This file contains hidden or 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
<?php | |
class TestCase extends Illuminate\Foundation\Testing\TestCase { | |
protected $baseUrl = 'http://localhost'; | |
/** | |
* Creates the application. | |
* | |
* @return \Illuminate\Foundation\Application | |
*/ | |
public function createApplication() | |
{ | |
if(file_exists(__DIR__.'/../.env.testing')) { | |
$envs = file(__DIR__.'/../.env.testing'); | |
if($envs) { | |
foreach($envs as $env) { | |
$env = str_replace(array("\n","\r"), '', trim($env) ); | |
if($env) { | |
putenv($env); | |
} | |
} | |
} | |
} | |
$app = require __DIR__.'/../bootstrap/app.php'; | |
$app->make(Illuminate\Contracts\Console\Kernel::class)->bootstrap(); | |
return $app; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment