-
Notifications
You must be signed in to change notification settings - Fork 3
Add model generator tests #70
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
Conversation
# Conflicts: # tests/ControllerGeneratorTest.php # tests/NovaResourceGeneratorTest.php # tests/NovaTestGeneratorTest.php # tests/Support/Controller/ControllerMockTrait.php # tests/Support/NovaResource/NovaResourceMockTrait.php # tests/Support/NovaTest/NovaTestMockTrait.php # tests/Support/Shared/GeneratorMockTrait.php # tests/TestCase.php
…erator-tests # Conflicts: # tests/Support/Factory/FactoryMockTrait.php
DenTray
left a comment
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 change target branch and merge it with the current master
src/Generators/ModelGenerator.php
Outdated
| foreach ($relationsByType as $relation) { | ||
| if (!$this->classExists('models', $relation)) { | ||
| $this->throwFailureException( | ||
| ClassNotExistsException::class, |
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 add arg names for multiline style
| ]); | ||
| } | ||
|
|
||
| public function mockGeneratorForMissingRelationModel(): void |
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.
seems this method is not using
| { | ||
| return $this->hasMany(User::class); | ||
| } | ||
| protected $casts = [ |
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 change casts place after the hidden property
| { | ||
| public function some_relation() | ||
| { | ||
|
|
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.
refs: #49
…to 49-add-model-generator-tests
| @@ -0,0 +1,10 @@ | |||
| <?php | |||
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 this model https://github.com/RonasIT/laravel-entity-generator/blob/master/tests/Support/Models/WelcomeBonus.php and just add relation to there instead?
tests/ModelGeneratorTest.php
Outdated
|
|
||
| class ModelGeneratorTest extends TestCase | ||
| { | ||
| use ModelMockTrait, MockTrait; |
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 just use MockTrait into Generator MockTrait?
refs: #49
src/Generators/ModelGenerator.php
Outdated
| } | ||
|
|
||
| if ($this->isStubExists('model') && ($this->isStubExists('relation') || empty($this->relations))) { | ||
| if ($this->isStubExists('model') && (collect($this->relations)->every(fn ($relation) => empty($relation)) || $this->isStubExists('relation', '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.
| if ($this->isStubExists('model') && (collect($this->relations)->every(fn ($relation) => empty($relation)) || $this->isStubExists('relation', 'model'))) { | |
| if ($this->isStubExists('model') && (!$this->hasRelations() || $this->isStubExists('relation', 'model'))) { |
refs: #49
Issue #49