mirror of
https://github.com/pestphp/pest.git
synced 2026-03-11 02:07:23 +01:00
start covers attribute implementation
This commit is contained in:
@ -5,6 +5,7 @@ declare(strict_types=1);
|
||||
namespace Pest\PendingCalls;
|
||||
|
||||
use Closure;
|
||||
use InvalidArgumentException;
|
||||
use Pest\Factories\TestCaseMethodFactory;
|
||||
use Pest\Support\Backtrace;
|
||||
use Pest\Support\HigherOrderCallables;
|
||||
@ -168,6 +169,25 @@ final class TestCall
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the covered class and method.
|
||||
*/
|
||||
public function covers(string|array ...$classes): TestCall
|
||||
{
|
||||
foreach ($classes as $i => $class) {
|
||||
if (is_array($class) && count($class) !== 2) {
|
||||
throw new InvalidArgumentException(sprintf(
|
||||
'The #%s covered class must be an array with exactly 2 items: class and method name.',
|
||||
$i
|
||||
));
|
||||
}
|
||||
|
||||
$this->testCaseMethod->covers[] = $class;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves the property accessors to be used on the target.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user