valet
valet copied to clipboard
Test Valet commands
This is a first attempt at https://github.com/laravel/valet/issues/1233. I've split up the app init for Valet into a separate cli/app.php
file which can be re-used in the test suite. This will run the actual commands using the ApplicationTester
class by Symfony.
Unfortunately I couldn't get the first commands I'm trying to test to work and would appreciate any help with this.
@driesvints Just pushed up my branch and compared and I much prefer how you're working here, so as long as we're able to get yours working in CI I'd rather go with your solution. I'll try to make some time for it this week!
@mattstauffer nice. I've just merged master into my PR so it's up to date again.
@driesvints OK, I got it fixed so it's working in CI. Basically, it changes VALET_HOME_PATH
to be a local folder, preps that folder, and then that triggers the commands being registered in app.php
(they weren't before because VALET_HOME_PATH
didn't exist).
Nice work!
OK, I think this is working.
The main output of ALL of this code and ALL of these commits are:
Before this, we could only test our individual classes, but not the commands themselves.
Now, we can actually test commands.
For example:
https://github.com/laravel/valet/pull/1256/files#diff-38057577cc680f5c7b83f3688b196a18ed53d744d984789303e8503373acd629
@driesvints Please feel free to take a look before I merge. I kinda... took this one and ran with it 😆
My only disappointment is the need to add the writer()
line at the top of each command. Couldn't figure out how to get away without that, but I'm gonna see if I can let my brain rest on it for a day or two to see if I come up with anything.
That said, this is good to merge if you like it, Dries.
Looks good to me! Nice job @mattstauffer 👍
Thanks @driesvints!