CompileFormFromXML($sXMLContent); $this->AssertPHPCodeIsValid($sProducedPHP); $this->assertEquals($sExpectedPHP, $sProducedPHP, $sMessage); } public function CompileFormFromXMLProvider() { return [ 'Basic properties' => [ '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, 'sMessage' => 'Basic scalar properties should generate PHP', ], 'Empty property tree' => [ 'sXMLContent' => << XML, 'sExpectedPHP' => << 'Empty property tree should generate minimal PHP', ], 'Empty property tree lower case' => [ 'sXMLContent' => << XML, 'sExpectedPHP' => << 'Empty property tree should generate minimal PHP', ], 'Properties with all value-types' => [ '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, 'sMessage' => '', ], '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, 'sMessage' => '', ], 'Input static' => [ 'sXMLContent' => << Contact XML, 'sExpectedPHP' => <<Add('class_attribute_property', 'Combodo\iTop\Forms\Block\DataModel\AttributeChoiceFormBlock', [ 'label' => 'UI:ClassAttribute', ]) ->SetInputValue('class', 'Contact'); } } PHP, 'sMessage' => '', ], 'test' => [ 'sXMLContent' => << XML, 'sExpectedPHP' => << '', ], ]; } }