Files
pollux/tests/CreatesApplication.php
2026-10-30 10:12:57 +01:00

33 lines
1015 B
PHP

<?php
namespace Tests;
use Illuminate\Contracts\Console\Kernel;
trait CreatesApplication
{
/**
* Creates the application.
*
* @return \Illuminate\Foundation\Application
*/
public function createApplication()
{
$app = require __DIR__.'/../bootstrap/app.php';
$app->make(Kernel::class)->bootstrap();
// RefreshDatabase runs migrate:fresh. Refuse cached or overridden
// configuration that could point it at the application's database.
if (!$app->environment('testing')
|| config('database.default') !== 'mysql'
|| config('database.connections.mysql.host') !== 'db-test'
|| config('database.connections.mysql.database') !== 'pollux_test'
|| !empty(config('database.connections.mysql.unix_socket'))) {
throw new \RuntimeException('Tests require the isolated db-test / pollux_test database. Clear cached configuration before running tests.');
}
return $app;
}
}