-
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.
| $excepts = ($modification === 'request') ? ['id'] : []; | ||
|
|
||
| $this->generateFixture("{$type}_{$entity}_{$modification}.json", Arr::except($object, $excepts)); | ||
| $this->generateFixture("{$type}_" . Str::snake($this->getTestingEntityName()) . "_{$modification}.json", Arr::except($object, $excepts)); |
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.
please revert
src/Generators/NovaTestGenerator.php
Outdated
| $entityName = $this->getTestingEntityName(); | ||
|
|
||
| if ($this->classExists('nova', "Nova{$entityName}Test")) { | ||
| $path = $this->getClassPath('nova', "Nova{$entityName}Test"); | ||
|
|
||
| throw new ResourceAlreadyExistsException($path); | ||
| } |
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.
any reasons to make it after searching the nova resource in the filesystem???
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 logic of the abstract method getTestingEntityName depends on the filesystem scan
src/Generators/NovaTestGenerator.php
Outdated
|
|
||
| $entityName = $this->getTestingEntityName(); | ||
|
|
||
| if ($this->classExists('nova', "Nova{$entityName}Test")) { |
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.
| if ($this->classExists('nova', "Nova{$entityName}Test")) { | |
| if ($this->classExists('nova', $this->getTestClassName())) { |
src/Generators/NovaTestGenerator.php
Outdated
| $entityName = $this->getTestingEntityName(); | ||
|
|
||
| if ($this->classExists('nova', "Nova{$entityName}Test")) { | ||
| $path = $this->getClassPath('nova', "Nova{$entityName}Test"); |
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.
| $path = $this->getClassPath('nova', "Nova{$entityName}Test"); | |
| $path = $this->getClassPath('nova', $this->getTestClassName()); |
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); | ||
|
|
||
| $entityName = $this->getTestingEntityName(); | ||
|
|
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.
There's trailing whitespace on line 48. Remove the extra whitespace at the end of this line for consistency with project formatting standards.
#140