Laravel 13.35: Fake Assertions Accept Property Arrays | Mohamed Said       [Skip to content](#main)  [ ![](https://cdn.msaied.com/01KT78WE565VEMM3PSNQAAB0MH.png) Mohamed SaidLaravel Backend Engineer ](https://msaied.com) - [Home](https://msaied.com)
- [Projects](https://msaied.com/projects)
- [Articles](https://msaied.com/articles)
- [Certificates](https://msaied.com/certificates)
- [About](https://msaied.com#about)

           [  Contact](https://msaied.com#contact) Menu 

Menu
----

Close 

 - [HomeStart here](https://msaied.com)
- [ProjectsCase studies](https://msaied.com/projects)
- [ArticlesEngineering notes](https://msaied.com/articles)
- [CertificatesCredentials](https://msaied.com/certificates)
- [AboutHow I work](https://msaied.com#about)
- [ContactGet in touch](https://msaied.com#contact)

  [Start a conversation](https://msaied.com#contact) [WhatsApp](https://wa.me/201094619204) [Email](mailto:hello@msaied.com) 

 1. [Home](https://msaied.com)
2. /
3. [Articles](https://msaied.com/articles)
4. /
5. [Laravel](https://msaied.com/articles?category=laravel)
6. /
7. Laravel Fake Assertions Now Accept Property Arrays in Laravel 13.35

   [Laravel](https://msaied.com/articles?category=laravel) [Tips &amp; Tricks](https://msaied.com/articles?category=tips-tricks) 

 Laravel Fake Assertions Now Accept Property Arrays in Laravel 13.35
====================================================================

 Laravel 13.35 lets you pass a plain array of expected property values to Queue, Bus, Event, and Notification fakes instead of writing a callback, making test assertions shorter and easier to read.

 ![](https://cdn.msaied.com/01M22N44A70A5MC2S599JP0MPH.webp) [Mohamed Said](https://msaied.com#person) Published 7 Oct 2026 · Updated 8 Oct 2026 · 3 min read

ShareCopy linkCopied

 ![Laravel Fake Assertions Now Accept Property Arrays in Laravel 13.35](https://cdn.msaied.com/754/1ab77f05a0bd841971617d39adabd22e.png) 

  On this page +1. [Cleaner Fake Assertions in Laravel 13.35](#cleaner-fake-assertions-in-laravel-1335)
2. [Before: Callback-Based Assertions](#before-callback-based-assertions)
3. [After: Array-Based Assertions](#after-array-based-assertions)
4. [How Values Are Compared](#how-values-are-compared)
5. [Public Properties Only](#public-properties-only)
6. [Key Takeaways](#key-takeaways)

 Cleaner Fake Assertions in Laravel 13.35
----------------------------------------

Laravel 13.35 ships a small but welcome quality-of-life improvement for feature tests: the `Queue`, `Bus`, `Event`, and `Notification` fakes now accept a plain PHP array of expected property values as the second argument to their assertion methods. You no longer need to write a closure just to compare a handful of properties.

### Before: Callback-Based Assertions

Prior to 13.35, verifying that a job was pushed with the right data required a callback:

```php
Queue::fake();

$this->actingAs($user)->post('/podcasts', $data);

Queue::assertPushed(ProcessPodcast::class, function (ProcessPodcast $job) use ($podcast, $user) {
    return $job->podcast->is($podcast)
        && $job->user->is($user)
        && $job->status === 'pending';
});

```

### After: Array-Based Assertions

With 13.35 you can replace that closure with a concise array:

```php
Queue::assertPushed(ProcessPodcast::class, [
    'podcast' => $podcast,
    'user'    => $user,
    'status'  => 'pending',
]);

```

The same syntax works across all four fakes:

```php
Event::assertDispatched(OrderShipped::class, ['order' => $order]);
Bus::assertDispatched(GenerateInvoice::class, ['order' => $order]);
Notification::assertSentTo($user, InvoicePaid::class, ['invoice' => $invoice]);

```

Negative and variant assertions that previously accepted a callback also support the array form:

```php
Queue::assertNotPushed(ProcessPodcast::class, ['user' => $otherUser]);

```

How Values Are Compared
-----------------------

Every key in the array must match for the assertion to pass. The comparison rules are:

- **Scalar values** — strict equality (`===`).
- **Eloquent models** — compared with `$model->is()`, which checks the primary key, table, and database connection. Two separate model instances pointing to the same row will match correctly.
- **Other objects** (Carbon, value objects, collections) — strict equality, meaning two separate instances for the same moment are *not* equal. Use a callback for those cases:

```php
Queue::assertPushed(SendReminder::class, function (SendReminder $job) use ($user) {
    return $job->user->is($user)
        && $job->sendAt->equalTo(now()->addDay());
});

```

The array checks **top-level properties only** — there is no dot-notation support for nested values.

Public Properties Only
----------------------

The fake reads properties directly from outside the object, so they must be `public`. Jobs that store data in `protected` properties or expose it only through getter methods still require a callback. Constructor property promotion with `public` works perfectly:

```php
class ProcessPodcast implements ShouldQueue
{
    use Queueable;

    public function __construct(
        public Podcast $podcast,
        public User    $user,
        public string  $status = 'pending',
    ) {}
}

```

If a key in the array does not exist on the object, the assertion fails rather than throwing an exception — so a typo in a property name surfaces immediately as a failing test.

Key Takeaways
-------------

- Available in **Laravel 13.35** for `Queue`, `Bus`, `Event`, and `Notification` fakes.
- Pass an associative array as the second argument instead of a closure.
- Eloquent models are compared with `->is()`; everything else uses `===`.
- Only **public** properties are accessible; use a callback for protected data or complex objects.
- Dot-notation for nested properties is **not** supported.
- A missing property key fails the assertion cleanly — no uncaught errors.

Contributed by [Jack Bayliss](https://github.com/jackbayliss) in [PR #61770](https://github.com/laravel/framework/pull/61770).

---

*Source: [Laravel Fake Assertions Now Accept Property Arrays — Laravel News](https://laravel-news.com/laravel-fake-assertion-property-arrays)*

- [Laravel](https://msaied.com/articles?search=Laravel)
- [Testing](https://msaied.com/articles?search=Testing)
- [Laravel 13](https://msaied.com/articles?search=Laravel%2013)
- [Fakes](https://msaied.com/articles?search=Fakes)
- [PHPUnit](https://msaied.com/articles?search=PHPUnit)

 Frequently asked questions 
---------------------------

  Which Laravel fakes support the new array assertion syntax?As of Laravel 13.35, the Queue, Bus, Event, and Notification fakes all accept an associative array of expected property values in place of a callback in their assertion methods.

   How are Eloquent models compared when using array assertions?When both the expected and actual values are Eloquent models, Laravel uses the `$model-&gt;is()` method, which compares the primary key, table, and database connection. All other values are compared with strict equality (`===`).

   Do properties need to be public to use array-based fake assertions?Yes. The fake reads properties directly from outside the object, so they must be declared public. Jobs or events that store data in protected properties or behind getter methods still require a callback-based assertion.

   ![Mohamed Said](https://cdn.msaied.com/01M22N44A70A5MC2S599JP0MPH.webp)About the author
----------------

[Mohamed Said](https://msaied.com#person)Senior Backend Engineer specializing in Laravel, scalable SaaS platforms, APIs, and cloud infrastructure. I build secure, high-performance web applications that help businesses grow.

[About](https://msaied.com#about) [GitHub ↗](https://github.com/EG-Mohamed) [LinkedIn ↗](https://www.linkedin.com/in/msaiedm/) [WhatsApp ↗](https://wa.me/201094619204) [Email Address ↗](mailto:hello@msaied.com) [My CV ↗](https://drive.google.com/file/u/0/d/1MF20IPRJyzfy32mhEutjL5EpSls0w2Q8/view)  

   [Previous articleFilament v5.10.1 Released: Bug Fixes for Tables, Select Search, and Dropdown Navigation](https://msaied.com/articles/filament-v5101-released-bug-fixes-for-tables-select-search-and-dropdown-navigation)  

   On this page
-------------

1. [Cleaner Fake Assertions in Laravel 13.35](#cleaner-fake-assertions-in-laravel-1335)
2. [Before: Callback-Based Assertions](#before-callback-based-assertions)
3. [After: Array-Based Assertions](#after-array-based-assertions)
4. [How Values Are Compared](#how-values-are-compared)
5. [Public Properties Only](#public-properties-only)
6. [Key Takeaways](#key-takeaways)

 ###  Have a technical challenge?

 Tell me what you’re building. I reply within two working days.

[Start a conversation](https://msaied.com#contact) 

   Related articles
-----------------

 [ ![](https://cdn.msaied.com/753/fea306145a8fc693561ccd02ff95afa5.png) Laravel · 3 min read### Filament v5.10.1 Released: Bug Fixes for Tables, Select Search, and Dropdown Navigation

7 Oct 2026 ](https://msaied.com/articles/filament-v5101-released-bug-fixes-for-tables-select-search-and-dropdown-navigation) [ ![](https://cdn.msaied.com/751/f7f990b3f16958e2c8634c128cc211e6.png) Laravel · 3 min read### Filament v4.15.1 Released: Bug Fixes for Tables, Select Search, and Dropdown Navigation

7 Oct 2026 ](https://msaied.com/articles/filament-v4151-released-bug-fixes-for-tables-select-search-and-dropdown-navigation) [ ![](https://cdn.msaied.com/750/bc3e713faaa9d7c80b19bb72f0b4f97d.png) Laravel · 3 min read### Route::query() and Model defaults() in Laravel 13.35

7 Oct 2026 ](https://msaied.com/articles/routequery-and-model-defaults-in-laravel-1335) 

  Have a technical challenge?
----------------------------

Tell me what you’re building. I reply within two working days.

 [Discuss your project ↗](https://msaied.com#contact) 

  © 2026 Mohamed Said · Built with Laravel, meant to last.Senior Backend Engineer specializing in Laravel, scalable SaaS platforms, APIs, and cloud infrastructure. I build secure, high-performance web applications that help businesses grow.

 - [Home](https://msaied.com)
- [Articles](https://msaied.com/articles)
- [Certificates](https://msaied.com/certificates)
- [GitHub](https://github.com/EG-Mohamed)
- [LinkedIn](https://www.linkedin.com/in/msaiedm/)
- [WhatsApp](https://wa.me/201094619204)
- [Email Address](mailto:hello@msaied.com)
- [My CV](https://drive.google.com/file/u/0/d/1MF20IPRJyzfy32mhEutjL5EpSls0w2Q8/view)
- [Sitemap](https://msaied.com/sitemap.xml)
