- UI Revamp
- Some i18n added/fixed - WIP on a new testing mechanism
This commit is contained in:
1 parent
f5014e1cee
commit
58c61a8f01
76 files changed
+1428
-313
No files matched your search
@@ -45,7 +45,7 @@ class Picea implements FormInterface
|
||||
return $context->valid();
|
||||
}
|
||||
|
||||
public function execute(FormContextInterface $context) : void
|
||||
public function execute(FormContextInterface $context) : mixed
|
||||
{
|
||||
$deleted = $failed = 0;
|
||||
|
||||
@@ -57,6 +57,7 @@ class Picea implements FormInterface
|
||||
}
|
||||
|
||||
if ($deleted) {
|
||||
return true;
|
||||
# $context->pushMessage();
|
||||
}
|
||||
|
||||
|
||||
@@ -23,8 +23,6 @@ class GenerateEntity implements FormInterface
|
||||
|
||||
public function validate(FormContextInterface $context) : bool
|
||||
{
|
||||
|
||||
|
||||
return $context->valid();
|
||||
}
|
||||
|
||||
|
||||
@@ -131,22 +131,27 @@ class Migrate implements FormInterface
|
||||
|
||||
$alter = $context->alterAll ? explode(',', $context->alterAll) : [ $context->alter ];
|
||||
|
||||
foreach(array_filter($alter) as $entity) {
|
||||
if ($this->definition[$entity]['table']->modifier->type === Lib\Database\ModifierTypeEnum::Alter) {
|
||||
$adapter = $entity::resolveEntity()->sqlAdapter()->adapter();
|
||||
try {
|
||||
foreach (array_filter($alter) as $entity) {
|
||||
if ($this->definition[$entity]['table']->modifier->type === Lib\Database\ModifierTypeEnum::Alter) {
|
||||
$adapter = $entity::resolveEntity()->sqlAdapter()->adapter();
|
||||
|
||||
$def = $this->definition[$entity]['columns']->filterAlter();
|
||||
$def = $this->definition[$entity]['columns']->filterAlter();
|
||||
|
||||
if ( $adapter->splitAlterQuery() ) {
|
||||
$def->walk(fn(Lib\Database\Definition $definition) =>
|
||||
$entity::repository()->alterTable([ $definition->toArray() ])
|
||||
);
|
||||
}
|
||||
else {
|
||||
$entity::repository()->alterTable($def->map( fn(Lib\Database\Definition $e) => $e->toArray() ));
|
||||
if ($adapter->splitAlterQuery()) {
|
||||
$def->walk(fn(Lib\Database\Definition $definition) => $entity::repository()->alterTable([$definition->toArray()])
|
||||
);
|
||||
} else {
|
||||
$entity::repository()->alterTable($def->map(fn(Lib\Database\Definition $e) => $e->toArray()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch(\Throwable $t) {
|
||||
$context->pushMessage(
|
||||
Lib\Message::generateError($t->getMessage())
|
||||
);
|
||||
}
|
||||
|
||||
$this->initialize($context);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace Lean\Console\Form\Testing;
|
||||
|
||||
use \Lean\Console\{ Lib, Entity };
|
||||
|
||||
class TestContext extends Lib\FormContext
|
||||
{
|
||||
public string $class;
|
||||
|
||||
public string $name;
|
||||
|
||||
public string $method;
|
||||
}
|
||||
Reference in new issue
Block a user