CompileFormFromXML($sXMLContent); $this->AssertPHPCodeIsValid($sProducedPHP); $sMessage = $this->dataName(); $this->assertEquals($sExpectedPHP, $sProducedPHP, $sMessage); } public function CompileFormFromXMLProvider() { return [ 'Basic scalar properties should generate PHP' => [ 'sXMLContent' => << XML, 'sExpectedPHP' => <<Add('title_property', 'Combodo\iTop\Forms\Block\DataModel\LabelFormBlock', [ 'label' => 'UI:BasicTest:Prop-Title', ]); \$this->Add('class_property', 'Combodo\iTop\Forms\Block\Base\TextFormBlock', [ 'label' => 'UI:BasicTest:Prop-Class', ]); } } PHP, ], 'Empty property tree should generate minimal PHP' => [ 'sXMLContent' => << XML, 'sExpectedPHP' => << [ 'sXMLContent' => << XML, 'sExpectedPHP' => << [ 'sXMLContent' => << XML, 'sExpectedPHP' => <<Add('aggregate_function_property', 'Combodo\iTop\Forms\Block\DataModel\Dashlet\AggregateFunctionFormBlock', [ 'label' => 'UI:AggregateFunction', ]); \$this->Add('choice_property', 'Combodo\iTop\Forms\Block\Base\ChoiceFormBlock', [ 'label' => 'UI:Choice', ]); \$this->Add('class_property', 'Combodo\iTop\Forms\Block\Base\TextFormBlock', [ 'label' => 'UI:Class', ]); \$this->Add('class_attribute_property', 'Combodo\iTop\Forms\Block\DataModel\AttributeChoiceFormBlock', [ 'label' => 'UI:ClassAttribute', ]); \$this->Add('class_attribute_group_by_property', 'Combodo\iTop\Forms\Block\DataModel\Dashlet\ClassAttributeGroupByFormBlock', [ 'label' => 'UI:ClassAttributeGroupBy', ]); \$this->Add('class_attribute_value_property', 'Combodo\iTop\Forms\Block\DataModel\AttributeValueChoiceFormBlock', [ 'label' => 'UI:ClassAttributeValue', ]); \$this->Add('integer_property', 'Combodo\iTop\Forms\Block\Base\IntegerFormBlock', [ 'label' => 'UI:Integer', ]); \$this->Add('label_property', 'Combodo\iTop\Forms\Block\DataModel\LabelFormBlock', [ 'label' => 'UI:Label', ]); \$this->Add('oql_property', 'Combodo\iTop\Forms\Block\DataModel\OqlFormBlock', [ 'label' => 'UI:OQL', ]); \$this->Add('string_property', 'Combodo\iTop\Forms\Block\Base\TextFormBlock', [ 'label' => 'UI:String', ]); } } PHP, ], 'Collection of trees' => [ 'sXMLContent' => << UI:AddSubTree XML, 'sExpectedPHP' => <<Add('string_property', 'Combodo\iTop\Forms\Block\Base\TextFormBlock', [ 'label' => 'UI:String', ]); \$this->Add('integer_property', 'Combodo\iTop\Forms\Block\Base\IntegerFormBlock', [ 'label' => 'UI:Integer', ]); } } class FormFor__collection_of_trees_test extends Combodo\iTop\Forms\Block\Base\FormBlock { protected function BuildForm(): void { \$this->Add('collection_of_trees_test__sub_tree_collection', 'Combodo\iTop\Forms\Block\Base\CollectionBlock', [ 'label' => 'UI:SubTree', 'button_label' => 'UI:AddSubTree', 'block_entry_type' => 'SubFormFor__collection_of_trees_test__sub_tree_collection', ]); } } PHP, ], 'Input static' => [ 'sXMLContent' => << Contact Test XML, 'sExpectedPHP' => <<Add('class_attribute_property', 'Combodo\iTop\Forms\Block\DataModel\AttributeChoiceFormBlock', [ 'label' => 'UI:ClassAttribute', ]) ->SetInputValue('class', 'Contact'); } } PHP, ], 'Input binding' => [ 'sXMLContent' => << {{class_property.text}} XML, 'sExpectedPHP' => <<Add('class_property', 'Combodo\iTop\Forms\Block\Base\TextFormBlock', [ 'label' => 'UI:Class', ]); \$this->Add('class_attribute_property', 'Combodo\iTop\Forms\Block\DataModel\AttributeChoiceFormBlock', [ 'label' => 'UI:ClassAttribute', ]) ->InputDependsOn('class', 'class_property', 'text'); } } PHP, ], 'Relevance condition' => [ 'sXMLContent' => << source_property.text != 'count' XML, 'sExpectedPHP' => <<Add('source_property', 'Combodo\iTop\Forms\Block\Base\TextFormBlock', [ 'label' => 'UI:Source', ]); \$this->Add('dependant_property_relevance_condition', 'Combodo\iTop\Forms\Block\Expression\BooleanExpressionFormBlock', [ 'expression' => "source_property.text != 'count'", ]) ->AddInputDependsOn('source_property.text', 'source_property', 'text'); \$this->Add('dependant_property', 'Combodo\iTop\Forms\Block\Base\TextFormBlock', [ 'label' => 'UI:Dependant', ]) ->InputDependsOn('visible', 'dependant_property_relevance_condition', 'result'); } } PHP, ], 'test' => [ 'sXMLContent' => << XML, 'sExpectedPHP' => <<