mirror of
https://github.com/kevinveenbirkenbach/infinito.git
synced 2025-01-09 14:07:25 +01:00
Optimized FormMeta and Tests
This commit is contained in:
parent
2009f1b691
commit
926eb0c3fb
@ -8,6 +8,8 @@ use App\Domain\TemplateManagement\TemplateMeta;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @author kevinfrantz
|
* @author kevinfrantz
|
||||||
|
*
|
||||||
|
* @todo Optimize contructor parameter!
|
||||||
*/
|
*/
|
||||||
class FormMeta implements FormMetaInterface
|
class FormMeta implements FormMetaInterface
|
||||||
{
|
{
|
||||||
@ -37,7 +39,11 @@ class FormMeta implements FormMetaInterface
|
|||||||
|
|
||||||
private function setFormClass(): void
|
private function setFormClass(): void
|
||||||
{
|
{
|
||||||
$this->formClass = 'App\\Form\\'.implode('\\', $this->sourceMeta->getBasicPathArray()).'\\'.$this->sourceMeta->getBasicName().'Type';
|
$this->formClass = 'App\\Form';
|
||||||
|
foreach ($this->sourceMeta->getBasicPathArray() as $element) {
|
||||||
|
$this->formClass .= '\\'.ucfirst($element);
|
||||||
|
}
|
||||||
|
$this->formClass .= '\\'.ucfirst($this->sourceMeta->getBasicName()).'Type';
|
||||||
}
|
}
|
||||||
|
|
||||||
private function setMeta(): void
|
private function setMeta(): void
|
||||||
@ -50,7 +56,7 @@ class FormMeta implements FormMetaInterface
|
|||||||
return $this->formClass;
|
return $this->formClass;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getTemplateMeta(): string
|
public function getTemplateMeta(): TemplateMetaInterface
|
||||||
{
|
{
|
||||||
return $this->templateMeta;
|
return $this->templateMeta;
|
||||||
}
|
}
|
||||||
|
@ -2,9 +2,11 @@
|
|||||||
|
|
||||||
namespace App\Domain\FormManagement;
|
namespace App\Domain\FormManagement;
|
||||||
|
|
||||||
|
use App\Domain\TemplateManagement\TemplateMetaInterface;
|
||||||
|
|
||||||
interface FormMetaInterface
|
interface FormMetaInterface
|
||||||
{
|
{
|
||||||
public function getFormClass(): string;
|
public function getFormClass(): string;
|
||||||
|
|
||||||
public function getTemplateMeta(): string;
|
public function getTemplateMeta(): TemplateMetaInterface;
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,8 @@ use App\Domain\FormManagement\FormMeta;
|
|||||||
*/
|
*/
|
||||||
class SourceMeta implements SourceMetaInterface
|
class SourceMeta implements SourceMetaInterface
|
||||||
{
|
{
|
||||||
|
const FOLDER = 'entity';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var \ReflectionClass
|
* @var \ReflectionClass
|
||||||
*/
|
*/
|
||||||
@ -55,10 +57,15 @@ class SourceMeta implements SourceMetaInterface
|
|||||||
$this->setBasicPathArray();
|
$this->setBasicPathArray();
|
||||||
$this->setBasicName();
|
$this->setBasicName();
|
||||||
$this->setInterfaceReflection();
|
$this->setInterfaceReflection();
|
||||||
$this->templateMeta = new TemplateMeta($this->basicPathArray, $this->basicName, 'entity');
|
$this->setTemplateMeta();
|
||||||
$this->formMeta = new FormMeta($this);
|
$this->formMeta = new FormMeta($this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function setTemplateMeta(): void
|
||||||
|
{
|
||||||
|
$this->templateMeta = new TemplateMeta($this->basicPathArray, $this->basicName, self::FOLDER);
|
||||||
|
}
|
||||||
|
|
||||||
private function setBasicPathArray(): void
|
private function setBasicPathArray(): void
|
||||||
{
|
{
|
||||||
$namespace = $this->sourceReflection->getNamespaceName();
|
$namespace = $this->sourceReflection->getNamespaceName();
|
||||||
|
@ -94,9 +94,4 @@ class TemplateMeta implements TemplateMetaInterface
|
|||||||
{
|
{
|
||||||
return $this->type;
|
return $this->type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPathSuffix(): string
|
|
||||||
{
|
|
||||||
return $this->pathSuffix;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
34
application/tests/Unit/Domain/FormMetaTest.php
Normal file
34
application/tests/Unit/Domain/FormMetaTest.php
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests\Unit\Domain;
|
||||||
|
|
||||||
|
use PHPUnit\Framework\TestCase;
|
||||||
|
use App\Domain\FormManagement\FormMetaInterface;
|
||||||
|
use App\Domain\FormManagement\FormMeta;
|
||||||
|
use App\Entity\Source\Primitive\Name\SurnameSource;
|
||||||
|
use App\Domain\SourceManagement\SourceMeta;
|
||||||
|
use App\Domain\TemplateManagement\TemplateMetaInterface;
|
||||||
|
|
||||||
|
class FormMetaTest extends TestCase
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var FormMetaInterface
|
||||||
|
*/
|
||||||
|
protected $formMeta;
|
||||||
|
|
||||||
|
public function setUp(): void
|
||||||
|
{
|
||||||
|
$sourceMeta = new SourceMeta(new SurnameSource());
|
||||||
|
$this->formMeta = new FormMeta($sourceMeta);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testGetFormClass(): void
|
||||||
|
{
|
||||||
|
$this->assertEquals('App\Form\Source\Primitive\Name\SurnameType', $this->formMeta->getFormClass());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testTemplateMeta(): void
|
||||||
|
{
|
||||||
|
$this->assertInstanceOf(TemplateMetaInterface::class, $this->formMeta->getTemplateMeta());
|
||||||
|
}
|
||||||
|
}
|
@ -9,6 +9,7 @@ use App\Domain\SourceManagement\SourceMeta;
|
|||||||
use App\Entity\Source\Complex\UserSourceInterface;
|
use App\Entity\Source\Complex\UserSourceInterface;
|
||||||
use App\Domain\TemplateManagement\TemplateMetaInterface;
|
use App\Domain\TemplateManagement\TemplateMetaInterface;
|
||||||
use App\Entity\Source\SourceInterface;
|
use App\Entity\Source\SourceInterface;
|
||||||
|
use App\Domain\FormManagement\FormMetaInterface;
|
||||||
|
|
||||||
class SourceMetaTest extends TestCase
|
class SourceMetaTest extends TestCase
|
||||||
{
|
{
|
||||||
@ -73,4 +74,9 @@ class SourceMetaTest extends TestCase
|
|||||||
{
|
{
|
||||||
$this->assertEquals($this->source, $this->sourceMeta->getSource());
|
$this->assertEquals($this->source, $this->sourceMeta->getSource());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testFormMeta(): void
|
||||||
|
{
|
||||||
|
$this->assertInstanceOf(FormMetaInterface::class, $this->sourceMeta->getFormMeta());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user