If you need a nice way of printing objects, JSON works very well.
Note: ApprovalTests will sort your fields alphabetically so that you have consistency in your JSON.
Here's an example.
public function testVerifyAsJson()
{
$obj = [
"color" => "black",
"category" => "hue",
"type" => "primary",
"code" => [
"rgba" => [255, 255, 255, 1],
"hex" => "#000",
]
];
Approvals::verifyAsJson($obj);
}
will create the approved file
{
"category": "hue",
"code": {
"hex": "#000",
"rgba": [
255,
255,
255,
1
]
},
"color": "black",
"type": "primary"
}