Skip to main content

After the First Client Review

Premium
16 min read
Alexey avatar

Hello. Some questions / corrections:

  1. app/Http/Controllers/CompanyUser (Guide) Controller.php: RegistrationInvite but not UserRegistrationInvite.
  2. app/Http/Controllers/Auth/RegisteredUserController.php: but not app/Http/Controllers/RegisteredUserController.php:
  3. Actually do we need edit scenario for users (guides)? For what we may edit an email in this way? If not we need to change / remove "update requests files" and it's methods in controllers.
marcelo-kazalukian avatar

Hello. I think in the function test_company_owner_can_send_invite_to_user the line $user = User::factory()->admin()->create(); should be $user = User::factory()->companyOwner()->create(); is this correct? Thanks.

marcelo-kazalukian avatar

same in the function test_company_owner_can_send_invite_to_guide_to_his_company

Nerijus avatar

Thanks. Updated the lesson.

marcelo-kazalukian avatar

Hello. I think in the function test_company_owner_can_send_invite_to_user the line

$user = User::factory()->companyOwner()->create(); should be $user = User::factory()->companyOwner()->create(['company_id' => $company->id]);

if not, then in this line, the user doesn't have the same company $response->assertRedirect(route('companies.users.index', $company->id));

Nerijus avatar

In this case it doesn't matter because we test different thing. But for consistency yes it would be better. Updated the lesson.

jwinder avatar

Yeah i noticed same thing i had to switch it like this for company owner

$response = $this->actingAs($companyOwner)->post(route('companies.users.store', $company->id), [
'email' => 'test@test.com'
]);
 
$response->assertRedirect(route('companies.users.index', $company->id));
 
// checks if mailable of type UserRegistrationInvite was sent from above line of code
Mail::assertSent(UserRegistrationInvite::class);
Hugo Viergever avatar

"And the invitation email is now sent..." But I'm affraid I get an error here: Connection could not be established with host "mailpit:1025": stream_socket_client(): php_network_getaddresses: getaddrinfo for mailpit failed: Host is onbekend. / Is it necessary to register with mailgun.org? Can this be the reason for the failure? Thank you for the reply!

Povilas Korop avatar

You need to use some email provider to send email, yes. It could be Mailgun or similar for real emails, or Mailpit/Mailtrap for fake emails. And yes, that's the reason for the failure.