-
Notifications
You must be signed in to change notification settings - Fork 3
159 ability to set nova resource for nova tests generator #165
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
159 ability to set nova resource for nova tests generator #165
Conversation
…rator-instead-of-Model
…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 pull request adds the ability to set custom Nova resource names for the Nova tests generator, addressing issue #140. The changes enable users to specify a custom resource name when generating Nova tests, particularly useful when Nova resources are organized in subdirectories or have non-standard naming conventions.
Key changes:
- Modified Nova test generation to accept and use custom resource names via
--resource-nameoption - Updated test templates and naming conventions to use the resource name instead of the model name
- Added proper validation and error handling for multiple matching resources
Reviewed Changes
Copilot reviewed 18 out of 18 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
src/Generators/NovaTestGenerator.php |
Core logic to handle custom resource names and resource discovery |
src/Commands/MakeEntityCommand.php |
Added --resource-name command line option |
stubs/nova_test.blade.php |
Updated template to use resource names in generated tests |
| Multiple test fixtures | Updated fixture files to reflect new naming conventions with resource names |
ReadMe.md |
Documentation for the new --resource-name option |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
|
|
||
| public static function label(): string | ||
| { | ||
| return 'WelcomeBonus'; |
Copilot
AI
Aug 28, 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 label() method returns 'WelcomeBonus' but this is a PostResource. This should return 'Post' to match the actual resource.
| return 'WelcomeBonus'; | |
| return 'Post'; |
| return [ | ||
| new PublishPostAction, | ||
| new UnPublishPostAction, | ||
| new UnPublishPostAction, |
Copilot
AI
Aug 28, 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.
There's a duplicate UnPublishPostAction in the actions array. This creates redundancy and should be removed.
| new UnPublishPostAction, |
| return [ | ||
| new PublishPostAction, | ||
| new UnPublishPostAction, | ||
| new UnPublishPostAction, |
Copilot
AI
Aug 28, 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.
There's a duplicate UnPublishPostAction in the actions array. This creates redundancy and should be removed.
| new UnPublishPostAction, |
| { | ||
| use NovaTestTrait; | ||
|
|
||
| protected static User $user; |
Copilot
AI
Aug 28, 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 User class is not imported. Add 'use App\Models\User;' or the appropriate User class import at the top of the file.
| { | ||
| return [ | ||
| [ | ||
| 'action' => PublishPostAction::class, |
Copilot
AI
Aug 28, 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.
PublishPostAction class is not imported. Add the appropriate import statement at the top of the file.
| 'state' => 'run_publish_post_action_state', | ||
| ], | ||
| [ | ||
| 'action' => UnPublishPostAction::class, |
Copilot
AI
Aug 28, 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.
UnPublishPostAction class is not imported. Add the appropriate import statement at the top of the file.
| protected function loadNovaFields() | ||
| { | ||
| return app("\\App\\Nova\\{$this->novaModelName}")->fields(new NovaRequest()); | ||
| return app("{$this->fullNovaResourcePath}")->fields(new NovaRequest()); |
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.
| return app("{$this->fullNovaResourcePath}")->fields(new NovaRequest()); | |
| return app($this->fullNovaResourcePath)->fields(new NovaRequest()); |
| protected function loadNovaFilters() | ||
| { | ||
| return app("\\App\\Nova\\{$this->novaModelName}")->filters(new NovaRequest()); | ||
| return app("{$this->fullNovaResourcePath}")->filters(new NovaRequest()); |
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.
| return app("{$this->fullNovaResourcePath}")->filters(new NovaRequest()); | |
| return app($this->fullNovaResourcePath)->filters(new NovaRequest()); |
| } | ||
|
|
||
| if ($this->classExists('nova', "Nova{$this->model}Test")) { | ||
| $this->isNovaResourceExists(); |
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.
I saw this in another request https://github.com/RonasIT/laravel-entity-generator/pull/163/files#L44
Let's take solution from Pull Request #163
| {--only-nova-resource : Set this flag if you want to create only nova resource.} | ||
| {--only-nova-tests : Set this flag if you want to create only nova resource tests.} | ||
| {--resource-name= : Override the default Nova resource name. Used only with --only-nova-tests.} |
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.
pleae this feature implement by in next task, not this #159
#140