Skip to content

testing

alizeinodin edited this page Sep 11, 2026 · 2 revisions

Testing

use Alizeinodin\SmsApi\Facades\Sms;

Sms::fake();

Sms::send('09121234567', 'Hello');
Sms::template('otp-login')->to('09121234567')->send(['CODE' => '1']);

Sms::assertSent();
Sms::assertSentTo('09121234567');
Sms::assertTemplateSent('09121234567', 'otp-array'); // resolved ID for array driver
Sms::assertNothingSent(); // before sending

OTP vault in tests

config([
    'smsapi.otp.vault.enabled' => true,
    'smsapi.otp.vault.reveal_code' => true,
    'smsapi.otp.vault.throttle.enabled' => false,
]);

Sms::fake();

$issued = Sms::challenge('login')
    ->template('otp-login')
    ->to('09121234567')
    ->usingCode('12345') // optional fixed code
    ->send();

Sms::challenge('login')->check('09121234567', '12345');

For mail channels use Mail::fake() — Sms::fake() intercepts SMS only.

Clone this wiki locally