You don't really need Faker for this,
$data = json_encode([
'start_date' => Carbon::yesterday()->toDateString(),
'end_date' => Carbon::now()->toDateString(),
'thing' => rand(11,99),
]);
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hi,
At the moment, I have this in one of my tests:
$data = "[[{'start_date':'2018-01-01','end_date':'2018-02-01','thing':'12'}],
[{'start_date':'2018-03-01','end_date':'2018-04-01','thing':'8'}]]";
Basically I just need a couple of dates and a small random number, then converted to JSON for a post.
Should I just be using faker to do this, inside the test. or is there a better way?
Mick
Please or to participate in this conversation.