In Laravel and Pest tests, assertDatabaseHas() natively queries nested JSON properties using arrow syntax and accepts backed Enum instances directly.
Testing JSON attributes or PHP backed enums requires no manual casting or encoding. assertDatabaseHas() supports arrow syntax and serializes enums automatically.
$this->assertDatabaseHas('users', [
'role' => UserRole::Maintainer,
'settings->theme' => 'dark',
]);
- Handles Backed Enums directly without ->value casting
- Queries nested JSON keys using arrow notation
- Works out of the box with Pest and PHPUnit assertions
Tags:
#Laravel #Testing #Pest #Enums