-
Notifications
You must be signed in to change notification settings - Fork 3
Cover generators with tests #65
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
|
@KonstantinLapkovsky please check all other mock traits according my comments |
# Conflicts: # phpunit.xml # tests/Support/NovaTestMockTrait.php
tests/NovaResourceGeneratorTest.php
Outdated
| $this->expectException(ClassNotExistsException::class); | ||
| $this->expectExceptionMessage('Cannot create Post Nova resource cause Post Model does not exists. ' | ||
| . "Create a Post Model by himself or run command 'php artisan make:entity Post --only-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.
let's wrap it to the helper
| $this->expectException(ClassNotExistsException::class); | |
| $this->expectExceptionMessage('Cannot create Post Nova resource cause Post Model does not exists. ' | |
| . "Create a Post Model by himself or run command 'php artisan make:entity Post --only-model'"); | |
| $this->assertExceptionThrowed(ClassNotExistsException::class, "Cannot create Post Nova resource cause Post Model does not exists. Create a Post Model by himself or run command 'php artisan make:entity Post --only-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.
could we use already implemented assertExceptionThrowed helper instead?
tests/Support/NovaTestGeneratorTest/NovaTestGeneratorMockTrait.php
Outdated
Show resolved
Hide resolved
tests/NovaResourceGeneratorTest.php
Outdated
| $this->expectException(ClassNotExistsException::class); | ||
| $this->expectExceptionMessage('Cannot create Post Nova resource cause Post Model does not exists. ' | ||
| . "Create a Post Model by himself or run command 'php artisan make:entity Post --only-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.
could we use already implemented assertExceptionThrowed helper instead?
tests/NovaTestGeneratorTest.php
Outdated
| use NovaTestMockTrait; | ||
| use NovaTestGeneratorMockTrait; | ||
|
|
||
| public function testCreateNovaTestsResourceNotExists() |
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.
| public function testCreateNovaTestsResourceNotExists() | |
| public function testGenerateResourceNotExists() |
tests/NovaTestGeneratorTest.php
Outdated
| ->generate(); | ||
| } | ||
|
|
||
| public function testCreateNovaTestAlreadyExists() |
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.
| public function testCreateNovaTestAlreadyExists() | |
| public function testGenerateNovaTestAlreadyExists() |
tests/NovaTestGeneratorTest.php
Outdated
| $this->assertGeneratedFileEquals('update_welcome_bonus_request.json', 'tests/fixtures/NovaWelcomeBonusTest/update_welcome_bonus_request.json'); | ||
| } | ||
|
|
||
| public function testCreateWithMissingNovaPackage() |
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.
| public function testCreateWithMissingNovaPackage() | |
| public function testGenerateNovaPackageNotInstall() |
tests/Support/GeneratorMockTrait.php
Outdated
|
|
||
| public function mockCheckingNovaPackageExistence(string $className, bool $result = false): void | ||
| { | ||
| $this->mockClassExistsFunction($className, $result); | ||
| } |
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 anymore
| public function mockCheckingNovaPackageExistence(string $className, bool $result = false): void | |
| { | |
| $this->mockClassExistsFunction($className, $result); | |
| } |
| } | ||
|
|
||
| protected function getFieldsForCreation(): array | ||
| public function getFieldsForCreation(): array |
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.
should we change visibility for this function?
tests/NovaResourceGeneratorTest.php
Outdated
| use Doctrine\DBAL\Types\IntegerType; | ||
| use Doctrine\DBAL\Types\StringType; | ||
| use Illuminate\Support\Facades\Event; | ||
| use ReflectionClass; |
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.
| use ReflectionClass; |
Issue #49