Skip to content

Instantly share code, notes, and snippets.

@Heolink
Created June 25, 2015 09:11
Show Gist options
  • Save Heolink/9506cd9d726dbaf333c4 to your computer and use it in GitHub Desktop.
Save Heolink/9506cd9d726dbaf333c4 to your computer and use it in GitHub Desktop.
Utiliser un fichier .env.testing dans les tests phpunit
<?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