isAllowed($developer))->toBeFalse() ->and(app(DeploymentGuard::class)->denialReason($developer))->toContain('DEPLOYMENT_PACKAGE_ENABLED'); }); test('a nem fejlesztői stage-en akkor sem érhető el, ha a kapcsoló be van kapcsolva', function () { deploymentAllowEnvironment(); Config::set('app.stage', 'PROD'); $developer = deploymentDeveloper(); expect(app(DeploymentGuard::class)->isAllowed($developer))->toBeFalse() ->and(app(DeploymentGuard::class)->denialReason($developer))->toContain('fejlesztői környezetben'); }); test('a developer szerep nélküli felhasználó nem éri el', function () { deploymentAllowEnvironment(); Role::create(['name' => 'admin', 'display_name' => 'Admin']); $admin = User::factory()->create(); $admin->addRole(Role::where('name', 'admin')->first()); FeatureFlag::create([ 'name' => 'DeploymentPackage', 'label' => 'Deployment csomagoló', 'enabled' => true, 'stages' => null, 'roles' => null, ]); app(FeatureFlagRegistrar::class)->registerAll(); expect(app(DeploymentGuard::class)->isAllowed($admin))->toBeFalse(); }); test('a kikapcsolt feature flag elrejti a felületet a fejlesztő elől is', function () { deploymentAllowEnvironment(); $developer = deploymentDeveloper(flagEnabled: false); expect(app(DeploymentGuard::class)->isAllowed($developer))->toBeFalse() ->and(DeploymentPackage::canAccess())->toBeFalse(); }); test('minden feltétel teljesülése esetén engedélyezett', function () { deploymentAllowEnvironment(); $developer = deploymentDeveloper(); expect(app(DeploymentGuard::class)->isAllowed($developer))->toBeTrue() ->and(app(DeploymentGuard::class)->denialReason($developer))->toBeNull(); }); test('a jogosulatlan felhasználó 403-at kap az oldal betöltésekor', function () { deploymentAllowEnvironment(); $developer = deploymentDeveloper(flagEnabled: false); // Szándékosan valódi HTTP kérés: a Livewire::test() a HttpException-t válasszá // alakítja (RequestBroker: withoutExceptionHandling([HttpException::class])), így // ott nem a tényleges belépési pontot mérnénk. $this->actingAs($developer) ->get(DeploymentPackage::getUrl()) ->assertForbidden(); });