Testing
Use Log Driver
Section titled “Use Log Driver”BARTA_DRIVER=logFake HTTP Requests
Section titled “Fake HTTP Requests”use Illuminate\Support\Facades\Http;
it('sends sms', function () { Http::fake([ 'smsplus.sslwireless.com/*' => Http::response(['status' => 'SUCCESS']), ]);
config()->set('barta.default', 'ssl');
$response = Barta::to('01712345678')->message('Test')->send();
expect($response->success)->toBeTrue();});Test Notifications
Section titled “Test Notifications”use Illuminate\Support\Facades\Notification;
it('sends notification', function () { Notification::fake();
$user->notify(new OrderShipped());
Notification::assertSentTo($user, OrderShipped::class);});Test Queued SMS
Section titled “Test Queued SMS”use Illuminate\Support\Facades\Bus;use Larament\Barta\Jobs\SendSmsJob;
it('queues sms', function () { Bus::fake();
Barta::to('01712345678')->message('Test')->queue();
Bus::assertDispatched(SendSmsJob::class);});