From 5f574ded814525931c6adc71448437581cdf07b5 Mon Sep 17 00:00:00 2001 From: freek Date: Wed, 28 Jul 2021 00:36:43 +0200 Subject: [PATCH] add toBeIn --- src/Expectation.php | 10 ++++++++++ tests/Features/Expect/toBeIn.php | 11 +++++++++++ 2 files changed, 21 insertions(+) create mode 100644 tests/Features/Expect/toBeIn.php diff --git a/src/Expectation.php b/src/Expectation.php index e41f21d0..2e92434e 100644 --- a/src/Expectation.php +++ b/src/Expectation.php @@ -371,6 +371,16 @@ final class Expectation return $this; } + /** + * Asserts that the value is one of the given values. + */ + public function toBeIn(array $possibleValues): Expectation + { + Assert::assertContains($this->value, $possibleValues); + + return $this; + } + /** * Asserts that the value is infinite. */ diff --git a/tests/Features/Expect/toBeIn.php b/tests/Features/Expect/toBeIn.php new file mode 100644 index 00000000..3d34f46a --- /dev/null +++ b/tests/Features/Expect/toBeIn.php @@ -0,0 +1,11 @@ +toBeIn(['a', 'b', 'c']); +}); + +test('failures', function () { + expect('d')->toBeIn(['a', 'b', 'c']); +})->throws(ExpectationFailedException::class);