diff --git a/src/Concerns/Testable.php b/src/Concerns/Testable.php index d43a31fd..1b164b04 100644 --- a/src/Concerns/Testable.php +++ b/src/Concerns/Testable.php @@ -285,12 +285,13 @@ trait Testable $underlyingTest = Reflection::getFunctionVariable($this->__test, 'closure'); $testReflection = new ReflectionFunction($underlyingTest); $requiredParametersCount = $testReflection->getNumberOfRequiredParameters(); + $suppliedParametersCount = count($arguments); - if (count($arguments) >= $requiredParametersCount) { + if ($suppliedParametersCount >= $requiredParametersCount) { return; } - throw new DatasetArgsCountMismatch($this->dataName()); + throw new DatasetArgsCountMismatch($this->dataName(), $requiredParametersCount, $suppliedParametersCount); } /** diff --git a/src/Exceptions/DatasetArgsCountMismatch.php b/src/Exceptions/DatasetArgsCountMismatch.php index 3b34839c..86fcd3f1 100644 --- a/src/Exceptions/DatasetArgsCountMismatch.php +++ b/src/Exceptions/DatasetArgsCountMismatch.php @@ -8,8 +8,8 @@ use Exception; final class DatasetArgsCountMismatch extends Exception { - public function __construct(string $dataName) + public function __construct(string $dataName, int $requiredCount, int $suppliedCount) { - parent::__construct(sprintf('Number of arguments mismatch between test and dataset [%s]', $dataName)); + parent::__construct(sprintf('Test expects %d arguments but dataset [%s] only provides %d', $requiredCount, $dataName, $suppliedCount)); } }