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);