Compare commits

...

4 Commits

Author SHA1 Message Date
d9d46c73f8 chore: stores statically the result 2026-04-09 21:36:49 +01:00
e44c554a0b chore: bumps dependencies 2026-04-06 21:57:05 +01:00
9797a71dbc feat(ai): allow temporary namesapce 2026-04-03 14:43:28 +01:00
c1a54df233 feat: --ai work in progress 2026-04-03 14:04:20 +01:00
7 changed files with 63 additions and 4 deletions

View File

@ -19,14 +19,14 @@
"require": { "require": {
"php": "^8.3.0", "php": "^8.3.0",
"brianium/paratest": "^7.20.0", "brianium/paratest": "^7.20.0",
"nunomaduro/collision": "^8.9.2", "nunomaduro/collision": "^8.9.3",
"nunomaduro/termwind": "^2.4.0", "nunomaduro/termwind": "^2.4.0",
"pestphp/pest-plugin": "^4.0.0", "pestphp/pest-plugin": "^4.0.0",
"pestphp/pest-plugin-arch": "^4.0.0", "pestphp/pest-plugin-arch": "^4.0.0",
"pestphp/pest-plugin-mutate": "^4.0.1", "pestphp/pest-plugin-mutate": "^4.0.1",
"pestphp/pest-plugin-profanity": "^4.2.1", "pestphp/pest-plugin-profanity": "^4.2.1",
"phpunit/phpunit": "^12.5.16", "phpunit/phpunit": "^12.5.16",
"symfony/process": "^7.4.5|^8.0.8" "symfony/process": "^7.4.8|^8.0.8"
}, },
"conflict": { "conflict": {
"filp/whoops": "<2.18.3", "filp/whoops": "<2.18.3",
@ -57,7 +57,7 @@
"require-dev": { "require-dev": {
"pestphp/pest-dev-tools": "^4.1.0", "pestphp/pest-dev-tools": "^4.1.0",
"pestphp/pest-plugin-browser": "^4.3.0", "pestphp/pest-plugin-browser": "^4.3.0",
"pestphp/pest-plugin-type-coverage": "^4.0.3", "pestphp/pest-plugin-type-coverage": "^4.0.4",
"psy/psysh": "^0.12.22" "psy/psysh": "^0.12.22"
}, },
"minimum-stability": "dev", "minimum-stability": "dev",

View File

@ -59,6 +59,11 @@ final class TestCaseFactory
Concerns\Expectable::class, Concerns\Expectable::class,
]; ];
/**
* The namespace for the test case, overrides the path-based namespace when set.
*/
public ?string $namespace = null;
/** /**
* Creates a new Factory instance. * Creates a new Factory instance.
*/ */
@ -127,7 +132,7 @@ final class TestCaseFactory
$partsFQN = explode('\\', $classFQN); $partsFQN = explode('\\', $classFQN);
$className = array_pop($partsFQN); $className = array_pop($partsFQN);
$namespace = implode('\\', $partsFQN); $namespace = $this->namespace ?? implode('\\', $partsFQN);
$baseClass = sprintf('\%s', $this->class); $baseClass = sprintf('\%s', $this->class);
if (trim($className) === '') { if (trim($className) === '') {

View File

@ -56,4 +56,31 @@ trait HandleArguments
return array_values(array_flip($arguments)); return array_values(array_flip($arguments));
} }
/**
* Pops the given argument and its value from the arguments, returning the value.
*
* @param array<int, string> $arguments
*/
public function popArgumentValue(string $argument, array &$arguments): ?string
{
foreach ($arguments as $key => $value) {
if (str_contains($value, "$argument=")) {
unset($arguments[$key]);
$arguments = array_values($arguments);
return substr($value, strlen($argument) + 1);
}
if ($value === $argument && isset($arguments[$key + 1])) {
$result = $arguments[$key + 1];
unset($arguments[$key], $arguments[$key + 1]);
$arguments = array_values($arguments);
return $result;
}
}
return null;
}
} }

View File

@ -107,6 +107,13 @@ final readonly class Help implements HandlesArguments
'desc' => 'Initialise a standard Pest configuration', 'desc' => 'Initialise a standard Pest configuration',
]], ...$content['Configuration']]; ]], ...$content['Configuration']];
$content['AI'] = [
[
'arg' => '--ai',
'desc' => 'Run a code snippet as a fully scaffolded test for AI verification',
],
];
$content['Execution'] = [...[ $content['Execution'] = [...[
[ [
'arg' => '--parallel', 'arg' => '--parallel',

View File

@ -51,6 +51,11 @@ final class WrapperRunner implements RunnerInterface
/** /**
* The time to sleep between cycles. * The time to sleep between cycles.
*/ */
/**
* The merged test result from the parallel run.
*/
public static ?TestResult $result = null;
private const int CYCLE_SLEEP = 10000; private const int CYCLE_SLEEP = 10000;
/** /**
@ -386,6 +391,8 @@ final class WrapperRunner implements RunnerInterface
$testResultSum->numberOfIssuesIgnoredByBaseline(), $testResultSum->numberOfIssuesIgnoredByBaseline(),
); );
self::$result = $testResultSum;
if ($this->options->configuration->cacheResult()) { if ($this->options->configuration->cacheResult()) {
$resultCacheSum = new DefaultResultCache($this->options->configuration->testResultCacheFile()); $resultCacheSum = new DefaultResultCache($this->options->configuration->testResultCacheFile());
foreach ($this->resultCacheFiles as $resultCacheFile) { foreach ($this->resultCacheFiles as $resultCacheFile) {

View File

@ -113,6 +113,16 @@ final class TestRepository
$this->testCaseMethodFilters[] = $filter; $this->testCaseMethodFilters[] = $filter;
} }
/**
* Gets the class and traits configured for the given directory path.
*
* @return array<int, string>
*/
public function getUsesForPath(string $path): array
{
return $this->uses[$path][0] ?? [];
}
/** /**
* Gets the test case factory from the given filename. * Gets the test case factory from the given filename.
*/ */

View File

@ -147,6 +147,9 @@
--disable-coverage-ignore ...... Disable metadata for ignoring code coverage --disable-coverage-ignore ...... Disable metadata for ignoring code coverage
--no-coverage Ignore code coverage reporting configured in the XML configuration file --no-coverage Ignore code coverage reporting configured in the XML configuration file
AI OPTIONS:
--ai ..... Run a code snippet as a fully scaffolded test for AI verification
MUTATION TESTING OPTIONS: MUTATION TESTING OPTIONS:
--mutate .... Runs mutation testing, to understand the quality of your tests --mutate .... Runs mutation testing, to understand the quality of your tests
--mutate --parallel ...................... Runs mutation testing in parallel --mutate --parallel ...................... Runs mutation testing in parallel