Grate class having a lot of fun learning new things at least for me.
However on this part of the test I am not getting all green I have one error that I am having a bit of trouble figuring out
RouteIs checks if the current URL is the one user is on right now. The * means everything, so every route name that starts with companies. users. will be a true value and navigation item will be set as active. What you are saying is a route model binding
companies.users.index will only match that route. But what if you go inside the create/edit pages? Then the route is not going to be marked as active. This means that the navigation will be in an incorrect state.
Now adding the * to the url as companies.users.* will make it match ANYTHING that is inside there. For example:
companies.users.indexcompanies.users.createcompanies.users.edit
All of the above will match and correctly mark the active navigation due to the * wildcard
Grate class having a lot of fun learning new things at least for me. However on this part of the test I am not getting all green I have one error that I am having a bit of trouble figuring out
Can’t find the edit in the policies\Company User Policy page
I started over from scratch and BOY AM I GLADE! All test passed even the one on this page.
Small things, in these methods:
( route name should be destroy not update )
$response = $this->actingAs($user)->delete(route('companies.users.destroy', [$company2->id, $user->id]));
Updated tutorial. Thanks
Hi, it seems that in an update of the course the update route name is being used again in de delete tests.
Shouldn't we use $this->assertSoftDeleted within test_company_owner_can_delete_user_for_his_company?
Yes it would be logical.
question, why did you use the ff code in the navigation section:
request()->routeIs('companies.users.*')instead of:
request()->routeIs('companies.users.index', auth()->user()->company_id)is it to make the code shorter?
RouteIs checks if the current URL is the one user is on right now. The * means everything, so every route name that starts with
companies. users.will be a true value and navigation item will be set as active. What you are saying is a route model bindingTo just make it more obvious:
companies.users.indexwill only match that route. But what if you go inside the create/edit pages? Then the route is not going to be marked as active. This means that the navigation will be in an incorrect state.Now adding the
*to the url ascompanies.users.*will make it match ANYTHING that is inside there. For example:companies.users.indexcompanies.users.createcompanies.users.editAll of the above will match and correctly mark the active navigation due to the
*wildcardthanks guys!
i got an error after runing the test.
An error occurred inside PHPUnit.
Message: syntax error, unexpected token "use" Location: C:\laragon\www\reservation\tests\Feature\CompanyTest.php:17
Its like your test file has syntax errors
Soo many new things to learn ... daaimn :D. Yet it's still is fun