I want to test my CLI package for Laravel in isolation meaning without setting up a Laravel app then putting it inside the packages
directory and loading it via composer.
I've been struggling to figure out a way to write tests for my Laravel CLI package since last week. I tried using testbench
but I failed to configure it to make it work. I've been reading tests and composer.json
files for may popular packages and tried following them but with no luck.
Looking forward for some help. I really appreciate it.
Thanks in advance.
Top comments (4)
Hey, in laravel docs there is a page for how you can write tests for your cli commands laravel.com/docs/5.8/console-tests hope that help you.
or clarify the problem more :)
It certainly will work when you are code is inside the Laravel app. But I'm working on a Laravel CLI package. most of the big names like Spatie, Tighten etc use testbench and I couldn't make it work.
What testbench does is that it installs Laravel and makes it available to the package under development. And I couldn't find any help how to configure the Laravel that comes with testbench.
Most of the tutorials I found only talk about basic stuff and don't dig deeper.
In that case what I would advice is to have laravel app that requires your package from local path and you try your package from it. or if you don't mind share the package and I will try to install the testbench for u
I have that setup but that's not a practical aaproach I want my packages to be standalone while in development so that I can run tests without being installed inside an app