add toBeBetween() expectation

This commit is contained in:
JonPurvis
2023-09-22 01:55:06 +01:00
parent 6bc9da3fe1
commit be0d9e964b
2 changed files with 56 additions and 0 deletions

View File

@ -1128,4 +1128,17 @@ final class Expectation
return $this;
}
/**
* Asserts that the value is between 2 specified values
*
* @return self<TValue>
*/
public function toBeBetween(int|float|DateTimeInterface $lowestValue, int|float|DateTimeInterface $highestValue, string $message = ''): self
{
Assert::assertGreaterThanOrEqual($lowestValue, $this->value, $message);
Assert::assertLessThanOrEqual($highestValue, $this->value, $message);
return $this;
}
}