Jump24 - Laravel Developers that Click into Place. Never outsourced. Never offshored. Always exceptional.

UnitTest Attribute and More in Laravel 13.3.0

Last updated on by

UnitTest Attribute and More in Laravel 13.3.0 image

Never Miss a Laravel Release πŸš€

Sign up and get an email with each new Laravel release

This release introduces a #[UnitTest] PHP attribute for skipping framework boot on individual test methods, variadic support for model attributes like #[Fillable] and #[Hidden], a new BatchStarted event in the job batching lifecycle, and more.

  • New #[UnitTest] attribute to skip framework boot per test method
  • Variadic args for #[Fillable], #[Appends], #[Hidden], and other model attributes
  • New BatchStarted event for job batch lifecycle monitoring
  • Memory usage shown in verbose queue worker output
  • Security: install:broadcasting now passes --ignore-scripts to npm/pnpm

What's New

#[UnitTest] Attribute

A new #[UnitTest] attribute lets you skip framework booting for individual test methods within a TestCase that extends Laravel's base test case. This is useful when most tests in a class need the container but a few are pure unit tests that don't.

Without it, every test in the class pays the cost of booting the full framework. With #[UnitTest], those specific methods run as bare PHPUnit tests β€” which can be an order of magnitude faster.

use Illuminate\Foundation\Testing\Attributes\UnitTest;
 
class LocationServiceTest extends TestCase
{
public function test_getCoordinates_resolves_address_for_us(): void
{
// needs the container
}
 
#[UnitTest]
public function test_getState_returns_state_from_abbreviation(): void
{
// no framework boot needed
}
}

Pull Request: #59432

Variadic Model Attributes

Several Eloquent model attributes now accept variadic arguments. Previously, you had to pass an array; now you can pass each value as a separate argument:

// Before
#[Fillable(['first_name', 'last_name'])]
#[Hidden(['password', 'secret'])]
class User extends Model {}
 
// After
#[Fillable('first_name', 'last_name')]
#[Hidden('password', 'secret')]
class User extends Model {}

Passing a single array is still supported, so there are no breaking changes.

Pull Request: #59421

BatchStarted Event

A new BatchStarted event fires when the first job in a batch is processed (whether it succeeds or fails). This fills in a gap in the batch lifecycle:

  • BatchDispatched β€” jobs are queued, no worker has touched them yet
  • BatchStarted β€” first job has been processed
  • BatchFinished β€” all jobs are done (or cancelled)
  • BatchCanceled β€” batch was cancelled

This makes it possible to distinguish between a batch that's been queued and one that's actively being worked, which is useful for progress monitoring and UI updates.

Pull Request: #59458

Memory Usage in Verbose Queue Worker Output

When running the queue worker with -v, each processed job now includes current memory usage alongside the existing timing information:

# Before
2026-04-01 09:45:39 App\Jobs\ProcessReport 121599597 database reports 110.57ms DONE
 
# After
2026-04-01 09:45:39 App\Jobs\ProcessReport 121599597 database reports 44.58ms 132.5MB DONE

The memory reading uses the same logic as the worker's internal memoryExceeded check, so it gives you a direct view of how close a job is pushing toward the --memory limit.

Pull Request: #59379

Other Fixes and Improvements

