mirror of
https://github.com/pestphp/pest.git
synced 2026-03-07 08:17:22 +01:00
Merge branch 'master' into method-match
This commit is contained in:
@ -219,6 +219,26 @@ final class Expectation
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* It skips the tests in the callback if the condition is not truthy.
|
||||
*
|
||||
* @param Closure|bool|string $condition
|
||||
*/
|
||||
public function when($condition, callable $callback): Expectation
|
||||
{
|
||||
$condition = is_callable($condition)
|
||||
? $condition
|
||||
: function () use ($condition) {
|
||||
return $condition;
|
||||
};
|
||||
|
||||
if ($condition()) {
|
||||
$callback(new self($this->value));
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Asserts that two variables have the same type and
|
||||
|
||||
Reference in New Issue
Block a user