Fixes test suite

This commit is contained in:
Nuno Maduro
2024-04-27 11:36:22 +01:00
parent f49d1e0e18
commit cfa00da885
15 changed files with 161 additions and 51 deletions

View File

@ -20,12 +20,12 @@ final class BootOverrides implements Bootstrapper
public const FILES = [
'4f57b79c6ca77cab241cef879ea98bc743d2cd1fbe4586ab652608bf29aa4176' => 'Runner/Filter/NameFilterIterator.php',
'c7c09ab7c9378710b27f761a4b2948196cbbdf2a73e4389bcdca1e7c94fa9c21' => 'Runner/ResultCache/DefaultResultCache.php',
'bc8718c89264f65800beabc23e51c6d3bcff87dfc764a12179ef5dbfde272c8b' => 'Runner/TestSuiteLoader.php',
'6c23c8455e135328ca89b54ac2dfe9ba3d6ce23f9e080928752dbee2de93f0eb' => 'Runner/TestSuiteLoader.php',
'2ef8e21dbb27cf6597dd9bb0f941c063dcc98b5af2c35d10b1c2d77721582e8f' => 'TextUI/Command/Commands/WarmCodeCoverageCacheCommand.php',
'badc88c79c2a47d768be3925051999b158d08b64e57ccf4ce560f1610cbcc1e8' => 'TextUI/Output/Default/ProgressPrinter/Subscriber/TestSkippedSubscriber.php',
'5ff38e143e244c4d80e767447e5a045891cc6518f008f24f2bb945289b83a07f' => 'TextUI/TestSuiteFilterProcessor.php',
'a01a02eadd18146f12731c7adb8cd56cf76f3f6bda2bae06ff4fd6573789b0f4' => 'Event/Value/ThrowableBuilder.php',
'c78f96e34b98ed01dd8106539d59b8aa8d67f733274118b827c01c5c4111c033' => 'Logging/JUnit/JunitXmlLogger.php',
'354137e9f9489633cab805c1f1de4023f84c90e4cdfb36ac9bdc0c321dd7078d' => 'Logging/JUnit/JunitXmlLogger.php',
];
/**

View File

@ -334,10 +334,11 @@ trait Testable
fn (ReflectionParameter $reflectionParameter): string => $reflectionParameter->getName(),
array_filter($testReflection->getParameters(), fn (ReflectionParameter $reflectionParameter): bool => ! $reflectionParameter->isOptional()),
);
if (
(count(array_diff($testParameterNames, $datasetParameterNames)) === 0) || isset($testParameterNames[0])
&& $suppliedParametersCount >= $requiredParametersCount) {
if (array_diff($testParameterNames, $datasetParameterNames) === []) {
return;
}
if (isset($testParameterNames[0])
&& $suppliedParametersCount >= $requiredParametersCount) {
return;
}

View File

@ -13,6 +13,8 @@ final class Attributes
{
/**
* Evaluates the given attributes and returns the code.
*
* @param iterable<int, Attribute> $attributes
*/
public static function code(iterable $attributes): string
{
@ -23,9 +25,9 @@ final class Attributes
return " #[\\{$name}]";
}
$arguments = array_map(fn (string $argument): string => var_export($argument, true), $attribute->arguments);
$arguments = array_map(fn (string $argument): string => var_export($argument, true), iterator_to_array($attribute->arguments));
return sprintf(' #[\\%s(%s)]', $name, implode(', ', $arguments));
}, $attributes));
}, iterator_to_array($attributes)));
}
}

View File

@ -11,7 +11,7 @@ final class DatasetArgumentsMismatch extends Exception
public function __construct(int $requiredCount, int $suppliedCount)
{
if ($requiredCount <= $suppliedCount) {
parent::__construct(sprintf('Test argument names and dataset keys do not match'));
parent::__construct('Test argument names and dataset keys do not match');
} else {
parent::__construct(sprintf('Test expects %d arguments but dataset only provides %d', $requiredCount, $suppliedCount));
}

View File

@ -12,7 +12,7 @@ final class Attribute
/**
* @param iterable<int, string> $arguments
*/
public function __construct(public string $name, public iterable $arguments = [])
public function __construct(public string $name, public iterable $arguments)
{
//
}

View File

@ -29,9 +29,9 @@ final class TestCaseFactory
/**
* The list of attributes.
*
* @var iterable<int, Attribute>
* @var array<int, Attribute>
*/
public iterable $attributes = [];
public array $attributes = [];
/**
* The FQN of the Test Case class.

View File

@ -25,7 +25,7 @@ final class TestCaseMethodFactory
/**
* The list of attributes.
*
* @var array<int, class-string<Attribute>>
* @var array<int, Attribute>
*/
public array $attributes = [];
@ -95,6 +95,7 @@ final class TestCaseMethodFactory
$testCase = TestSuite::getInstance()->tests->get($this->filename);
assert($testCase instanceof TestCaseFactory);
$testCase->factoryProxies->proxy($concrete);
$this->factoryProxies->proxy($concrete);