mirror of
https://github.com/pestphp/pest.git
synced 2026-03-09 09:17:23 +01:00
Higher Order Tests now resolve callable expectations. The tap method now always returns the test case.
This commit is contained in:
@ -7,15 +7,15 @@ namespace Pest\PendingObjects;
|
||||
use Closure;
|
||||
use Pest\Factories\TestCaseFactory;
|
||||
use Pest\Support\Backtrace;
|
||||
use Pest\Support\HigherOrderCallables;
|
||||
use Pest\Support\NullClosure;
|
||||
use Pest\TestSuite;
|
||||
use SebastianBergmann\Exporter\Exporter;
|
||||
|
||||
/*
|
||||
* @mixin \Pest\Support\HigherOrderCallables
|
||||
* @method \Pest\Expectations\Expectation expect(mixed $value)
|
||||
*
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @mixin HigherOrderCallables
|
||||
*/
|
||||
final class TestCall
|
||||
{
|
||||
|
||||
@ -81,7 +81,6 @@ final class Coverage implements AddsOutput, HandlesArguments
|
||||
}
|
||||
|
||||
if ($input->getOption(self::MIN_OPTION) !== null) {
|
||||
/* @phpstan-ignore-next-line */
|
||||
$this->coverageMin = (float) $input->getOption(self::MIN_OPTION);
|
||||
}
|
||||
|
||||
|
||||
@ -4,6 +4,8 @@ declare(strict_types=1);
|
||||
|
||||
namespace Pest\Support;
|
||||
|
||||
use Pest\Expectation;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
@ -19,6 +21,34 @@ final class HigherOrderCallables
|
||||
$this->target = $target;
|
||||
}
|
||||
|
||||
/**
|
||||
* @template TValue
|
||||
*
|
||||
* Create a new expectation. Callable values will be executed prior to returning the new expectation.
|
||||
*
|
||||
* @param callable|TValue $value
|
||||
*
|
||||
* @return Expectation<TValue>
|
||||
*/
|
||||
public function expect($value)
|
||||
{
|
||||
return new Expectation(is_callable($value) ? Reflection::bindCallable($value) : $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @template TValue
|
||||
*
|
||||
* Create a new expectation. Callable values will be executed prior to returning the new expectation.
|
||||
*
|
||||
* @param callable|TValue $value
|
||||
*
|
||||
* @return Expectation<TValue>
|
||||
*/
|
||||
public function and($value)
|
||||
{
|
||||
return $this->expect($value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @template TValue
|
||||
*
|
||||
@ -28,6 +58,8 @@ final class HigherOrderCallables
|
||||
*/
|
||||
public function tap(callable $callable)
|
||||
{
|
||||
return Reflection::bindCallable($callable) ?? $this->target;
|
||||
Reflection::bindCallable($callable);
|
||||
|
||||
return $this->target;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user