How to perform tests with backed enums

  1. $casts is set```phpprotected $casts = [ 'name' => EnumsRole::class,];```
  2. The enum, in this case, does not implement hasLabel.```phpenum Role: string{ case FOO = 'foo';case BAR= 'bar';}```
  3. The test```phplivewire(ListRoles::class) ->assertTableColumnFormattedStateSet('name', $record->name, record: $record); // Object of class App\Enums\Role could not be converted to string
livewire(ListRoles::class)
->assertTableColumnFormattedStateSet('name', $record->name->value, record: $record); // Failed asserting that a table column with name [name] has a formatted state of [foo] for recordto string

```
  1. if I use assertTableColumnStateSet, the errors are exactly the same.
Does anyone know what I could be doing wrong?
Was this page helpful?