53 lines
2.4 KiB
PHP
53 lines
2.4 KiB
PHP
<?php
|
|
|
|
namespace Tests;
|
|
|
|
use Illuminate\Foundation\Application;
|
|
use Illuminate\Foundation\Testing\RefreshDatabaseState;
|
|
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
|
|
use Laravel\Fortify\Features;
|
|
|
|
abstract class TestCase extends BaseTestCase
|
|
{
|
|
public function createApplication(): Application
|
|
{
|
|
$app = parent::createApplication();
|
|
// migrate:fresh only clears the connection's public search path. This module owns a separate schema.
|
|
if (! RefreshDatabaseState::$migrated && $app->environment('testing')) {
|
|
$db = $app->make('db')->connection();
|
|
if ($db->getDriverName() === 'pgsql'
|
|
&& in_array($db->getDatabaseName(), ['portal_services_test', 'investmoz_test'], true)
|
|
&& (string) $db->getConfig('port') === '55441'
|
|
&& in_array($db->getConfig('host'), ['127.0.0.1', 'localhost'], true)) {
|
|
$db->statement('DROP SCHEMA IF EXISTS skills_edu CASCADE');
|
|
if ($db->selectOne("SELECT to_regclass('public.complementary_project_links') AS id")->id !== null) {
|
|
$db->statement('DROP TRIGGER IF EXISTS project_dependency_check ON public.complementary_project_links');
|
|
$db->statement('DROP TRIGGER IF EXISTS project_dependency_lock ON public.complementary_project_links');
|
|
}
|
|
$db->statement('DROP FUNCTION IF EXISTS public.check_project_dependency_graph() RESTRICT');
|
|
$db->statement('DROP FUNCTION IF EXISTS public.lock_project_dependency_graph() RESTRICT');
|
|
if ($db->selectOne("SELECT to_regclass('public.existing_business_locations') AS id")->id !== null) {
|
|
$db->statement('DROP TRIGGER IF EXISTS existing_business_locations_hierarchy_trigger ON public.existing_business_locations');
|
|
}
|
|
$db->statement('DROP FUNCTION IF EXISTS public.enforce_existing_business_location_hierarchy() RESTRICT');
|
|
}
|
|
}
|
|
|
|
return $app;
|
|
}
|
|
|
|
protected function setUp(): void
|
|
{
|
|
parent::setUp();
|
|
// HTTP feature tests must not depend on the developer's Vite SSR server.
|
|
config(['inertia.ssr.enabled' => false]);
|
|
}
|
|
|
|
protected function skipUnlessFortifyHas(string $feature, ?string $message = null): void
|
|
{
|
|
if (! Features::enabled($feature)) {
|
|
$this->markTestSkipped($message ?? "Fortify feature [{$feature}] is not enabled.");
|
|
}
|
|
}
|
|
}
|