mirror of
https://github.com/barryvdh/laravel-ide-helper.git
synced 2026-08-18 18:13:11 +00:00
Feature: Add Config Option to Enforce Nullable Relationships (#1580)
* feat: add config option for nullable relationships Introduce enforce_nullable_relationships configuration to control nullable Eloquent relationships. * refactor: update logic for nullable relationships Update isRelationNullable method to respect new config option. * test: add tests for nullable relationship config - Verify behavior of enforce_nullable_relationships configuration option. - Create snapshot to reflect enforce_nullable_relationships set to false. * docs: improve documented context and usage * docs: update CHANGELOG with enforce_nullable_relationships option
This commit is contained in:
@@ -46,4 +46,23 @@ class Test extends AbstractModelsCommand
|
||||
$this->assertStringContainsString('Written new phpDocBlock to', $tester->getDisplay());
|
||||
$this->assertMatchesMockedSnapshot();
|
||||
}
|
||||
|
||||
public function testRelationNotNullable(): void
|
||||
{
|
||||
// Disable enforcing nullable relationships
|
||||
Config::set('ide-helper.enforce_nullable_relationships', false);
|
||||
|
||||
$command = $this->app->make(ModelsCommand::class);
|
||||
|
||||
$tester = $this->runCommand($command, [
|
||||
'--write' => true,
|
||||
]);
|
||||
|
||||
$this->assertSame(0, $tester->getStatusCode());
|
||||
$this->assertStringContainsString('Written new phpDocBlock to', $tester->getDisplay());
|
||||
$this->assertMatchesMockedSnapshot();
|
||||
|
||||
// Re-enable default enforcing nullable relationships
|
||||
Config::set('ide-helper.enforce_nullable_relationships', true);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user