Laravel testing without specific midleware - laravel

I've write a middleware to build a menu, but when I run my tests It tooks about an hour (It's a huge menu)
I want to know if there's a way to disable this specific middleware for testing but not using:
use withoutMiddleware;
because this also disable the auth middeware and my tests depends on it.
Thank you.

Related

How to write an appropriate test for backpack admin crud functionality?

I've implemented a laravel project which involves backpack admin, now I want to know is there any appropriate way to test its CRUD functionality (like the store, delete, etc actions)?
It doesn't matter what kind of test is needed (functional or unit test), I just want to test its functionality.
The easiest way I found was to create browser tests using Laravel Dusk - https://laravel.com/docs/8.x/dusk

Run lumen/laravel without instantiating the whole app

I want to force my lumen project to run without instantiating the whole app.
For example when a route has been executed, like:
/test
when it is called, then it goes to somewhere that we defined it.
for instance: ExampleController#test
That's it.
I don't need any extra package or in fact I don't want the whole app created just for a simple request.
Is there any tool? or Is it possible?
It is possible to reduce boilerplate code from every Framework, but consider Lumen as a reduced Laravel.
First read Laravel's Request Lifecycle from docs: https://laravel.com/docs/7.x/lifecycle
Secondly, you should keep Facades, Eloquent and Services Providers commented and with this Lumen is lean as posible.

Laravel CRUD Application Dusk vs PHPUnit

I am currently working on a Laravel CRUD application and I was wondering why PHPUnit does not support crawling the browser (anymore, as I read). I already covered the basement of my project via PHPUnit, but I do also want to test links, a tags, button clicks etc. So I do already have a strong basement of unit tests.
Now I read about Dusk providing a crawler for DOM tests. Shall I use both together (is it even possible?) or should I migrate to Dusk? I'm not sure whether Dusk provides the same functionality as PHPUnit does and as stated, I do already have a strong phpunit testing base.
From now on I'm kinda stuck, because of 50:50 testcases, as I do also need to test whether the DOM does provide the correct information.
Appreciate any help or expert advice.
Thank you in advance!
Dusk is not a crawler but a browser driver, it can control a (headless) browser.
Specifically designed on top of PHPunit to do E2E (end to end) testing.
So convert to Dusk what is browser tests (html/javascript), but everything else keep as unit tests.
API tests for example you don't need dusk at all.

Is it possible to turn off JavaScript for some tests using Codeception?

We have client-side validation and server-side validation as a back up in this Laravel application, and we want to test both, but I can't figure out if that's possible. Is it possible to turn off JavaScript for a single run of the tests, then run them again with it on using Codeception?
Test with PhpBrowser or Laravel5 module.
They can't execute Javascript, so only server side validation is possible.
You will have to create a separate test suite (or use functional if you aren't using it yet) for these tests, because you can have only one of WebDriver, PhpBrowser and Laravel5 modules enabled at a time.

How do I enable/disable Laravel's route filters for Behat scenarios? [Laravel 5]

By default Laravel disables route filters in testing environment and I wasn't able to switch them back on. So I decided to run Behat in another envrionment ('testing-behat').
Now the filters are always enabled. Which is quite annoying as well... ;-)
I would like to enable or disable Laravel's route filters for some scenarios in Behat.
Right now I scattered Route::disableFilters() around pretty much everywhere in my FeatureContext (#beforeSuite, #beforeScenario, #Given).
But to no avail.
So any hint would be appreciated...

Resources