mirror of
				https://github.com/kevinveenbirkenbach/infinito.git
				synced 2025-10-31 17:29:04 +00:00 
			
		
		
		
	In between commit solving tests for meta and template management
This commit is contained in:
		| @@ -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()); | ||||
|         } | ||||
|     } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user