mirror of
https://github.com/pestphp/pest.git
synced 2026-03-06 15:57:21 +01:00
Feature: Introducing The Ability to Dump Conditionally
This commit is contained in:
@ -118,6 +118,48 @@ final class Expectation
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Dump the expectation value when the result of the condition is truthy.
|
||||
*
|
||||
* @param bool $boolean
|
||||
* @return never
|
||||
*/
|
||||
public function ddWhen($boolean, mixed ...$arguments): void
|
||||
{
|
||||
if (! $boolean) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (function_exists('dd')) {
|
||||
dd($this->value, ...$arguments);
|
||||
}
|
||||
|
||||
var_dump($this->value);
|
||||
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Dump the expectation value when the result of the condition is falsy.
|
||||
*
|
||||
* @param bool $boolean
|
||||
* @return never
|
||||
*/
|
||||
public function ddUnless($boolean, mixed ...$arguments): void
|
||||
{
|
||||
if ($boolean) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (function_exists('dd')) {
|
||||
dd($this->value, ...$arguments);
|
||||
}
|
||||
|
||||
var_dump($this->value);
|
||||
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send the expectation value to Ray along with all given arguments.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user