valet icon indicating copy to clipboard operation
valet copied to clipboard

Test Valet commands

Open driesvints opened this issue 2 years ago • 4 comments

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 avatar May 24 '22 14:05 driesvints

@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 avatar May 31 '22 13:05 mattstauffer

@mattstauffer nice. I've just merged master into my PR so it's up to date again.

driesvints avatar May 31 '22 13:05 driesvints

@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).

mattstauffer avatar Jun 03 '22 19:06 mattstauffer

Nice work!

driesvints avatar Jun 07 '22 06:06 driesvints

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

mattstauffer avatar Dec 02 '22 04:12 mattstauffer

@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.

mattstauffer avatar Dec 02 '22 04:12 mattstauffer

Looks good to me! Nice job @mattstauffer 👍

driesvints avatar Dec 02 '22 08:12 driesvints

Thanks @driesvints!

mattstauffer avatar Dec 02 '22 18:12 mattstauffer