- UI Revamp

- Some i18n added/fixed
- WIP on a new testing mechanism
This commit is contained in:
mcndave committed 2026-11-25 19:18:36 +00:00
1 parent f5014e1cee
commit 58c61a8f01
76 files changed
+1428 -313

No files matched your search

+70
View File
@@ -0,0 +1,70 @@
<?php
namespace Lean\Console\Form\Testing;
use Picea\Ui\Method\{ FormInterface, FormContextInterface };
use Lean\Console\{Attribute\TestParameter, Lib, Entity};
use Ulmus\{ EntityCollection };
use Psr\Container\ContainerInterface;
use Psr\Http\Message\ResponseInterface;
class Test implements FormInterface
{
protected Lib\Testing\TestPreprocessorInterface $waitFor;
protected Lib\Testing\TestFetcherItem $definition;
public function __construct(
protected ContainerInterface $container,
protected Lib\Testing\TestFetcher $testFetcher,
) {}
public function initialize(FormContextInterface $context) : void
{
if ($context->class ?? false) {
$this->definition = $this->testFetcher->compile()[$context->class];
}
}
public function validate(FormContextInterface $context) : bool
{
if (isset($this->definition->attribute) && $this->definition->attribute->waitFor) {
$this->waitFor = new $this->definition->attribute->waitFor();
}
return $context->valid();
}
public function execute(FormContextInterface $context) : mixed
{
if (isset($this->waitFor)) {
$this->waitFor->run();
}
$controller = $this->container->get($context->class);
$test = $this->definition->methods->filtersOne(fn($e) => $e->attribute->name === $context->name);
$request = $context->getRequest()
->withMethod($context->method)
->withAttribute('arguments', $test->attribute->arguments)
->withQueryParams($test->attribute->withQueryParams)
->withParsedBody($test->attribute->withParsedBody);
$arguments = []; # @todo
$result = $controller->{$test->name}($request, $arguments);
return $result;
}
public function attributeCollection(array $collection) : EntityCollection
{
$collection = new EntityCollection(...$collection);
$collection->entityClass = static::class;
return $collection;
}
}