Queue & Workers:

  • Forward releaseOnTerminationSignals through schedule groups (#59357)
  • Added LostConnection to WorkerStopReason (#59370)
  • Fixed dependency injection of faked queueing dispatcher (#59378)
  • Cached getLockForPopping() result in DatabaseQueue (#59435)
  • Enum support added to QueueManager connection methods (#59389)
  • Enum support added to LogManager channel and driver methods (#59391)

Scheduling:

  • Fixed sub-minute scheduling skips at minute boundaries (#59331)

Models & Database:

  • Fixed incrementEach/decrementEach to scope to the model instance (#59376)
  • Fixed MorphTo eager load matching when ownerKey is null and the result key is a non-primitive (#59394)
  • CollectedBy attribute now follows inheritance (#59419)
  • Stringable objects can now be returned from casts() (#59479)
  • Fixed macros with static closures (#59414)

HTTP & Requests:

  • Added ->file() method to $request->safe() for accessing validated file inputs (#59396)
  • Pass request to afterResponse callback (#59410)

URI:

  • Added isNotEmpty() method to the Uri class (#59408)
  • Added withoutFragment() method to the Uri class (#59413)
  • Fixed URI fragment preservation when decoding query strings (#59481)

Testing:

  • Added assertHasNoAttachments() to Mailable (#59443)
  • Added driver() method to MailFake (#59448)

Collections:

  • Collection methods are now compatible with extended subclass constructors (#59455)

Schema:

  • MariaDbSchemaState now uses mysql --version for client detection instead of mariadb --version (#59360)

Security:

  • The install:broadcasting command now passes --ignore-scripts to npm/pnpm when installing packages, preventing lifecycle scripts from running during installation (#59485)

Upgrade Notes

No breaking changes are expected for typical applications. Review the full changelog for complete details when upgrading.

References

Paul Redmond photo

Staff writer at Laravel News. Full stack web developer and author.

Cube

Laravel Newsletter

Join 40k+ other developers and never miss out on new tips, tutorials, and more.

image
Laravel Code Review

Get expert guidance in a few days with a Laravel code review

Visit Laravel Code Review
Tinkerwell logo

Tinkerwell

The must-have code runner for Laravel developers. Tinker with AI, autocompletion and instant feedback on local and production environments.

Tinkerwell
Get expert guidance in a few days with a Laravel code review logo

Get expert guidance in a few days with a Laravel code review

Expert code review! Get clear, practical feedback from two Laravel devs with 10+ years of experience helping teams build better apps.

Get expert guidance in a few days with a Laravel code review
PhpStorm logo

PhpStorm

The go-to PHP IDE with extensive out-of-the-box support for Laravel and its ecosystem.

PhpStorm
Laravel Cloud logo

Laravel Cloud

Easily create and manage your servers and deploy your Laravel applications in seconds.

Laravel Cloud
Acquaint Softtech logo

Acquaint Softtech

Acquaint Softtech offers AI-ready Laravel developers who onboard in 48 hours at $3000/Month with no lengthy sales process and a 100 percent money-back guarantee.

Acquaint Softtech
Kirschbaum logo

Kirschbaum

Providing innovation and stability to ensure your web application succeeds.

Kirschbaum
Shift logo

Shift

Running an old Laravel version? Instant, automated Laravel upgrades and code modernization to keep your applications fresh.

Shift
Harpoon: Next generation time tracking and invoicing logo

Harpoon: Next generation time tracking and invoicing

The next generation time-tracking and billing software that helps your agency plan and forecast a profitable future.

Harpoon: Next generation time tracking and invoicing
Lucky Media logo

Lucky Media

Get Lucky Now - the ideal choice for Laravel Development, with over a decade of experience!

Lucky Media
SaaSykit: Laravel SaaS Starter Kit logo

SaaSykit: Laravel SaaS Starter Kit

SaaSykit is a Multi-tenant Laravel SaaS Starter Kit that comes with all features required to run a modern SaaS. Payments, Beautiful Checkout, Admin Panel, User dashboard, Auth, Ready Components, Stats, Blog, Docs and more.

SaaSykit: Laravel SaaS Starter Kit
MongoDB logo

MongoDB

Enhance your PHP applications with the powerful integration of MongoDB and Laravel, empowering developers to build applications with ease and efficiency. Support transactional, search, analytics and mobile use cases while using the familiar Eloquent APIs. Discover how MongoDB's flexible, modern database can transform your Laravel applications.

MongoDB

The latest

View all →
Laravel Mobile Pass: Generate Apple Wallet and Google Wallet Passes image

Laravel Mobile Pass: Generate Apple Wallet and Google Wallet Passes

Read article
PHPverse 2026 Returns June 9th image

PHPverse 2026 Returns June 9th

Read article
LLPhant: A PHP Generative AI Framework Inspired by LangChain image

LLPhant: A PHP Generative AI Framework Inspired by LangChain

Read article
Debounceable Queued Jobs in Laravel 13.6.0 image

Debounceable Queued Jobs in Laravel 13.6.0

Read article
Build Custom Middleware for Query Performance Monitoring and Optimization in Laravel with MongoDB image

Build Custom Middleware for Query Performance Monitoring and Optimization in Laravel with MongoDB

Read article
Laravel API Starter Kits Are Coming Soon! image

Laravel API Starter Kits Are Coming Soon!

Read article