[TESTS] Add some basic tests for ModelsCommand
#869
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Only add tests, no other functional change
Given that #865 was accepted and we've now the foundation for writing tests, I came up with some basic tests regarding the ModelsCommand.
The general idea is to show it's doable / easy (maybe not always 😄 ) and to inspire maybe others to contribute also to tests when they e.g. add/change features.
I added:
\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GenerateBasicPhpdoc\Test::test
\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\CustomDate\Test::test
The tests might look a bit unconventional regarding:
but
The main reason is that
ModelsCommand
behaves differently when scanning a directory with multiple models It would (of course) always process all of them, which makes testing / mocking more cumbersome. So I decided to split this and better isolate this from each other.Please note this is only a very small "get things going" test additional and by all means, we know there's much more to test (relations etc.).
Tests are skipped for Laravel < 6.0
I started out trying to get it work for Laravel 5.5 and 5.8 but ran into problems. After investing some time I decided not to invest more and skipped it.
Problems I had with 5.5
Tests didn't work, threw this error:
I googled and came to orchestral/testbench#153 and https://github.com/orchestral/testbench/tree/3.5#running-testing-migrations but still couldn't make it work, thus skipped it.
I actually got this working for https://github.com/rebing/graphql-laravel but checked the sources and it looked the same => all traces of this attempt are however already removed.
Problems I had with 5.8
The generated types are different 🤪:
I didn't wanted to invest too much here