instance('env', 'production'); config(['app.debug' => false, 'app.url' => 'https://compras.example.test', 'session.secure' => true, 'session.driver' => 'database', 'cache.default' => 'database', 'fortify.features' => [Features::twoFactorAuthentication(['confirm' => true, 'confirmPassword' => true])], 'mfa.required_functions' => ['admin', 'finance']]); } test('a development installation is reported as not ready for production', function () { config(['app.debug' => true, 'app.url' => 'http://localhost', 'fortify.features' => []]); $this->artisan('sgc:production-check') ->expectsOutputToContain('FALHA APP_ENV=production') ->expectsOutputToContain('FALHA APP_DEBUG=false') ->expectsOutputToContain('FALHA APP_URL em https') ->expectsOutputToContain('FALHA MFA ligado') ->assertFailed(); }); test('a production configuration passes every check except a non PostgreSQL database', function () { productionConfig(); $postgres = DB::connection()->getDriverName() === 'pgsql'; $run = $this->artisan('sgc:production-check') ->expectsOutputToContain('OK APP_ENV=production') ->expectsOutputToContain('OK MFA ligado') ->expectsOutputToContain('OK Migrações aplicadas') ->expectsOutputToContain('OK Pacotes partilhados conferidos') ->expectsOutputToContain(($postgres ? 'OK ' : 'FALHA ').'Base de dados PostgreSQL'); $postgres ? $run->assertSuccessful() : $run->assertFailed(); }); test('https without secure session cookies fails', function () { productionConfig(); config(['session.secure' => false]); $this->artisan('sgc:production-check')->expectsOutputToContain('FALHA SESSION_SECURE_COOKIE=true')->assertFailed(); });