Skip to content

Commit

Permalink
Merge pull request #20 from RonasIT/18-env-files-are-not-visible
Browse files Browse the repository at this point in the history
#18: Added inclusion of .env files in tests
  • Loading branch information
DenTray authored Jun 6, 2024
2 parents 48bed73 + 6db16de commit e4b1577
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace RonasIT\Media\Tests;

use Carbon\Carbon;
use Dotenv\Dotenv;
use Illuminate\Support\Facades\Config;
use Orchestra\Testbench\TestCase as BaseTest;
use RonasIT\Media\MediaServiceProvider;
Expand Down Expand Up @@ -42,6 +43,20 @@ public function getFixturePath(string $fixtureName): string
}

protected function getEnvironmentSetUp($app): void
{
Dotenv::createImmutable(__DIR__ . '/..', '.env.testing')->load();

$this->setupDb($app);
}

protected function getPackageProviders($app): array
{
return [
MediaServiceProvider::class,
];
}

protected function setupDb($app): void
{
$app['config']->set('database.default', env('DB_DEFAULT', 'pgsql'));
$app['config']->set('database.connections.pgsql', [
Expand All @@ -52,11 +67,4 @@ protected function getEnvironmentSetUp($app): void
'password' => env('DB_PASSWORD', 'secret'),
]);
}

protected function getPackageProviders($app): array
{
return [
MediaServiceProvider::class
];
}
}

0 comments on commit e4b1577

Please sign in to comment.