-
Notifications
You must be signed in to change notification settings - Fork 3
refactor: set resource name in dump/fixtures #214
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?
refactor: set resource name in dump/fixtures #214
Conversation
…rator-instead-of-Model
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 refactors the test generator code to use resource names (e.g., NovaWelcomeBonusResource) instead of model names (e.g., WelcomeBonus) when naming fixture directories and files. The change ensures consistency between test class names and their associated fixture paths.
Key Changes
- Introduced an
$entityproperty to track the resource/model name used for fixture generation - Updated fixture paths to use resource names (e.g.,
NovaWelcomeBonusResourceTestdirectory instead ofNovaWelcomeBonusTest) - Modified fixture file naming to include the full resource name (e.g.,
nova_welcome_bonus_resource_dump.sqlinstead ofnova_welcome_bonus_dump.sql)
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| tests/NovaTestGeneratorTest.php | Updated test assertions to expect fixture paths and filenames with resource names |
| tests/CommandTest.php | Updated test assertions to reflect new fixture directory and filename patterns |
| src/Generators/TestsGenerator.php | Added generate() method to set $entity property from model name |
| src/Generators/NovaTestGenerator.php | Modified to use $entity property for resource name throughout fixture generation |
| src/Generators/AbstractTestsGenerator.php | Removed local $entity variable and updated to use class property for fixture naming |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or 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 5 out of 5 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
tests/NovaTestGeneratorTest.php
Outdated
| ->setModel('WelcomeBonus') | ||
| ->generate(); | ||
|
|
||
| $this->assertFileDoesNotExist('tests/NovaWelcomeBonusTest.php'); |
Copilot
AI
Nov 4, 2025
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.
The assertion checks for the old test class name NovaWelcomeBonusTest which is inconsistent with the new naming convention. Since the Nova resource is WelcomeBonusResource, the expected test class name should be NovaWelcomeBonusResourceTest. Consider updating this assertion to verify the correct behavior by checking that tests/NovaWelcomeBonusResourceTest.php does not exist when the stub is missing.
| $this->assertFileDoesNotExist('tests/NovaWelcomeBonusTest.php'); | |
| $this->assertFileDoesNotExist('tests/NovaWelcomeBonusResourceTest.php'); |
src/Generators/NovaTestGenerator.php
Outdated
|
|
||
| $this->novaResourceClassName = Arr::first($novaResources); | ||
|
|
||
| $this->checkResourceExists('nova', $this->getTestClassName(), $this->modelSubFolder); |
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.
are you sure that the modelSubFolder is required here?
src/Generators/NovaTestGenerator.php
Outdated
| 'models_namespace' => $this->generateNamespace('models', $this->modelSubFolder), | ||
| 'user_model_path' => $this->generateNamespace('models') . '\User', |
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.
why are you adding a separate user_model_path and use it instead of models_namespace and didn't remove the models_namespace as it not using anymore?
please revert it as it good solution for now to pass the base models namespace and add the User
#140