I have a table with a quantity
column, defined as DECIMAL(8,3)
.
I wrote a test that creates a record in the table and tests if the record is present:
$this->assertDatabaseHas('my_table', [
'id' => $newRecord->getKey(),
'id_user' => $id_user,
'quantity' => (float)$quantity,
'id_action' => 5,
]);
This is the result of the test:
Failed asserting that a row in the table [my_table] matches the attributes {
"id_user": 6166,
"quantity": 10,
"id_action": 5,
"params": "{"id_sale_bid":2040}"
}.
Found similar results: [
{
"id_user": 6166,
"quantity": "10.000",
"id_action": 5,
"params": "{"id_sale_bid": 2040}"
}
]
As you can see the record is present, it’s just that it looks for the wrong type.