From 37c40cb7350585191651ce9b29054654b40ec4c5 Mon Sep 17 00:00:00 2001 From: Erik Gaal Date: Tue, 3 Oct 2023 10:55:57 +0200 Subject: [PATCH] Add `toContainEquals` expectation --- src/Mixins/Expectation.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/Mixins/Expectation.php b/src/Mixins/Expectation.php index e42fc96a..4473f553 100644 --- a/src/Mixins/Expectation.php +++ b/src/Mixins/Expectation.php @@ -196,6 +196,21 @@ final class Expectation return $this; } + /** + * Asserts that $needle equals an element of the value. + * + * @return self + */ + public function toContainEquals(mixed ...$needles): self + { + foreach ($needles as $needle) { + if (! is_iterable($this->value)) { + InvalidExpectationValue::expected('iterable'); + } + Assert::assertContainsEquals($needle, $this->value); + } + } + /** * Asserts that the value starts with $expected. *