feat(tickets): add TicketFormController, TicketFormService, and TicketFormResource with related routes and tests

This commit is contained in:
2026-08-28 17:00:47 -03:00
parent dca35e7b0c
commit af516ce9e3
8 changed files with 449 additions and 8 deletions

View File

@@ -8,17 +8,22 @@ use RuntimeException;
abstract class TestCase extends BaseTestCase
{
/**
* Boot the application only when the test database is explicitly isolated.
*/
public function createApplication(): Application
{
$app = parent::createApplication();
$connection = (string) $app['config']->get('database.default');
$database = (string) $app['config']->get("database.connections.{$connection}.database");
$usesInMemorySqlite = $connection === 'sqlite' && $database === ':memory:';
if (! $usesInMemorySqlite && ! str_ends_with(strtolower($database), '_test')) {
throw new RuntimeException(
"Unsafe test database [{$database}]. Tests may only use an in-memory SQLite database or a database ending in _test.",
);
$database = (string) $app['config']->get(
'database.connections.'.$app['config']->get('database.default').'.database'
);
if (! preg_match('/^shopit_(?:test|testing)(?:_\d+)?$/', $database)) {
throw new RuntimeException(sprintf(
'Refusing to run tests against database [%s]. Use [shopit_test] or [shopit_testing].',
$database !== '' ? $database : '(empty)'
));
}
return $app;