Sep 19, 2024
1
Level 2
assertDatabaseHas and encrypted casts?
On my model, I cast a column as encrypted:
protected function casts(): array
{
return [
'body' => 'encrypted',
];
}
But my database assertion fails:
$this->post('/messages', [
'body' => 'Hello',
]);
$this->assertDatabaseHas('chat_messages', [
'body' => Crypt::encryptString('Hello'),
'participant_id' => 1,
]);
How is this usually tested? It works if I remove the encrypted cast.
Please or to participate in this conversation.