PHPackages                             samuelmwangiw/africastalking-laravel-tests - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. samuelmwangiw/africastalking-laravel-tests

ActiveLibrary

samuelmwangiw/africastalking-laravel-tests
==========================================

Testing helpers for samuelmwangiw/africastalking-laravel: fake the Africa's Talking API and assert against Voice, SMS, Airtime, Mobile Data, SIM Swap, Payment, Stash, Wallet and Application calls.

02↑2900%PHPCI passing

Since Jul 30Pushed yesterdayCompare

[ Source](https://github.com/SamuelMwangiW/africastalking-laravel-tests)[ Packagist](https://packagist.org/packages/samuelmwangiw/africastalking-laravel-tests)[ RSS](/packages/samuelmwangiw-africastalking-laravel-tests/feed)WikiDiscussions main Synced today

READMEChangelogDependenciesVersions (2)Used By (0)

africastalking-laravel-tests
============================

[](#africastalking-laravel-tests)

[![Latest Version on Packagist](https://camo.githubusercontent.com/247a991c081ded5e7421744aa65ed487d7628af6341f0e51b5d6ca4fab6da098/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f73616d75656c6d77616e6769772f6166726963617374616c6b696e672d6c61726176656c2d74657374732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/samuelmwangiw/africastalking-laravel-tests)[![run-tests](https://github.com/SamuelMwangiW/africastalking-laravel-tests/actions/workflows/run-tests.yml/badge.svg)](https://github.com/SamuelMwangiW/africastalking-laravel-tests/actions/workflows/run-tests.yml)[![PHPStan](https://github.com/SamuelMwangiW/africastalking-laravel-tests/actions/workflows/phpstan.yml/badge.svg)](https://github.com/SamuelMwangiW/africastalking-laravel-tests/actions/workflows/phpstan.yml)[![Code styling](https://github.com/SamuelMwangiW/africastalking-laravel-tests/actions/workflows/php-cs-fixer.yml/badge.svg)](https://github.com/SamuelMwangiW/africastalking-laravel-tests/actions/workflows/php-cs-fixer.yml)[![Total Downloads](https://camo.githubusercontent.com/a5b4d025aef11a77aa2e19508670bc017088fe802ef940cea99a8633f484a86c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f73616d75656c6d77616e6769772f6166726963617374616c6b696e672d6c61726176656c2d74657374732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/samuelmwangiw/africastalking-laravel-tests)

Testing helpers for [`samuelmwangiw/africastalking-laravel`](https://github.com/samuelmwangiw/africastalking-laravel). Fake the Africa's Talking API in your test suite and make expressive assertions against Voice, SMS, Airtime, Mobile Data, SIM Swap, Payment, Stash, Wallet and Application calls — no real HTTP requests, no sandbox credentials required.

Installation
------------

[](#installation)

You can install the package via composer, as a dev dependency:

```
composer require samuelmwangiw/africastalking-laravel-tests --dev
```

The package auto-registers its service provider via Laravel package discovery.

Usage
-----

[](#usage)

Call `Africastalking::fake()` at the start of a test to intercept every request the main package would otherwise send to Africa's Talking. Every domain (voice, sms, airtime, data, simswap, stash, wallet, application, payment) is pre-wired with realistic default responses, so your code under test can run unmodified.

```
use SamuelMwangiW\Africastalking\Facades\Africastalking;

it('sends a welcome sms', function () {
    Africastalking::fake();

    Africastalking::sms('Welcome!')->to('+254700000000')->send();

    Africastalking::fake()->assertSmsSentTo('+254700000000');
});
```

`Africastalking::fake()` always returns the same instance within a test, so you can chain configuration and assertions across multiple calls.

Global
------

[](#global)

MethodDescription`Africastalking::fake(): FakeAfricastalking`Base entry point; intercepts every Saloon request across all domains`assertNothingDispatched(): void`Asserts nothing was sent to Africa's Talking, across any service`assertSentCount(int $count, ?string $service = null)`Generic count assertion, optionally scoped to one service (`voice`, `sms`, `airtime`, `data`, `simswap`, `stash`, `wallet`, `application`, `payment`)`recorded(string $service): Collection`Escape hatch returning the raw recorded `Saloon\Http\Response` objects for a serviceVoice
-----

[](#voice)

MethodDescription`fake()->failVoiceCalls()`Makes every subsequent voice call fail`fake()->failVoiceCallsFor(array $phoneNumbers)`Makes voice calls fail only for the given phone numbers`fake()->succeedVoiceCalls()`Reverts a prior `failVoiceCalls()`/`failVoiceCallsFor()`, making subsequent calls succeed again`assertVoiceCallCount(int $count)`Asserts exactly N voice calls were placed`assertNoVoiceCallsPlaced()` / `assertNothingCalled()`Asserts no voice call was placed`assertVoiceCallPlaced(?Closure $callback = null)`Asserts a call was placed, optionally matching a closure over the request body`assertVoiceCallPlacedTo(string $phoneNumber)` / `assertCallMadeTo(string $phone)`Asserts a call was placed to a specific number`assertVoiceCallPlacedFrom(string $callerId)` / `assertCallMadeFrom(string $phone)`Asserts a call was placed from a specific caller ID`assertVoiceCallHadClientRequestId(string $id)` / `assertCallRequestId(string $id)`Asserts a placed call carried the given `clientRequestId` (voice calls have no idempotency key in the main package — this is the closest equivalent)`assertVoiceCallHadActions(array $actionTypes)`Asserts a placed call's `callActions` included the given action types, in order`assertVoiceCallSaid(string $message)`Asserts a placed call included a `say` action with the given exact message`assertVoiceCallPlayed(string $url)`Asserts a placed call included a `play` action with the given URL`assertVoiceCallDialed(array $phoneNumbers)`Asserts a placed call included a `dial` action to the given numbers`assertVoiceCallQueued(string $queueName)`Asserts a placed call included an `enqueue` action for the given queue`fake()->withQueueStatus(array $entries)`Seeds `queueStatus()` responses globally`fake()->withQueueStatusFor(string $phoneNumber, array $entries)`Seeds `queueStatus()` response for a specific phone number`assertQueueStatusChecked(?string $phoneNumber = null)`Asserts `queueStatus()` was called, optionally for a specific numberSMS
---

[](#sms)

MethodDescription`fake()->failSms()`Makes every subsequent SMS send fail`fake()->failSmsTo(array $phoneNumbers)`Makes SMS sends fail only for the given phone numbers`assertSmsSentTo(string $phoneNumber)`Asserts an SMS was sent to a specific number`assertSmsSentFrom(string $sender)`Asserts the sender ID (`from`) was set correctly`assertSmsContains(string $text)`Asserts a sent SMS's body contains the given text`assertSmsCount(int $count)`Asserts exactly N SMS messages were sent`assertNoSmsSent()` / `assertNothingSent()`Asserts no SMS was sent. `assertNothingSent()` is scoped to SMS only — for the cross-service assertion, use the global `assertNothingDispatched()``assertBulkSmsSent()`Asserts a bulk-mode SMS was sent`assertPremiumSmsSent()`Asserts a premium-mode SMS was sentAirtime
-------

[](#airtime)

MethodDescription`fake()->failAirtime()`Makes every subsequent airtime disbursement fail`fake()->failAirtimeFor(array $phoneNumbers)`Makes airtime disbursement fail only for the given phone numbers`assertAirtimeSentTo(string $phoneNumber, ?string $amount = null)`Asserts airtime was sent to a number, optionally checking the amount (substring match)`assertSentAirtime(string $phone, int $amount)`Asserts airtime was sent to a number for an exact whole-unit amount`assertAirtimeCount(int $count)`Asserts exactly N airtime disbursements were sent`assertNoAirtimeSent()` / `assertAirtimeNotSent()`Asserts no airtime was sent`assertSentAirtimeIdempotently(string $key)`Asserts an airtime request carried the given `Idempotency-Key` headerMobile Data
-----------

[](#mobile-data)

MethodDescription`fake()->failDataBundles()`Makes every subsequent data bundle send fail`assertDataBundleSentTo(string $phoneNumber, string $productName)`Asserts a data bundle was sent to a number for a given productSIM Swap
--------

[](#sim-swap)

MethodDescription`fake()->withSimSwapResult(string $phoneNumber, array $result)`Seeds/overrides the SIM swap check result for a phone number`assertSimSwapChecked(string $phoneNumber)`Asserts a SIM swap check was performed for a numberPayment (mobile checkout)
-------------------------

[](#payment-mobile-checkout)

MethodDescription`fake()->failPayments()`Makes every subsequent payment fail`assertPaymentSent(?Closure $callback = null)`Asserts a mobile checkout payment was sentStash
-----

[](#stash)

MethodDescription`fake()->failStashTopup()`Makes every subsequent Stash top-up fail`assertStashToppedUp(?Closure $callback = null)`Asserts a Stash top-up was sentWallet
------

[](#wallet)

MethodDescription`fake()->withWalletBalance(string $amount)`Seeds the wallet balance response`fake()->fakeWalletBalance(float $balance, string $currency = 'KES')`Same as `withWalletBalance()`, but takes the amount and currency as separate argumentsApplication
-----------

[](#application)

MethodDescription`fake()->withApplicationBalance(string $amount)`Seeds the application balance responseNotes on failures
-----------------

[](#notes-on-failures)

Calling one of the `fail*()` helpers does not throw an HTTP exception by itself — it makes the *mocked* Africa's Talking response describe a failure the same way the real API would (an empty `Recipients` list, a recipient marked `Failed`, a top-up `status` of `Failed`, and so on). Whether that turns into a thrown exception in your code under test depends entirely on `samuelmwangiw/africastalking-laravel`'s own domain logic — for example, `Message::send()` throws `AfricastalkingException` when no recipient was accepted, while `Airtime::send()` simply returns an `AirtimeResponse` with `numSent === 0` for the caller to inspect.

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Samuel Mwangi](https://github.com/SamuelMwangiW)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

22

—

LowBetter than 21% of packages

Maintenance65

Regular maintenance activity

Popularity3

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity13

Early-stage or recently created project

 Bus Factor1

Top contributor holds 75% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/a61fbb91053310302b3256009b67e371e533083b8eea4ae37d3b6a9efa06e2f6?d=identicon)[SamuelMwangiW](/maintainers/SamuelMwangiW)

---

Top Contributors

[![SamuelMwangiW](https://avatars.githubusercontent.com/u/1807304?v=4)](https://github.com/SamuelMwangiW "SamuelMwangiW (3 commits)")[![claude](https://avatars.githubusercontent.com/u/81847?v=4)](https://github.com/claude "claude (1 commits)")

### Embed Badge

![Health badge](/badges/samuelmwangiw-africastalking-laravel-tests/health.svg)

```
[![Health](https://phpackages.com/badges/samuelmwangiw-africastalking-laravel-tests/health.svg)](https://phpackages.com/packages/samuelmwangiw-africastalking-laravel-tests)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
