feat: add toHaveKebabCaseKeys

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

View File

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