Closed nhunt290 closed 9 months ago
Hello there! Thanks for opening your first issue on this repo!
Just a heads-up: Here at Backpack we use Github Issues only for tracking bugs. Talk about new features is also acceptable. This helps a lot in keeping our focus on improving Backpack. If you issue is not a bug/feature, please help us out by closing the issue yourself and posting in the appropriate medium (see below). If you're not sure where it fits, it's ok, a community member will probably reply to help you with that.
Backpack communication channels:
backpack-for-laravel
tag;Please keep in mind Backpack offers no official / paid support. Whatever help you receive here, on Gitter, Slack or Stackoverflow is thanks to our awesome awesome community members, who give up some of their time to help their peers. If you want to join our community, just start pitching in. We take pride in being a welcoming bunch.
Thank you!
-- Justin Case The Backpack Robot
I will add that I already had a Route::crud('user', 'UserCrudController');
route in routes/backpack/custom.php and hadn't realised Laravel-Backpack/PermissionManager was using a route with the same name which overwrited mine.
As that's the case and the test I was running won't have been using my route, but PermissionManager's, I think this is more of a bug with PermissionManager rather than CRUD.
I am assuming backpack_pro()
here is returning true when testing https://github.com/Laravel-Backpack/PermissionManager/blob/main/src/app/Http/Controllers/UserCrudController.php#L56C13-L56C27
Testing against my version of the UserCrudController which is a standard one created using the backpack CLI, the test passes without the need to create the empty filter views.
Are you able to move this issue to Laravel-Backpack/PermissionManager or should I recreate it on there?
Hello there! Thanks for opening your first issue on this repo!
Just a heads-up: Here at Backpack we use Github Issues only for tracking bugs. Talk about new features is also acceptable. This helps a lot in keeping our focus on improving Backpack. If you issue is not a bug/feature, please help us out by closing the issue yourself and posting in the appropriate medium (see below). If you're not sure where it fits, it's ok, a community member will probably reply to help you with that.
Backpack communication mediums:
backpack-for-laravel
tag;Please keep in mind Backpack offers no official / paid support. Whatever help you receive here, on Gitter, Slack or Stackoverflow is thanks to our awesome awesome community members, who give up some of their time to help their peers. If you want to join our community, just start pitching in. We take pride in being a welcoming bunch.
Thank you!
-- Justin Case The Backpack Robot
Hello @nhunt290 thanks for the report and through explanation.
Indeed, I can confirm that backpack_pro()
returns true when running unit tests.
The main reason behind it, is that we can't add backpack/pro
as a dev-dependency, as that would prevent any free user of backpack/CRUD
from installing the open-source core dev dependencies without having a backpack/pro
license.
This is indeed a rather interesting use case, as the backpack/PermissionManager
is also a free package, and we wrap the paid stuff in a backpack_pro()
conditional so that free users can also use it, if they don't need the added features with pro.
I am not sure what's the best way to handle this, using the package works, testing the package without pro is broken, but I am not seeing easy way out.
Maybe an .env
variable instead of returning true when running unit tests ? Something like TESTING_PRO=true
that we can setup on our test environments when needed ?
I will bring this to my colleagues attention so that we can try to figure out a better solution.
I can't promise any deadlines, as I don't think this is high-priority. It's annoying indeed and prevents people from testing stuff while using the Permission Manager controllers.
Thanks again for the detailed report and reproduction steps, they were very helpful π
Hey @pxpm, thanks for the response.
It is indeed an interesting use case.
I wonder if maybe you could check inside the backpack_pro()
conditional if the app is running unit tests with a simple if(App::runningUnitTests()) {return true}
.
Perhaps with a combination of APP_ENV=local
and/or APP_DEBUG=true
in case someone can fake the response of App::runningUnitTests()
and get the paid features for free, as I can't imagine anyone deploying to production with such env values.. I hope.
But, I understand it's not a high priority and that's OK, I'll leave it with you and the team to decide the best workaround :)
Hey @nhunt290 that's what we are doing already: https://github.com/Laravel-Backpack/CRUD/blob/0e14e07c8449a20595b71ca70c3d6fdf628f3449/src/helpers.php#L395 and it's not the best solution as we just found out π
You dont' get the paid features for free, we just don't test those inside backpack/crud
package, but we need the backpack_pro()
call inside our codebase to return true when we are running the backpack/crud
tests. That's why maybe an .env
variable for the testing environments is better than our current solution π
Cheers
Closing this issue as there has been no activity. Please feel free to reopen if needed or if you have additional information to provide. Thanks!
Bug report
What I did
I have a UserCrudController with the method list method
I created a test to check my user.index route is accessible
What I expected to happen
I would expect the test to pass.
My test for the dashboard route passes just fine:
What happened
Test fails with the following exception:
Next Spatie\LaravelIgnition\Exceptions\ViewException: None of the views in the given array exist. in /Users/me/projects/b-f-l/vendor/laravel/framework/src/Illuminate/View/Factory.php:168
What I've already tried to fix it
The above exception comes from this method getting the first view that exists:
I added
dd($views)
above the $view declaration and ran the test again which returned:Is this related to previous issues like the following? https://github.com/Laravel-Backpack/PageManager/issues/123 https://github.com/Laravel-Backpack/CRUD/issues/4196
For me, the last time I used backpack was v4 and I enjoyed it, so decided to use it again this time around. But after reading the above articles and checking the docs, it seems filters are now a PRO feature, which makes me think it's related the above issues in that the error message is not at all clear.
Just to try it, I created an empty
vendor/backpack/crud/filters/dropdown.blade.php
file. Ran the test again, and this time I dumped out:So, I did the same as above, created a blank select2.blade.php file, ran the test again, and this time it passed.
I don't really need filters, yet. I may do further down the line but not now, so I don't want to simply just upgrade for the sake of it. Would there be a reason my tests seem to be trying to implement the filters? When I visit the user list page in the browser, I get no errors or any indication of it trying to load filters, so not sure why my test would be.
If this is a bug within Backpack, is there any way I can disable filters so they don't attempt to show? I don't really want to have to commit a couple of blank files if I don't have to.
Is it a bug in the latest version of Backpack?
After I run
composer update backpack/crud
the bug... is it still there? YesBackpack, Laravel, PHP, DB version
When I run
php artisan backpack:version
the output is: