PHPackages                             circle33/laravel-bus-fluentable - 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. [Testing &amp; Quality](/categories/testing)
4. /
5. circle33/laravel-bus-fluentable

ActiveLibrary[Testing &amp; Quality](/categories/testing)

circle33/laravel-bus-fluentable
===============================

Make Laravel testing batched jobs more fluent.

v1.0.10(1y ago)05MITPHP

Since Dec 17Pushed 1y ago1 watchersCompare

[ Source](https://github.com/rust17/laravel-bus-fluentable)[ Packagist](https://packagist.org/packages/circle33/laravel-bus-fluentable)[ RSS](/packages/circle33-laravel-bus-fluentable/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (4)Dependencies (5)Versions (10)Used By (0)

 [![](./bus.png)](./bus.png)

Laravel Bus Fluentable
======================

[](#laravel-bus-fluentable)

[![Latest Version on Packagist](https://camo.githubusercontent.com/ddb479243f5bb5dbd346652123e386eceac0bde3cb434a73971e8b52bd91748c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f636972636c6533332f6c61726176656c2d6275732d666c75656e7461626c652e7376673f7374796c653d666c61742d636972636c65)](https://packagist.org/packages/circle33/laravel-bus-fluentable)[![PHPUnit](https://github.com/rust17/laravel-bus-fluentable/actions/workflows/phpunit.yml/badge.svg)](https://github.com/rust17/laravel-bus-fluentable/actions/workflows/phpunit.yml)[![Static Analysis](https://github.com/rust17/laravel-bus-fluentable/actions/workflows/phpstan.yml/badge.svg)](https://github.com/rust17/laravel-bus-fluentable/actions/workflows/phpstan.yml)[![Check Style](https://github.com/rust17/laravel-bus-fluentable/actions/workflows/php-cs-fixer.yml/badge.svg)](https://github.com/rust17/laravel-bus-fluentable/actions/workflows/php-cs-fixer.yml)

When using Laravel, the current approach to testing batched jobs, as shown below, is somewhat unconventional:

```
Bus::assertBatched(fn (PendingBatchFake $batchedCollection) =>
    $batchedCollection->jobs->count() === 1 && $batchedCollection->jobs->first()->value === 'hello';
);

```

This package introduces some helper functions to enhance the testability of batched jobs. Inspired by [fluent JSON testing](https://laravel.com/docs/11.x/http-tests#fluent-json-testing), these methods provide a more streamlined and readable approach to testing job batches within the Laravel application. The goal is to improve developer experience by offering clear, concise methods with illustrative examples.

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

[](#installation)

```
composer require --dev circle33/laravel-bus-fluentable
```

Documentation
-------------

[](#documentation)

### `has`

[](#has)

Assert that the batch contains a job of the given type. You can also pass an integer to assert that the batch contains the exact number of jobs.

**Example:**

```
use Circle33\LaravelBusFluentable\Bus as BusFacade;
use Circle33\LaravelBusFluentable\FluentPendingBatch;

Bus::fake();

Bus::batch([
    new AJob(1, 2),
    new BJob,
])->dispatch();

BusFacade::assertPendingBatched(fn (FluentPendingBatch $batch) =>
    $batch->has(2)
        ->has(AJob::class, [1, 2])
);
```

### `missing`

[](#missing)

Assert that the batch does not contain a job of the given type.

**Example:**

```
use Circle33\LaravelBusFluentable\Bus as BusFacade;
use Circle33\LaravelBusFluentable\FluentPendingBatch;

Bus::fake();

Bus::batch([
    new BJob,
])->dispatch();

BusFacade::assertPendingBatched(fn (FluentPendingBatch $batch) =>
    $batch->missing(AJob::class)
);
```

### `hasAll`

[](#hasall)

Assert that the batch contains all of the given jobs.

**Example:**

```
use Circle33\LaravelBusFluentable\Bus as BusFacade;
use Circle33\LaravelBusFluentable\FluentPendingBatch;

Bus::fake();

Bus::batch([
    new AJob,
    new BJob,
])->dispatch();

BusFacade::assertPendingBatched(fn (FluentPendingBatch $batch) =>
    $batch->hasAll([AJob::class, BJob::class])
);
```

### `missingAll`

[](#missingall)

Assert that the batch does not contain any of the given jobs.

**Example:**

```
use Circle33\LaravelBusFluentable\Bus as BusFacade;
use Circle33\LaravelBusFluentable\FluentPendingBatch;

Bus::fake();

Bus::batch([
    new AJob,
    new BJob,
])->dispatch();

BusFacade::assertPendingBatched(fn (FluentPendingBatch $batch) =>
    $batch->missingAll([CJob::class, DJob::class])
);
```

### `hasAny`

[](#hasany)

Assert that the batch contains any of the given jobs.

**Example:**

```
use Circle33\LaravelBusFluentable\Bus as BusFacade;
use Circle33\LaravelBusFluentable\FluentPendingBatch;

Bus::fake();

Bus::batch([
    new AJob(1, 2),
    new BJob,
])->dispatch();

BusFacade::assertPendingBatched(fn (FluentPendingBatch $batch) =>
    $batch->hasAny(AJob::class, CJob::class)
);
```

### `first`

[](#first)

Assert that the first job in the batch matches the given callback.

**Example:**

```
use Circle33\LaravelBusFluentable\Bus as BusFacade;
use Circle33\LaravelBusFluentable\FluentPendingBatch;

Bus::fake();

Bus::batch([
    [
        new AJob(1, 2),
        new BJob,
    ],
    new CJob,
])->dispatch();

BusFacade::assertPendingBatched(fn (FluentPendingBatch $batch) =>
    $batch->first(fn (PendingBatchFake $firstBatch) =>
        $firstBatch->has(AJob::class, [1, 2])
            ->has(BJob::class)
    )
);
```

### `nth`

[](#nth)

Assert that the nth job in the batch matches the given callback or type and parameters.

**Example:**

```
use Circle33\LaravelBusFluentable\Bus as BusFacade;
use Circle33\LaravelBusFluentable\FluentPendingBatch;

Bus::fake();

Bus::batch([
    [
        new AJob(1, 2),
        new BJob
    ],
    new CJob::class(1)
])->dispatch();

BusFacade::assertPendingBatched(fn (FluentPendingBatch $batch) =>
    $batch->nth(0, fn (FluentPendingBatch $batch) =>
        $batch->has(AJob::class, [1, 2])
            ->has(BJob::class)
    )->nth(1, CJob::class, [1])
);
```

### `equal`

[](#equal)

Assert that the batch contains exactly the given jobs with the specified parameters.

**Example:**

```
use Circle33\LaravelBusFluentable\Bus as BusFacade;
use Circle33\LaravelBusFluentable\FluentPendingBatch;

Bus::fake();

Bus::batch([
    [
        new AJob(1, 2),
        new BJob
    ],
    new CJob::class(1)
])->dispatch();

BusFacade::assertPendingBatched(fn (FluentPendingBatch $batch) =>
    $batch->equal([
        [
            AJob::class => [1, 2],
            BJob::class
        ],
        CJob::class => [1]
    ])
);
```

### `etc`

[](#etc)

Assert that the batch has unexpected jobs beyond those checked.

**Example:**

```
use Circle33\LaravelBusFluentable\Bus as BusFacade;
use Circle33\LaravelBusFluentable\FluentPendingBatch;

Bus::fake();

Bus::batch([
    new AJob(1, 2),
    new BJob,
    new CJob::class(1)
])->dispatch();

BusFacade::assertPendingBatched(fn (FluentPendingBatch $batch) =>
    $batch->has(AJob::class, [1, 2])
        ->has(BJob::class)
        ->etc()
);
```

Contributing
============

[](#contributing)

Thank you for considering contributing to this project! We welcome and appreciate your help.

1. Fork the repository to your GitHub account.
2. Clone your forked repository to your local machine: ```
    git clone https://github.com/your-username/laravel-bus-fluentable.git
    ```

License
-------

[](#license)

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

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance40

Moderate activity, may be stable

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity44

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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.

###  Release Activity

Cadence

Every ~1 days

Total

9

Last Release

501d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/43b5cfbd3fb50ecdd4bb63908e944a88a58a915fd01aa0f225dae5e1fd3e3f5b?d=identicon)[rust17](/maintainers/rust17)

---

Top Contributors

[![rust17](https://avatars.githubusercontent.com/u/16575052?v=4)](https://github.com/rust17 "rust17 (26 commits)")

---

Tags

laravellaravel-bus-fluentable

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/circle33-laravel-bus-fluentable/health.svg)

```
[![Health](https://phpackages.com/badges/circle33-laravel-bus-fluentable/health.svg)](https://phpackages.com/packages/circle33-laravel-bus-fluentable)
```

###  Alternatives

[mpociot/laravel-test-factory-helper

Generate Laravel test factories from your existing models

933635.2k2](/packages/mpociot-laravel-test-factory-helper)[laracasts/behat-laravel-extension

Laravel extension for Behat

2611.3M12](/packages/laracasts-behat-laravel-extension)[davestewart/sketchpad

An innovative front-end environment for interactive Laravel development

29512.9k1](/packages/davestewart-sketchpad)[kunicmarko/graphql-test

GraphQL Test Cases

1359.0k](/packages/kunicmarko-graphql-test)[mnabialek/laravel-quick-migrations

Run Laravel tests quicker

2210.9k](/packages/mnabialek-laravel-quick-migrations)[srlabs/laravel-testing-utilities

Helper utilities for testing Laravel Applications

1011.9k](/packages/srlabs-laravel-testing-utilities)

PHPackages © 2026

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