I have a little problem with my unit test and an array generated "randomly",
I have something looking like this :
return [
'foo' => $this->faker->sentence(),
'bar' => [
'baz' => $this->faker->realText(),
'booz' => [
'baaz' => $this->faker->title()
]
]
];
$this->faker->xxx generate random strings or whatever, but I want to test the "shape" of the array, I want to ensure I have :
foo in first children array, bar too Bar have baz and booz at the same level and booz have a baaz in children.
But I could not find how to do that, I have tried something like this but it is not working :/
$this->assertEquals([
'foo' => \Mockery::any(),
'bar' => [
'baz' => \Mockery::any(),
],
], $class->method());
Maybe this is not possible and I should find a way to simply test the keys in the array?
Maybe array_diff_key can help me here?