mirror of
https://github.com/kevinveenbirkenbach/infinito.git
synced 2025-01-10 06:27:24 +01:00
In between commit solving tests for meta and template management
This commit is contained in:
parent
6352e82ce1
commit
72d0a6ba95
@ -4,9 +4,10 @@ namespace App\Domain\EntityManagement;
|
|||||||
|
|
||||||
use App\Domain\TemplateManagement\TemplatePathFormAndViewInterface;
|
use App\Domain\TemplateManagement\TemplatePathFormAndViewInterface;
|
||||||
use App\Entity\EntityInterface;
|
use App\Entity\EntityInterface;
|
||||||
use src\Domain\TemplateManagement\TemplatePathFormAndView;
|
use App\Domain\TemplateManagement\TemplatePathFormAndView;
|
||||||
use App\Domain\FormManagement\FormMetaInformationInterface;
|
use App\Domain\FormManagement\FormMetaInformationInterface;
|
||||||
use App\Domain\FormManagement\FormMetaInformation;
|
use App\Domain\FormManagement\FormMetaInformation;
|
||||||
|
use App\Domain\PathManagement\NamespacePathMapInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author kevinfrantz
|
* @author kevinfrantz
|
||||||
@ -36,7 +37,7 @@ class EntityMetaInformation implements EntityMetaInformationInterface
|
|||||||
/**
|
/**
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $pureName;
|
protected $pureName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var EntityInterface
|
* @var EntityInterface
|
||||||
@ -48,6 +49,16 @@ class EntityMetaInformation implements EntityMetaInformationInterface
|
|||||||
*/
|
*/
|
||||||
private $formMetaInformation;
|
private $formMetaInformation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $basicPathString;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var NamespacePathMapInterface
|
||||||
|
*/
|
||||||
|
private $namespacePathMap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param EntityInterface $entity
|
* @param EntityInterface $entity
|
||||||
*/
|
*/
|
||||||
@ -56,12 +67,18 @@ class EntityMetaInformation implements EntityMetaInformationInterface
|
|||||||
$this->entity = $entity;
|
$this->entity = $entity;
|
||||||
$this->entityReflection = new \ReflectionClass($entity);
|
$this->entityReflection = new \ReflectionClass($entity);
|
||||||
$this->setBasicPathArray();
|
$this->setBasicPathArray();
|
||||||
|
$this->setBasicPathString();
|
||||||
$this->setPureName();
|
$this->setPureName();
|
||||||
$this->setInterfaceReflection();
|
$this->setInterfaceReflection();
|
||||||
$this->setTemplatePathFormAndView();
|
$this->setTemplatePathFormAndView();
|
||||||
$this->formMetaInformation = new FormMetaInformation($this);
|
$this->formMetaInformation = new FormMetaInformation($this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function setBasicPathString(): void
|
||||||
|
{
|
||||||
|
$this->basicPathString = implode('/', $this->basicPathArray);
|
||||||
|
}
|
||||||
|
|
||||||
private function setTemplatePathFormAndView(): void
|
private function setTemplatePathFormAndView(): void
|
||||||
{
|
{
|
||||||
$this->templatePathFormAndView = new TemplatePathFormAndView(implode('/', $this->basicPathArray), $this->pureName);
|
$this->templatePathFormAndView = new TemplatePathFormAndView(implode('/', $this->basicPathArray), $this->pureName);
|
||||||
@ -158,4 +175,14 @@ class EntityMetaInformation implements EntityMetaInformationInterface
|
|||||||
{
|
{
|
||||||
return $this->formMetaInformation;
|
return $this->formMetaInformation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*
|
||||||
|
* @see \App\Domain\EntityManagement\EntityMetaInformationInterface::getBasicPathString()
|
||||||
|
*/
|
||||||
|
public function getBasicPathString(): string
|
||||||
|
{
|
||||||
|
return $this->basicPathString;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -47,4 +47,9 @@ interface EntityMetaInformationInterface
|
|||||||
* @return FormMetaInformationInterface The meta informations about the form
|
* @return FormMetaInformationInterface The meta informations about the form
|
||||||
*/
|
*/
|
||||||
public function getFormMetaInformation(): FormMetaInformationInterface;
|
public function getFormMetaInformation(): FormMetaInformationInterface;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getBasicPathString(): string;
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,75 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Domain\PathManagement;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author kevinfrantz
|
||||||
|
*/
|
||||||
|
final class NamespacePathMap implements NamespacePathMapInterface
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var array|string[]
|
||||||
|
*/
|
||||||
|
private $folders;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $namespace;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $path;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*
|
||||||
|
* @see \App\Domain\PathManagement\NamespacePathMapInterface::getNamespace()
|
||||||
|
*/
|
||||||
|
public function getNamespace(): string
|
||||||
|
{
|
||||||
|
return $this->namespace;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*
|
||||||
|
* @see \App\Domain\PathManagement\NamespacePathMapInterface::getPath()
|
||||||
|
*/
|
||||||
|
public function getPath(): string
|
||||||
|
{
|
||||||
|
return $this->path;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*
|
||||||
|
* @see \App\Domain\PathManagement\NamespacePathMapInterface::setPath()
|
||||||
|
*/
|
||||||
|
public function setPath(string $path): void
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*
|
||||||
|
* @see \App\Domain\PathManagement\NamespacePathMapInterface::setNamespace()
|
||||||
|
*/
|
||||||
|
public function setNamespace(string $namespace): void
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*
|
||||||
|
* @see \App\Domain\PathManagement\NamespacePathMapInterface::setFolderArray()
|
||||||
|
*/
|
||||||
|
public function setFolderArray(array $folders): void
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFolderArray(): array
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,41 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Domain\PathManagement;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Allows to map a path to an namespace.
|
||||||
|
*
|
||||||
|
* @author kevinfrantz
|
||||||
|
*/
|
||||||
|
interface NamespacePathMapInterface
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @param string $namespace
|
||||||
|
*/
|
||||||
|
public function setNamespace(string $namespace): void;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $path
|
||||||
|
*/
|
||||||
|
public function setPath(string $path): void;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getNamespace(): string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getPath(): string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array|string[] $folders
|
||||||
|
*/
|
||||||
|
public function setFolderArray(array $folders): void;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array|string[]
|
||||||
|
*/
|
||||||
|
public function getFolderArray(): array;
|
||||||
|
}
|
@ -3,12 +3,30 @@
|
|||||||
namespace App\Domain\SourceManagement;
|
namespace App\Domain\SourceManagement;
|
||||||
|
|
||||||
use App\Domain\EntityManagement\EntityMetaInformation;
|
use App\Domain\EntityManagement\EntityMetaInformation;
|
||||||
|
use App\Entity\Source\AbstractSource;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author kevinfrantz
|
* @author kevinfrantz
|
||||||
*/
|
*/
|
||||||
final class SourceMetaInformation extends EntityMetaInformation implements SourceMetaInformationInterface
|
final class SourceMetaInformation extends EntityMetaInformation implements SourceMetaInformationInterface
|
||||||
{
|
{
|
||||||
|
const UNPURE = 'source';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*
|
||||||
|
* @see \App\Domain\EntityManagement\EntityMetaInformation::__construct()
|
||||||
|
*
|
||||||
|
* @param $entity AbstractSource
|
||||||
|
*/
|
||||||
|
public function __construct(\App\Entity\EntityInterface $entity)
|
||||||
|
{
|
||||||
|
if (!$entity instanceof AbstractSource) {
|
||||||
|
throw new \TypeError('Entity has to be an instance of '.AbstractSource::class);
|
||||||
|
}
|
||||||
|
parent::__construct($entity);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*
|
*
|
||||||
@ -17,6 +35,6 @@ final class SourceMetaInformation extends EntityMetaInformation implements Sourc
|
|||||||
protected function setPureName(): void
|
protected function setPureName(): void
|
||||||
{
|
{
|
||||||
parent::setPureName();
|
parent::setPureName();
|
||||||
$this->pureName = str_replace('Source', '', $this->pureName);
|
$this->pureName = substr($this->pureName, 0, -strlen(self::UNPURE));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,10 @@ use App\DBAL\Types\RESTResponseType;
|
|||||||
*/
|
*/
|
||||||
final class TemplatePathInformation implements TemplatePathInformationInterface
|
final class TemplatePathInformation implements TemplatePathInformationInterface
|
||||||
{
|
{
|
||||||
|
const MOLECULE_FOLDER = 'molecule';
|
||||||
|
|
||||||
|
const ATOM_FOLDER = 'atom';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
@ -73,12 +77,12 @@ final class TemplatePathInformation implements TemplatePathInformationInterface
|
|||||||
|
|
||||||
private function setMoleculeTemplatePath(): void
|
private function setMoleculeTemplatePath(): void
|
||||||
{
|
{
|
||||||
$this->moleculeTemplatePath = 'molecule/'.$this->suffix;
|
$this->moleculeTemplatePath = self::MOLECULE_FOLDER.'/'.$this->prefix.'/'.$this->suffix;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function setAtomTemplatePath(): void
|
private function setAtomTemplatePath(): void
|
||||||
{
|
{
|
||||||
$this->atomTemplatePath = 'atom/'.$this->suffix;
|
$this->atomTemplatePath = self::ATOM_FOLDER.'/'.$this->prefix.'/'.$this->suffix;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -0,0 +1,36 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests\Unit\Domain\FormManagement;
|
||||||
|
|
||||||
|
use PHPUnit\Framework\TestCase;
|
||||||
|
use App\Entity\Source\Primitive\Name\SurnameSource;
|
||||||
|
use App\Domain\FormManagement\FormMetaInformationInterface;
|
||||||
|
use App\Domain\SourceManagement\SourceMetaInformation;
|
||||||
|
use App\Domain\FormManagement\FormMetaInformation;
|
||||||
|
use App\Domain\TemplateManagement\TemplatePathInformationInterface;
|
||||||
|
|
||||||
|
class FormMetaInformationTest extends TestCase
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var FormMetaInformationInterface
|
||||||
|
*/
|
||||||
|
private $formMeta;
|
||||||
|
|
||||||
|
public function setUp(): void
|
||||||
|
{
|
||||||
|
$sourceMeta = new SourceMetaInformation(new SurnameSource());
|
||||||
|
$this->formMeta = new FormMetaInformation($sourceMeta);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testGetFormClass(): void
|
||||||
|
{
|
||||||
|
$this->assertEquals('App\Form\Source\Primitive\Name\SurnameType', $this->formMeta->getFormClass());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testTemplateMeta(): void
|
||||||
|
{
|
||||||
|
$templatePathInformation = $this->formMeta->getTemplatePathInformation();
|
||||||
|
$this->assertInstanceOf(TemplatePathInformationInterface::class, $templatePathInformation);
|
||||||
|
$this->assertEquals('atom/form/source/primitive/name/surname.html.twig', $templatePathInformation->getAtomTemplatePath());
|
||||||
|
}
|
||||||
|
}
|
@ -1,34 +0,0 @@
|
|||||||
<?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());
|
|
||||||
}
|
|
||||||
}
|
|
@ -3,20 +3,20 @@
|
|||||||
namespace Tests\Unit\Domain\SourceManagement;
|
namespace Tests\Unit\Domain\SourceManagement;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
use App\Domain\SourceManagement\SourceMetaInterface;
|
|
||||||
use App\Entity\Source\Complex\UserSource;
|
use App\Entity\Source\Complex\UserSource;
|
||||||
use App\Domain\SourceManagement\SourceMeta;
|
|
||||||
use App\Entity\Source\Complex\UserSourceInterface;
|
use App\Entity\Source\Complex\UserSourceInterface;
|
||||||
use App\Domain\TemplateManagement\TemplateMetaInterface;
|
|
||||||
use App\Entity\Source\SourceInterface;
|
use App\Entity\Source\SourceInterface;
|
||||||
use App\Domain\FormManagement\FormMetaInterface;
|
use App\Domain\SourceManagement\SourceMetaInformation;
|
||||||
|
use App\Domain\SourceManagement\SourceMetaInformationInterface;
|
||||||
|
use App\Domain\TemplateManagement\TemplatePathFormAndViewInterface;
|
||||||
|
use App\Domain\FormManagement\FormMetaInformationInterface;
|
||||||
|
|
||||||
class SourceMetaTest extends TestCase
|
class SourceMetaInformationTest extends TestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var SourceMetaInterface
|
* @var SourceMetaInformationInterface
|
||||||
*/
|
*/
|
||||||
protected $sourceMeta;
|
protected $sourceMetaInformation;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var SourceInterface
|
* @var SourceInterface
|
||||||
@ -26,20 +26,20 @@ class SourceMetaTest extends TestCase
|
|||||||
public function setUp(): void
|
public function setUp(): void
|
||||||
{
|
{
|
||||||
$this->source = new UserSource();
|
$this->source = new UserSource();
|
||||||
$this->sourceMeta = new SourceMeta($this->source);
|
$this->sourceMetaInformation = new SourceMetaInformation($this->source);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testBasicName(): void
|
public function testBasicName(): void
|
||||||
{
|
{
|
||||||
$this->assertEquals('user', $this->sourceMeta->getBasicName());
|
$this->assertEquals('user', $this->sourceMetaInformation->getPureName());
|
||||||
$this->assertNotEquals('user2', $this->sourceMeta->getBasicName());
|
$this->assertNotEquals('user2', $this->sourceMetaInformation->getPureName());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testBasicPath(): void
|
public function testBasicPath(): void
|
||||||
{
|
{
|
||||||
$subset = ['source', 'complex'];
|
$subset = ['source', 'complex'];
|
||||||
$amount = count($subset);
|
$amount = count($subset);
|
||||||
$basicPathArray = $this->sourceMeta->getBasicPathArray();
|
$basicPathArray = $this->sourceMetaInformation->getBasicPathArray();
|
||||||
for ($index = 0; $index < $amount; ++$index) {
|
for ($index = 0; $index < $amount; ++$index) {
|
||||||
$this->assertEquals($subset[$index], $basicPathArray[$index]);
|
$this->assertEquals($subset[$index], $basicPathArray[$index]);
|
||||||
}
|
}
|
||||||
@ -52,7 +52,7 @@ class SourceMetaTest extends TestCase
|
|||||||
/**
|
/**
|
||||||
* @var \ReflectionClass
|
* @var \ReflectionClass
|
||||||
*/
|
*/
|
||||||
$interfaceReflection = $this->sourceMeta->getInterfaceReflection();
|
$interfaceReflection = $this->sourceMetaInformation->getInterfaceReflection();
|
||||||
$this->assertEquals(UserSourceInterface::class, $interfaceReflection->getName());
|
$this->assertEquals(UserSourceInterface::class, $interfaceReflection->getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -61,22 +61,22 @@ class SourceMetaTest extends TestCase
|
|||||||
/**
|
/**
|
||||||
* @var \ReflectionClass
|
* @var \ReflectionClass
|
||||||
*/
|
*/
|
||||||
$sourceReflection = $this->sourceMeta->getSourceReflection();
|
$sourceReflection = $this->sourceMetaInformation->getEntityReflection();
|
||||||
$this->assertEquals(UserSource::class, $sourceReflection->getName());
|
$this->assertEquals(UserSource::class, $sourceReflection->getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testTemplateMeta(): void
|
public function testTemplateMeta(): void
|
||||||
{
|
{
|
||||||
$this->assertInstanceOf(TemplateMetaInterface::class, $this->sourceMeta->getTemplateMeta());
|
$this->assertInstanceOf(TemplatePathFormAndViewInterface::class, $this->sourceMetaInformation->getTemplatePathFormAndView());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSource(): void
|
public function testSource(): void
|
||||||
{
|
{
|
||||||
$this->assertEquals($this->source, $this->sourceMeta->getSource());
|
$this->assertEquals($this->source, $this->sourceMetaInformation->getEntity());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testFormMeta(): void
|
public function testFormMeta(): void
|
||||||
{
|
{
|
||||||
$this->assertInstanceOf(FormMetaInterface::class, $this->sourceMeta->getFormMeta());
|
$this->assertInstanceOf(FormMetaInformationInterface::class, $this->sourceMetaInformation->getFormMetaInformation());
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,53 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Tests\Unit\Domain\TemplateManagement;
|
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
|
||||||
use App\Domain\TemplateManagement\TemplateMetaInterface;
|
|
||||||
use App\Entity\Source\Primitive\Name\FirstNameSource;
|
|
||||||
use App\Entity\Source\SourceInterface;
|
|
||||||
use App\Domain\TemplateManagement\TemplateMeta;
|
|
||||||
use App\Domain\SourceManagement\SourceMeta;
|
|
||||||
|
|
||||||
class TemplateMetaTest extends TestCase
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @var TemplateMetaInterface
|
|
||||||
*/
|
|
||||||
protected $templateMeta;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var SourceInterface
|
|
||||||
*/
|
|
||||||
protected $source;
|
|
||||||
|
|
||||||
private function getExpectedPath(string $type, string $context): string
|
|
||||||
{
|
|
||||||
return $context.'/entity/source/primitive/name/firstname.'.$type.'.twig';
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setUp(): void
|
|
||||||
{
|
|
||||||
$this->source = new FirstNameSource();
|
|
||||||
$sourceMeta = new SourceMeta($this->source);
|
|
||||||
$this->templateMeta = new TemplateMeta($sourceMeta->getBasicPathArray(), $sourceMeta->getBasicName(), 'entity');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testFrameTemplatePath(): void
|
|
||||||
{
|
|
||||||
$this->assertEquals($this->getExpectedPath('html', 'frame'), $this->templateMeta->getFrameTemplatePath());
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testContentTemplatePath(): void
|
|
||||||
{
|
|
||||||
$this->assertEquals($this->getExpectedPath('html', 'content'), $this->templateMeta->getContentTemplatePath());
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testSetType(): void
|
|
||||||
{
|
|
||||||
$this->templateMeta->setTemplateType('json');
|
|
||||||
$this->assertEquals($this->getExpectedPath('json', 'content'), $this->templateMeta->getContentTemplatePath());
|
|
||||||
$this->assertEquals($this->getExpectedPath('json', 'frame'), $this->templateMeta->getFrameTemplatePath());
|
|
||||||
$this->assertEquals('json', $this->templateMeta->getTemplateType());
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,62 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests\Unit\Domain\TemplateManagement;
|
||||||
|
|
||||||
|
use PHPUnit\Framework\TestCase;
|
||||||
|
use App\Entity\Source\Primitive\Name\FirstNameSource;
|
||||||
|
use App\Entity\Source\SourceInterface;
|
||||||
|
use App\Domain\TemplateManagement\TemplatePathInformation;
|
||||||
|
use App\Domain\SourceManagement\SourceMetaInformation;
|
||||||
|
use App\DBAL\Types\RESTResponseType;
|
||||||
|
|
||||||
|
class TemplatePathInformationTest extends TestCase
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var TemplatePathInformation
|
||||||
|
*/
|
||||||
|
private $templateMeta;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var SourceInterface
|
||||||
|
*/
|
||||||
|
private $source;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $type
|
||||||
|
* @param string $context
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
private function getExpectedPath(string $type, string $context): string
|
||||||
|
{
|
||||||
|
return $context.'/entity/source/primitive/name/firstname.'.$type.'.twig';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setUp(): void
|
||||||
|
{
|
||||||
|
$this->source = new FirstNameSource();
|
||||||
|
$sourceMeta = new SourceMetaInformation($this->source);
|
||||||
|
$folder = implode('/', $sourceMeta->getBasicPathArray());
|
||||||
|
$this->templateMeta = new TemplatePathInformation($sourceMeta->getPureName(), $folder, 'entity');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testFrameTemplatePath(): void
|
||||||
|
{
|
||||||
|
$this->assertEquals($this->getExpectedPath('html', 'molecule'), $this->templateMeta->getMoleculeTemplatePath());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testContentTemplatePath(): void
|
||||||
|
{
|
||||||
|
$this->assertEquals($this->getExpectedPath('html', 'atom'), $this->templateMeta->getAtomTemplatePath());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testSetType(): void
|
||||||
|
{
|
||||||
|
foreach (RESTResponseType::getChoices() as $type) {
|
||||||
|
$this->templateMeta->reloadType($type);
|
||||||
|
$this->assertEquals($this->getExpectedPath($type, 'atom'), $this->templateMeta->getAtomTemplatePath());
|
||||||
|
$this->assertEquals($this->getExpectedPath($type, 'molecule'), $this->templateMeta->getMoleculeTemplatePath());
|
||||||
|
$this->assertEquals($type, $this->templateMeta->getTemplateType());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user