feat: add toHaveCamelCaseKeys

This commit is contained in:
Maurizio
2023-08-17 20:51:14 +02:00
parent 0b115230f9
commit 5d81cf0d4c
2 changed files with 53 additions and 0 deletions

View File

@ -784,4 +784,26 @@ final class Expectation
return $this;
}
/**
* Asserts that the given expectation is iterable and contains camelCase keys.
*
* @return self<TValue>
*/
public function toHaveCamelCaseKeys(string $message = ''): self
{
if (! is_iterable($this->value)) {
InvalidExpectationValue::expected('iterable');
}
foreach ($this->value as $k => $item) {
$this->and($k)->toBeCamelCase($message);
if (is_array($item)) {
$this->and($item)->toHaveCamelCaseKeys($message);
}
}
return $this;
}
}