mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-25 11:38:44 +02:00
N°8772 - test driven compiler wip
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2025 Combodo SAS
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
*/
|
||||
|
||||
use Combodo\iTop\Forms\Compiler\FormsCompiler;
|
||||
use Combodo\iTop\Test\UnitTest\ItopDataTestCase;
|
||||
|
||||
class TestFormsCompiler extends ItopDataTestCase
|
||||
{
|
||||
public function testCompileFormFromXML()
|
||||
{
|
||||
$sXMLContent = <<<XML
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<node id="DashletTest" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="Combodo-PropertyTree">
|
||||
<nodes>
|
||||
<node id="title" xsi:type="Combodo-Property">
|
||||
<label>UI:DashletTest:Prop-Title</label>
|
||||
<value-type xsi:type="Combodo-ValueTypeLabel">
|
||||
</value-type>
|
||||
</node>
|
||||
<node id="class" xsi:type="Combodo-Property">
|
||||
<label>UI:DashletTest:Prop-Class</label>
|
||||
<value-type xsi:type="Combodo-ValueTypeClass">
|
||||
</value-type>
|
||||
</node>
|
||||
</nodes>
|
||||
</node>
|
||||
XML;
|
||||
|
||||
$sExpectedPHP = <<<PHP
|
||||
class FormForDashletTest extends Combodo\iTop\Forms\Block\Base\FormBlock
|
||||
{
|
||||
protected function BuildForm(): void
|
||||
{
|
||||
\$this->Add('title', 'Combodo\iTop\Forms\Block\DataModel\LabelFormBlock', [
|
||||
'label' => 'UI:DashletTest:Prop-Title',
|
||||
]);
|
||||
|
||||
\$this->Add('class', 'Combodo\iTop\Forms\Block\Base\TextFormBlock', [
|
||||
'label' => 'UI:DashletTest:Prop-Class',
|
||||
]);
|
||||
}
|
||||
}
|
||||
PHP;
|
||||
|
||||
$sProducedPHP = FormsCompiler::GetInstance()->CompileFormFromXML($sXMLContent);
|
||||
eval($sProducedPHP);
|
||||
$this->assertEquals($sExpectedPHP, $sProducedPHP);
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user