in resources/views/companies/guides/edit.blade.php:line 12 the action route for the form must be companies.guides.update instead of companies.users.update.
The same for the other. Plus and an additional point: It should be tested, if the actual data of the user/guide is removed, that was created with the factory. With assertDatabaseMissing() the test would would always pass, because the given data was never in the database. And because auf the introduction of soft deletes a few chapters back, it should also be replaced by assertSoftDeleted() .
This is a weird one at least for me 7 passed and 1 failed that one was the first one. Any suggestions?
PS the /n goes on for quite a wile like 20 to 30 lines.
could the problem be the fact that I don't have a second user? but would't that be supplied by the UserFactory or the CompanyFactory ?
In CompanyGuideController index method
should query the guide role id like this:
$guides = $company->users()->where('role_id', RoleEnum::GUIDE->value)->get();
Either its me, or shouldnt the last two tests be written like this?
public function test_company_owner_can_delete_guides_from_their_company() { $company = Company::factory()->create();
In resources/views/companies/guides/edit.blade.php
Undefined variable $user should be $guide
Updated lesson. Thanks.
in
resources/views/companies/guides/edit.blade.php:line 12 the action route for the form must becompanies.guides.updateinstead ofcompanies.users.update.Thank you, well noticed, fixed it!
In the tests of this section: Wouldn't it be more explicit to check, if the company owner can edit a guide and not himself?
Before:
After:
The same for the other. Plus and an additional point: It should be tested, if the actual data of the user/guide is removed, that was created with the factory. With
assertDatabaseMissing()the test would would always pass, because the given data was never in the database. And because auf the introduction of soft deletes a few chapters back, it should also be replaced byassertSoftDeleted().Before:
Hi, is there a different in using:
$response = $this->actingAs($user)->get(route('companies.guides.index', $company->id));
or
$response = $this->actingAs($user)->get(route('companies.guides.index', $company));
in both cases the test passes without errors, how laravel interprets them? thanks
It is how route model binding wourks and has nothing to do with tests itself. You can read more about it in the laravel
StoreGuideRequest is missing use statement for Illuminate\Validation\Rules. This should be explicit for the users that do not use LSP.