Please make changes to the CompanyFactory.php page your 'name' => fake()->words(3), Will not work you changed it in the GitHub version of the class to: 'name' => fake()->words(3, asText: true),
This did work and the test did pass.
Notice: I specifically didn't add isAdmin middleware for this route because later it can be reused for users with the company owner role. We will only need to restrict access so that users couldn't see other companies. My plan for this is to use Policies.
It seems that we have a route name's typo within the test_admin_can_delete_user_for_a_company(). Should it be ...->delete(route('companies.users.destroy',...); instead of 'update'?
And one more question. Is that "updated user" from the previous test retained, or is the database cleared before each test is run and our check is meaningless here? In this case, do we need to write something like this?
public function test_admin_can_delete_user_for_a_company(): void
In case someone is wondering: The last test of this lesson is failing, because the soft deletes in the user model aren't implemented yet. They follow in the next lesson. Until then you could use this as the last assertion:
Guys, the last test will fail intil you add SoftDeletes to User model. In the next lesson it'll be added. So, it's OK if you see your test fail. You can comment that test for now.
I think the index screen should list all users of the company. So I don't understand why on the index screen we only show users with the role of Company Owner. Can you explain it to me, please?
Please make changes to the CompanyFactory.php page your 'name' => fake()->words(3), Will not work you changed it in the GitHub version of the class to: 'name' => fake()->words(3, asText: true), This did work and the test did pass.
Changed. Thanks.
here why testing for admin if can do the CRUD and we did not put restriction no in Route and no in middleware ?
Dont skip text.
It seems that we have a route name's typo within the test_admin_can_delete_user_for_a_company(). Should it be ...->delete(route('companies.users.destroy',...); instead of 'update'?
And one more question. Is that "updated user" from the previous test retained, or is the database cleared before each test is run and our check is meaningless here? In this case, do we need to write something like this?
thanks
In case someone is wondering: The last test of this lesson is failing, because the soft deletes in the user model aren't implemented yet. They follow in the next lesson. Until then you could use this as the last assertion:
thanks a lot
Shouldn't the article reflect this in any way... I was wreaking my had for the last couple of hours ... time well spent
Will be fixed as well as updated to the laravel 11 in the next week.
Guys, the last test will fail intil you add
SoftDeletesto User model. In the next lesson it'll be added. So, it's OK if you see your test fail. You can comment that test for now."It doesn't make sense to show a screenshot with tests that have passed but are not successful in this step."
agreed ... I'm wasting time trying to figure it out, when the solution is to actually ignore it
I think the index screen should list all users of the company. So I don't understand why on the index screen we only show users with the role of Company Owner. Can you explain it to me, please?
**I advise you to edit factory of Company to be like this : ** 'name' => $this->faker->words(2, true);
to avoid the error while testing :
[Illuminate\Database\Grammar::parameterize(): Argument #1 ($values) must be of type array, string given]