mirror of
				https://github.com/kevinveenbirkenbach/infinito.git
				synced 2025-11-03 18:58:01 +00:00 
			
		
		
		
	deleted deprecated code
This commit is contained in:
		@@ -1,51 +0,0 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
namespace Tests\Unit\Domain\FormManagement;
 | 
			
		||||
 | 
			
		||||
use PHPUnit\Framework\TestCase;
 | 
			
		||||
use Infinito\Entity\Source\Primitive\Name\SurnameSource;
 | 
			
		||||
use Infinito\Domain\FormManagement\FormMetaInformationInterface;
 | 
			
		||||
use Infinito\Domain\SourceManagement\SourceMetaInformation;
 | 
			
		||||
use Infinito\Domain\FormManagement\FormMetaInformation;
 | 
			
		||||
use Infinito\Domain\TemplateManagement\TemplatePathInformationInterface;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @author kevinfrantz
 | 
			
		||||
 */
 | 
			
		||||
class FormMetaInformationTest extends TestCase
 | 
			
		||||
{
 | 
			
		||||
    const FORM_CLASS = 'Infinito\Form\Source\Primitive\Name\SurnameType';
 | 
			
		||||
 | 
			
		||||
    const FORM_VIEW_ATOM = 'atom/form/source/primitive/name/surname.html.twig';
 | 
			
		||||
 | 
			
		||||
    const FORM_VIEW_MOLECULE = 'molecule/form/source/primitive/name/surname.html.twig';
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @var FormMetaInformationInterface
 | 
			
		||||
     */
 | 
			
		||||
    private $formMeta;
 | 
			
		||||
 | 
			
		||||
    public function setUp(): void
 | 
			
		||||
    {
 | 
			
		||||
        $sourceMeta = new SourceMetaInformation(new SurnameSource());
 | 
			
		||||
        $this->formMeta = new FormMetaInformation($sourceMeta);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testGetFormClass(): void
 | 
			
		||||
    {
 | 
			
		||||
        $this->assertEquals(self::FORM_CLASS, $this->formMeta->getFormClass());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testGetView(): void
 | 
			
		||||
    {
 | 
			
		||||
        $this->assertEquals(self::FORM_VIEW_ATOM, $this->formMeta->getTemplatePathInformation()->getAtomTemplatePath());
 | 
			
		||||
        $this->assertEquals(self::FORM_VIEW_MOLECULE, $this->formMeta->getTemplatePathInformation()->getMoleculeTemplatePath());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    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,94 +0,0 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
namespace Tests\Unit\Domain\SourceManagement;
 | 
			
		||||
 | 
			
		||||
use PHPUnit\Framework\TestCase;
 | 
			
		||||
use Infinito\Entity\Source\Complex\UserSource;
 | 
			
		||||
use Infinito\Entity\Source\Complex\UserSourceInterface;
 | 
			
		||||
use Infinito\Entity\Source\SourceInterface;
 | 
			
		||||
use Infinito\Domain\SourceManagement\SourceMetaInformation;
 | 
			
		||||
use Infinito\Domain\SourceManagement\SourceMetaInformationInterface;
 | 
			
		||||
use Infinito\Domain\TemplateManagement\TemplatePathFormAndViewInterface;
 | 
			
		||||
use Infinito\Domain\FormManagement\FormMetaInformationInterface;
 | 
			
		||||
use Infinito\Entity\EntityInterface;
 | 
			
		||||
use Infinito\Exception\NotCorrectInstanceException;
 | 
			
		||||
 | 
			
		||||
class SourceMetaInformationTest extends TestCase
 | 
			
		||||
{
 | 
			
		||||
    const FOLDERS = [
 | 
			
		||||
        'source',
 | 
			
		||||
        'complex',
 | 
			
		||||
    ];
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @var SourceMetaInformationInterface
 | 
			
		||||
     */
 | 
			
		||||
    private $sourceMetaInformation;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @var SourceInterface
 | 
			
		||||
     */
 | 
			
		||||
    private $source;
 | 
			
		||||
 | 
			
		||||
    public function setUp(): void
 | 
			
		||||
    {
 | 
			
		||||
        $this->source = new UserSource();
 | 
			
		||||
        $this->sourceMetaInformation = new SourceMetaInformation($this->source);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testBasicName(): void
 | 
			
		||||
    {
 | 
			
		||||
        $this->assertEquals('user', $this->sourceMetaInformation->getPureName());
 | 
			
		||||
        $this->assertNotEquals('user2', $this->sourceMetaInformation->getPureName());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testFolders(): void
 | 
			
		||||
    {
 | 
			
		||||
        $amount = count(self::FOLDERS);
 | 
			
		||||
        $folders = $this->sourceMetaInformation->getNamespacePathMap()->getFolders();
 | 
			
		||||
        for ($index = 0; $index < $amount; ++$index) {
 | 
			
		||||
            $this->assertEquals(self::FOLDERS[$index], $folders[$index]);
 | 
			
		||||
        }
 | 
			
		||||
        $this->assertArraySubset(self::FOLDERS, $folders);
 | 
			
		||||
        $this->assertEquals($amount, count($folders));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testInterfaceReflection(): void
 | 
			
		||||
    {
 | 
			
		||||
        /**
 | 
			
		||||
         * @var \ReflectionClass
 | 
			
		||||
         */
 | 
			
		||||
        $interfaceReflection = $this->sourceMetaInformation->getInterfaceReflection();
 | 
			
		||||
        $this->assertEquals(UserSourceInterface::class, $interfaceReflection->getName());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testSourceReflection(): void
 | 
			
		||||
    {
 | 
			
		||||
        /**
 | 
			
		||||
         * @var \ReflectionClass
 | 
			
		||||
         */
 | 
			
		||||
        $sourceReflection = $this->sourceMetaInformation->getEntityReflection();
 | 
			
		||||
        $this->assertEquals(UserSource::class, $sourceReflection->getName());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testTemplateMeta(): void
 | 
			
		||||
    {
 | 
			
		||||
        $this->assertInstanceOf(TemplatePathFormAndViewInterface::class, $this->sourceMetaInformation->getTemplatePathFormAndView());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testSource(): void
 | 
			
		||||
    {
 | 
			
		||||
        $this->assertEquals($this->source, $this->sourceMetaInformation->getEntity());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testFormMeta(): void
 | 
			
		||||
    {
 | 
			
		||||
        $this->assertInstanceOf(FormMetaInformationInterface::class, $this->sourceMetaInformation->getFormMetaInformation());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testTypeError(): void
 | 
			
		||||
    {
 | 
			
		||||
        $this->expectException(NotCorrectInstanceException::class);
 | 
			
		||||
        new SourceMetaInformation($this->createMock(EntityInterface::class));
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,37 +0,0 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
namespace tests\Unit\Domain\TemplateManagement;
 | 
			
		||||
 | 
			
		||||
use PHPUnit\Framework\TestCase;
 | 
			
		||||
use Infinito\Domain\TemplateManagement\TemplatePathFormAndView;
 | 
			
		||||
use Infinito\DBAL\Types\RESTResponseType;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @author kevinfrantz
 | 
			
		||||
 */
 | 
			
		||||
class TemplatePathFormAndViewTest extends TestCase
 | 
			
		||||
{
 | 
			
		||||
    const FILE = 'hello_world';
 | 
			
		||||
 | 
			
		||||
    const FOLDER = 'folder';
 | 
			
		||||
 | 
			
		||||
    const BASE_PATH = 'atom/view/'.self::FOLDER.'/'.self::FILE.'.';
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @var TemplatePathFormAndView
 | 
			
		||||
     */
 | 
			
		||||
    private $templatePathFormAndView;
 | 
			
		||||
 | 
			
		||||
    public function setUp()
 | 
			
		||||
    {
 | 
			
		||||
        $this->templatePathFormAndView = new TemplatePathFormAndView(self::FILE, self::FOLDER);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testTypeReload(): void
 | 
			
		||||
    {
 | 
			
		||||
        foreach (RESTResponseType::getValues() as $type) {
 | 
			
		||||
            $this->templatePathFormAndView->reloadType($type);
 | 
			
		||||
            $this->assertEquals(self::BASE_PATH.$type.'.twig', $this->templatePathFormAndView->getView()->getAtomTemplatePath());
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,62 +0,0 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
namespace Tests\Unit\Domain\TemplateManagement;
 | 
			
		||||
 | 
			
		||||
use PHPUnit\Framework\TestCase;
 | 
			
		||||
use Infinito\Entity\Source\Primitive\Name\FirstNameSource;
 | 
			
		||||
use Infinito\Entity\Source\SourceInterface;
 | 
			
		||||
use Infinito\Domain\TemplateManagement\TemplatePathInformation;
 | 
			
		||||
use Infinito\Domain\SourceManagement\SourceMetaInformation;
 | 
			
		||||
use Infinito\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 = $sourceMeta->getNamespacePathMap()->getPath();
 | 
			
		||||
        $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::getValues() 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->getCrud());
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user