-
Notifications
You must be signed in to change notification settings - Fork 3
fix: seeder generation logic #223
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds conditional creation of DatabaseSeeder.php and updates test fixtures to handle both scenarios: when the DatabaseSeeder file already exists and when it needs to be created from scratch.
- Added a file existence check before creating DatabaseSeeder
- Created new test case for when DatabaseSeeder already exists
- Replaced outdated documentation reference to removed config path
Reviewed Changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/Generators/SeederGenerator.php | Added conditional check to only create DatabaseSeeder if it doesn't exist |
| tests/SeederGeneratorTest.php | Switched from RepositoryMockTrait to SeederGeneratorMockTrait and added test for existing DatabaseSeeder scenario |
| tests/Support/Seeder/SeederGeneratorMockTrait.php | New trait to mock filesystem with existing DatabaseSeeder for testing |
| tests/fixtures/SeederGeneratorTest/database_seeder_created.php | Fixture representing newly created DatabaseSeeder with PostSeeder |
| tests/fixtures/SeederGeneratorTest/database_seeder_existing.php | Fixture representing existing DatabaseSeeder with AuthorSeeder |
| tests/fixtures/SeederGeneratorTest/database_seeder_modified.php | Fixture representing existing DatabaseSeeder modified to include both AuthorSeeder and PostSeeder |
| ReadMe.md | Removed outdated 'seeds' path config reference |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 6 out of 7 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 6 out of 7 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| $structure = [ | ||
| 'database' => [ | ||
| 'seeders' => [], | ||
| ], | ||
| ]; | ||
|
|
||
| $root = vfsStream::setup('root', null, $structure); | ||
|
|
||
| $databaseSeederContent = file_get_contents(getcwd() . '/tests/fixtures/SeederGeneratorTest/existed_database_seeder.php'); | ||
|
|
||
| vfsStream::newFile('database/seeders/DatabaseSeeder.php') | ||
| ->at($root) | ||
| ->setContent($databaseSeederContent); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could we use an already implemented way?
$fileSystemMock = new FileSystemMock();
$fileSystemMock->seeders = [
'DatabaseSeeder.php' => file_get_contents(getcwd() . '/tests/fixtures/SeederGeneratorTest/existed_database_seeder.php'),
];
$fileSystemMock->setStructure();
Refs: #221