Merge pull request #974 from erikgaal/expect-to-contain-equals

[2.x] Add `toContainEquals` expectation
This commit is contained in:
Nuno Maduro
2024-01-25 14:38:55 +00:00
committed by GitHub
2 changed files with 54 additions and 0 deletions

View File

@ -196,6 +196,24 @@ final class Expectation
return $this;
}
/**
* Asserts that $needle equal an element of the value.
*
* @return self<TValue>
*/
public function toContainEqual(mixed ...$needles): self
{
if (! is_iterable($this->value)) {
InvalidExpectationValue::expected('iterable');
}
foreach ($needles as $needle) {
Assert::assertContainsEquals($needle, $this->value);
}
return $this;
}
/**
* Asserts that the value starts with $expected.
*