feat: adds toHaveKeys expectation

This commit is contained in:
Nuno Maduro
2020-09-13 15:15:37 +02:00
parent aa230a1716
commit 204f343831
4 changed files with 58 additions and 2 deletions

View File

@ -376,14 +376,30 @@ final class Expectation
/**
* Asserts that the value array has the provided $key.
*
* @param string|int $key
*/
public function toHaveKey(string $key): Expectation
public function toHaveKey($key): Expectation
{
Assert::assertArrayHasKey($key, $this->value);
return $this;
}
/**
* Asserts that the value array has the provided $keys.
*
* @param array<int, int|string> $keys
*/
public function toHaveKeys(array $keys): Expectation
{
foreach ($keys as $key) {
$this->toHaveKey($key);
}
return $this;
}
/**
* Asserts that the value is a directory.
*/