Answer the question
In order to leave comments, you need to log in
How in laravel when testing registration to block sending notifications for mail and sms?
Good afternoon!
Testing registration.
public function testSuccess(): void
{
$this->withoutMiddleware();
$user = factory(User::class, 'customer')->make(['phone' => '+7 (999) 000-0002']);
$response = $this->post(route('register'), [
'name' => $user->name,
'email' => $user->email,
'password' => 'secret1234',
'password_confirmation' => 'secret1234',
'department_id' => $voronezh = 40,
'phone' => $user->phone
]);
$newUser = User::where('email', $user->email);
self::assertEquals($newUser->email, $user->email);
$response
->assertStatus(302)
->assertRedirect(route('verify.phone'))
->assertSessionHas('success', __('messages', 'you_need_to_confirm_your_account_please_check_your_email_or_phone'));
}
class SmsServiceProvider extends ServiceProvider
{
public function register()
{
$this->app->singleton(SmsSender::class, function (Application $app) {
$config = $app->make('config')->get('sms');
switch ($config['driver']) {
case 'smsc.ru':
$params = $config['drivers']['smsc.ru'];
return new SmscRu($params['login'], $params['password'], $params['url']);
break;
case 'array':
return new SmsMock();
break;
default:
throw new \InvalidArgumentException('Undefined SMS driver ' . $config['driver']);
}
});
}
}
$this->mailer->to($user->email)->queue(new VerifyMail($user));
<env name="MAIL_DRIVER" value="array" force="true"/>
<env name="SMS_DRIVER" value="array" force="true"/>
Answer the question
In order to leave comments, you need to log in
For example, put a condition
if(config('app.env') === 'production'){
//
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question