mirror of
https://github.com/pestphp/pest.git
synced 2026-03-06 15:57:21 +01:00
add toBeIn
This commit is contained in:
@ -371,6 +371,16 @@ final class Expectation
|
|||||||
return $this;
|
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.
|
* Asserts that the value is infinite.
|
||||||
*/
|
*/
|
||||||
|
|||||||
11
tests/Features/Expect/toBeIn.php
Normal file
11
tests/Features/Expect/toBeIn.php
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use PHPUnit\Framework\ExpectationFailedException;
|
||||||
|
|
||||||
|
test('passes', function () {
|
||||||
|
expect('a')->toBeIn(['a', 'b', 'c']);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('failures', function () {
|
||||||
|
expect('d')->toBeIn(['a', 'b', 'c']);
|
||||||
|
})->throws(ExpectationFailedException::class);
|
||||||
Reference in New Issue
Block a user