Merge remote-tracking branch 'origin/support/3.0' into develop

# Conflicts:
#	test/sources/application/Helper/WebResourcesHelperTest.php
#	tests/php-unit-tests/ItopTestCase.php
#	tests/php-unit-tests/composer.lock
#	tests/php-unit-tests/unitary-tests/.make/release/DatamodelsXmlFilesTest.php
#	tests/php-unit-tests/unitary-tests/application/UI/Base/Layout/NavigationMenuTest.php
#	tests/php-unit-tests/unitary-tests/application/query/QueryTest.php
#	tests/php-unit-tests/unitary-tests/core/DBSearchTest.php
#	tests/php-unit-tests/unitary-tests/datamodels/2.x/itop-config/BulkChangeExtKeyTest.inc.php
#	tests/php-unit-tests/unitary-tests/datamodels/2.x/itop-config/CRUD/DBObjectTest.php
#	tests/php-unit-tests/unitary-tests/service/EventTest.php
#	tests/php-unit-tests/unitary-tests/setup/iTopDesignFormat/Convert-samples/3.0_to_3.1.expected.xml
#	tests/php-unit-tests/unitary-tests/setup/iTopDesignFormat/Convert-samples/3.0_to_3.1.input.xml
#	tests/php-unit-tests/unitary-tests/setup/iTopDesignFormat/Convert-samples/3.1_to_3.0.expected.xml
#	tests/php-unit-tests/unitary-tests/setup/iTopDesignFormat/Convert-samples/3.1_to_3.0.input.xml
#	tests/php-unit-tests/unitary-tests/sources/Application/Helper/WebResourcesHelperTest.php
#	tests/php-unit-tests/unitary-tests/sources/Router/RouterTest.php
#	tests/php-unit-tests/unitary-tests/sources/application/Helper/WebResourcesHelperTest.php
#	tests/php-unit-tests/unitary-tests/webservices/ImportTest.inc.php
#	tests/php-unit-tests/unitary-tests/webservices/RestTest.php
This commit is contained in:
Molkobain
2023-01-11 15:55:08 +01:00
253 changed files with 946 additions and 1446 deletions

View File

@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<itop_design xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.6">
<menus>
<menu id="WelcomeMenuLink1" xsi:type="WebPageMenuNode" _delta="define">
<rank>100</rank>
<parent>WelcomeMenu</parent>
<url>$$http://fr.wikipedia.org/</url>
</menu>
<menu id="WelcomeMenuLink2" xsi:type="WebPageMenuNode" _delta="define">
<rank>100</rank>
<parent>WelcomeMenu</parent>
<url>$$http://fr.wikipedia.org/</url>
</menu>
</menus>
</itop_design>

View File

@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<itop_design xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.7">
<menus>
<menu id="WelcomeMenuLink1" xsi:type="WebPageMenuNode" _delta="define">
<rank>100</rank>
<parent>WelcomeMenu</parent>
<url>$$http://fr.wikipedia.org/</url>
<in_new_window>true</in_new_window>
</menu>
<menu id="WelcomeMenuLink2" xsi:type="WebPageMenuNode" _delta="define">
<rank>100</rank>
<parent>WelcomeMenu</parent>
<url>$$http://fr.wikipedia.org/</url>
</menu>
</menus>
</itop_design>

View File

@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<itop_design xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.7">
<branding _revision_id="180">
<main_logo _revision_id="53" _delta="define">
<fileref ref="smile_portal_logo_7417a491754f12f744ac6311525e4db3" _revision_id="116"/>
</main_logo>
<login_logo _revision_id="53" _delta="define">
<fileref ref="smile_portal_logo_7417a491754f12f744ac6311525e4db3" _revision_id="116"/>
</login_logo>
<portal_logo _revision_id="53" _delta="define">
<fileref ref="smile_portal_logo_7417a491754f12f744ac6311525e4db3" _revision_id="116"/>
</portal_logo>
</branding>
<constants>
<constant id="RESPONSE_TICKET_SLT_QUERY" xsi:type="string" _created_in="itop-tickets" _revision_id="19" _delta="redefine"><![CDATA[SELECT slt FROM Organization AS child JOIN Organization AS root ON child.parent_id BELOW root.id JOIN CustomerContract AS cc ON cc.org_id=root.id JOIN lnkCustomerContractToService AS l1 ON l1.customercontract_id=cc.id JOIN SLA AS sla ON l1.sla_id=sla.id JOIN lnkSLAToSLT AS l2 ON l2.sla_id=sla.id JOIN SLT AS slt ON l2.slt_id=slt.id WHERE slt.metric = :metric AND l1.service_id = :this->service_id AND child.id= :this->org_id AND slt.request_type = :request_type AND slt.priority = :this->priority]]></constant>
</constants>
</itop_design>

View File

@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<itop_design xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.6">
<branding _revision_id="180">
<main_logo _revision_id="53" _delta="define">
<fileref ref="smile_portal_logo_7417a491754f12f744ac6311525e4db3" _revision_id="116"/>
</main_logo>
<login_logo _revision_id="53" _delta="define">
<fileref ref="smile_portal_logo_7417a491754f12f744ac6311525e4db3" _revision_id="116"/>
</login_logo>
<portal_logo _revision_id="53" _delta="define">
<fileref ref="smile_portal_logo_7417a491754f12f744ac6311525e4db3" _revision_id="116"/>
</portal_logo>
</branding>
<constants>
<constant id="RESPONSE_TICKET_SLT_QUERY" xsi:type="string" _created_in="itop-tickets" _revision_id="19" _delta="redefine"><![CDATA[SELECT slt FROM Organization AS child JOIN Organization AS root ON child.parent_id BELOW root.id JOIN CustomerContract AS cc ON cc.org_id=root.id JOIN lnkCustomerContractToService AS l1 ON l1.customercontract_id=cc.id JOIN SLA AS sla ON l1.sla_id=sla.id JOIN lnkSLAToSLT AS l2 ON l2.sla_id=sla.id JOIN SLT AS slt ON l2.slt_id=slt.id WHERE slt.metric = :metric AND l1.service_id = :this->service_id AND child.id= :this->org_id AND slt.request_type = :request_type AND slt.priority = :this->priority]]></constant>
<constant id="PORTAL_SERVICECATEGORY_QUERY" xsi:type="string" _created_in="itop-tickets" _revision_id="19" _delta="redefine"><![CDATA[SELECT s FROM Organization AS child JOIN Organization AS root ON child.parent_id BELOW root.id JOIN CustomerContract AS cc ON cc.org_id = root.id JOIN lnkCustomerContractToService AS l1 ON l1.customercontract_id=cc.id JOIN Service AS s ON l1.service_id=s.id WHERE child.id = :org_id AND s.status != 'obsolete' UNION SELECT Service AS s JOIN lnkCustomerContractToService AS l1 ON l1.service_id=s.id JOIN CustomerContract AS cc ON l1.customercontract_id=cc.id WHERE cc.org_id = :org_id AND s.status != 'obsolete']]></constant>
<constant id="PORTAL_VALIDATE_SERVICECATEGORY_QUERY" xsi:type="string" _created_in="itop-tickets" _revision_id="19" _delta="redefine"><![CDATA[SELECT s FROM Organization AS child JOIN Organization AS root ON child.parent_id BELOW root.id JOIN CustomerContract AS cc ON cc.org_id = root.id JOIN lnkCustomerContractToService AS l1 ON l1.customercontract_id=cc.id JOIN Service AS s ON l1.service_id=s.id WHERE child.id = :org_id AND s.id = :id AND s.status != 'obsolete' UNION SELECT Service AS s JOIN lnkCustomerContractToService AS l1 ON l1.service_id=s.id JOIN CustomerContract AS cc ON l1.customercontract_id=cc.id WHERE cc.org_id = :org_id AND s.id = :id AND s.status != 'obsolete']]></constant>
</constants>
</itop_design>

View File

@@ -0,0 +1,94 @@
<?xml version="1.0" encoding="UTF-8"?>
<itop_design xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.7">
<branding>
<themes>
<theme id="test-red" _delta="define">
<variables>
<variable id="backoffice-environment-banner-background-color">#C53030</variable>
<variable id="var1">#C53030</variable>
</variables>
<imports>
<import id="scss-variables">../css/scss-variables.scss</import>
<import id="css-variables">../css/css-variables.scss</import>
</imports>
<stylesheets>
<stylesheet id="custom">../css/custom.scss</stylesheet>
<stylesheet id="jqueryui">../css/ui-lightness/jqueryui.scss</stylesheet>
<stylesheet id="main">../css/main.scss</stylesheet>
</stylesheets>
</theme>
<theme id="light-grey">
<variables/>
<imports>
<import id="css-variables">../css/css-variables.scss</import>
</imports>
<stylesheets>
<stylesheet id="jqueryui">../css/ui-lightness/jqueryui.scss</stylesheet>
<stylesheet id="main">../css/light-grey.scss</stylesheet>
</stylesheets>
</theme>
</themes>
</branding>
<classes>
<class id="ClassWithStateButNoLifecycle">
<properties>
<icon>images/class-with-lifecycle.png</icon>
</properties>
</class>
<class id="ClassWithStateAndLifecycle">
<properties>
<icon>images/class-with-lifecycle.png</icon>
</properties>
<lifecycle>
<attribute>foo</attribute>
</lifecycle>
</class>
<class id="ClassWithStateAndImage">
<properties>
<icon>images/class-with-lifecycle.png</icon>
</properties>
</class>
<class id="ClassWithImageOnly">
<properties>
<icon>images/class-with-lifecycle.png</icon>
</properties>
</class>
<class id="OtherClass">
<properties>
<icon revisionid="2" _delta="redefine">
<fileref ref="company_0faae3b9d86b7c382b2e4cdae570bc3c" revisionid="62"/>
</icon>
</properties>
<fields>
<field id="status" xsi:type="AttributeEnum">
<always_load_in_tables>true</always_load_in_tables>
<values>
<value id="new">new</value>
<value id="waiting_for_approval">waiting_for_approval</value>
</values>
</field>
<field id="operational_status" xsi:type="AttributeMetaEnum">
<values>
<value id="ongoing">ongoing</value>
<value id="resolved">resolved</value>
</values>
</field>
</fields>
</class>
</classes>
<menus>
<menu id="WelcomeMenuLink1" xsi:type="WebPageMenuNode" _delta="define">
<rank>100</rank>
<parent>WelcomeMenu</parent>
<url>$$http://fr.wikipedia.org/</url>
<in_new_window>true</in_new_window>
</menu>
<menu id="RequestManagement" xsi:type="MenuGroup" _delta="define">
<rank>30</rank>
<enable_stimulus/>
</menu>
</menus>
<branding>
<main_logo _delta="define">images/itop-logo.png</main_logo>
</branding>
</itop_design>

View File

@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<itop_design xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.6">
<menus>
<menu id="WelcomeMenuLink1" xsi:type="WebPageMenuNode" _delta="define">
<rank>100</rank>
<parent>WelcomeMenu</parent>
<url>$$http://fr.wikipedia.org/</url>
</menu>
<menu id="WelcomeMenuLink2" xsi:type="WebPageMenuNode" _delta="define">
<rank>100</rank>
<parent>WelcomeMenu</parent>
<url>$$http://fr.wikipedia.org/</url>
</menu>
</menus>
<branding/>
</itop_design>

View File

@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<itop_design xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.7">
<menus>
<menu id="WelcomeMenuLink1" xsi:type="WebPageMenuNode" _delta="define">
<rank>100</rank>
<parent>WelcomeMenu</parent>
<url>$$http://fr.wikipedia.org/</url>
<in_new_window>true</in_new_window>
</menu>
<menu id="WelcomeMenuLink2" xsi:type="WebPageMenuNode" _delta="define">
<rank>100</rank>
<parent>WelcomeMenu</parent>
<url>$$http://fr.wikipedia.org/</url>
</menu>
</menus>
<branding>
<themes>
<theme id="light-grey">
<variables>
<variable id="foo" _delta="define">bar</variable>
</variables>
</theme>
</themes>
</branding>
</itop_design>

View File

@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<itop_design xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.6">
<branding _revision_id="180">
<main_logo _revision_id="53" _delta="define">
<fileref ref="smile_portal_logo_7417a491754f12f744ac6311525e4db3" _revision_id="116"/>
</main_logo>
<login_logo _revision_id="53" _delta="define">
<fileref ref="smile_portal_logo_7417a491754f12f744ac6311525e4db3" _revision_id="116"/>
</login_logo>
<portal_logo _revision_id="53" _delta="define">
<fileref ref="smile_portal_logo_7417a491754f12f744ac6311525e4db3" _revision_id="116"/>
</portal_logo>
</branding>
<constants>
<constant id="RESPONSE_TICKET_SLT_QUERY" xsi:type="string" _created_in="itop-tickets" _revision_id="19" _delta="redefine"><![CDATA[SELECT slt FROM Organization AS child JOIN Organization AS root ON child.parent_id BELOW root.id JOIN CustomerContract AS cc ON cc.org_id=root.id JOIN lnkCustomerContractToService AS l1 ON l1.customercontract_id=cc.id JOIN SLA AS sla ON l1.sla_id=sla.id JOIN lnkSLAToSLT AS l2 ON l2.sla_id=sla.id JOIN SLT AS slt ON l2.slt_id=slt.id WHERE slt.metric = :metric AND l1.service_id = :this->service_id AND child.id= :this->org_id AND slt.request_type = :request_type AND slt.priority = :this->priority]]></constant>
</constants>
</itop_design>

View File

@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<itop_design xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.7">
<branding _revision_id="180">
<main_logo _revision_id="53" _delta="define">
<fileref ref="smile_portal_logo_7417a491754f12f744ac6311525e4db3" _revision_id="116"/>
</main_logo>
<login_logo _revision_id="53" _delta="define">
<fileref ref="smile_portal_logo_7417a491754f12f744ac6311525e4db3" _revision_id="116"/>
</login_logo>
<portal_logo _revision_id="53" _delta="define">
<fileref ref="smile_portal_logo_7417a491754f12f744ac6311525e4db3" _revision_id="116"/>
</portal_logo>
</branding>
<constants>
<constant id="RESPONSE_TICKET_SLT_QUERY" xsi:type="string" _created_in="itop-tickets" _revision_id="19" _delta="redefine"><![CDATA[SELECT slt FROM Organization AS child JOIN Organization AS root ON child.parent_id BELOW root.id JOIN CustomerContract AS cc ON cc.org_id=root.id JOIN lnkCustomerContractToService AS l1 ON l1.customercontract_id=cc.id JOIN SLA AS sla ON l1.sla_id=sla.id JOIN lnkSLAToSLT AS l2 ON l2.sla_id=sla.id JOIN SLT AS slt ON l2.slt_id=slt.id WHERE slt.metric = :metric AND l1.service_id = :this->service_id AND child.id= :this->org_id AND slt.request_type = :request_type AND slt.priority = :this->priority]]></constant>
</constants>
</itop_design>

View File

@@ -0,0 +1,122 @@
<?xml version="1.0" encoding="UTF-8"?>
<itop_design xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="3.0">
<branding>
<themes>
<theme id="test-red" _delta="define">
<variables>
<variable id="ibo-page-banner--background-color">#C53030</variable>
<variable id="var1">#C53030</variable>
</variables>
<imports>
<import id="css-variables" xsi:type="utilities">../css/css-variables.scss</import>
<import id="scss-variables" xsi:type="utilities">../css/scss-variables.scss</import>
</imports>
<stylesheets>
<stylesheet id="jqueryui">../css/ui-lightness/jqueryui.scss</stylesheet>
<stylesheet id="main">../css/main.scss</stylesheet>
<stylesheet id="custom">../css/custom.scss</stylesheet>
</stylesheets>
</theme>
<theme id="light-grey">
<variables/>
<imports>
<import id="css-variables" xsi:type="utilities">../css/css-variables.scss</import>
</imports>
<stylesheets>
<stylesheet id="jqueryui">../css/ui-lightness/jqueryui.scss</stylesheet>
<stylesheet id="main">../css/light-grey.scss</stylesheet>
</stylesheets>
</theme>
</themes>
</branding>
<classes>
<class id="ClassWithNewValueInFieldWhichHasNoXsiTypeDueToMustExistFlag" _delta="must_exist">
<fields>
<field id="status" _delta="must_exist">
<values>
<value id="test" _delta="define">
<code>test</code>
</value>
</values>
</field>
</fields>
</class>
<class id="ClassWithLifecycle">
<properties>
<fields_semantic>
<state_attribute>foo</state_attribute>
</fields_semantic>
<style>
<icon>images/class-with-lifecycle.png</icon>
</style>
</properties>
<lifecycle/>
</class>
<class id="ClassWithLifecycleNoProperties">
<lifecycle/>
<properties>
<fields_semantic>
<state_attribute>foo</state_attribute>
</fields_semantic>
</properties>
</class>
<class id="OtherClass">
<properties>
<style>
<icon revisionid="2" _delta="redefine">
<fileref ref="company_0faae3b9d86b7c382b2e4cdae570bc3c" revisionid="62"/>
</icon>
</style>
</properties>
<fields>
<field id="status" xsi:type="AttributeEnum">
<always_load_in_tables>true</always_load_in_tables>
<values>
<value id="new">
<code>new</code>
</value>
<value id="assigned">
<code>assigned</code>
</value>
</values>
<sql>status</sql>
<default_value>new</default_value>
<is_null_allowed>false</is_null_allowed>
</field>
<field id="operational_status" xsi:type="AttributeMetaEnum">
<values>
<value id="ongoing">
<code>ongoing</code>
</value>
<value id="resolved">
<code>resolved</code>
</value>
<value id="closed">
<code>closed</code>
</value>
</values>
<sql>operational_status</sql>
<default_value>ongoing</default_value>
<mappings>
<mapping id="Ticket">
<attcode>status</attcode>
<metavalues>
<metavalue id="resolved">
<values>
<value id="resolved"/>
</values>
</metavalue>
<metavalue id="closed">
<values>
<value id="closed"/>
<value id="rejected"/>
</values>
</metavalue>
</metavalues>
</mapping>
</mappings>
</field>
</fields>
</class>
</classes>
</itop_design>

View File

@@ -0,0 +1,102 @@
<?xml version="1.0" encoding="UTF-8"?>
<itop_design xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.7">
<branding>
<themes>
<theme id="test-red" _delta="define">
<variables>
<variable id="backoffice-environment-banner-background-color">#C53030</variable>
<variable id="var1">#C53030</variable>
</variables>
<imports>
<import id="css-variables">../css/css-variables.scss</import>
<import id="scss-variables">../css/scss-variables.scss</import>
</imports>
<stylesheets>
<stylesheet id="jqueryui">../css/ui-lightness/jqueryui.scss</stylesheet>
<stylesheet id="main">../css/main.scss</stylesheet>
<stylesheet id="custom">../css/custom.scss</stylesheet>
</stylesheets>
</theme>
<theme id="light-grey">
<variables/>
<imports>
<import id="css-variables">../css/css-variables.scss</import>
</imports>
<stylesheets>
<stylesheet id="jqueryui">../css/ui-lightness/jqueryui.scss</stylesheet>
<stylesheet id="main">../css/light-grey.scss</stylesheet>
</stylesheets>
</theme>
</themes>
</branding>
<classes>
<class id="ClassWithNewValueInFieldWhichHasNoXsiTypeDueToMustExistFlag" _delta="must_exist">
<fields>
<field id="status" _delta="must_exist">
<values>
<value id="test" _delta="define">test</value>
</values>
</field>
</fields>
</class>
<class id="ClassWithLifecycle">
<properties>
<icon>images/class-with-lifecycle.png</icon>
</properties>
<lifecycle>
<attribute>foo</attribute>
</lifecycle>
</class>
<class id="ClassWithLifecycleNoProperties">
<lifecycle>
<attribute>foo</attribute>
</lifecycle>
</class>
<class id="OtherClass">
<properties>
<icon revisionid="2" _delta="redefine">
<fileref ref="company_0faae3b9d86b7c382b2e4cdae570bc3c" revisionid="62"/>
</icon>
</properties>
<fields>
<field id="status" xsi:type="AttributeEnum">
<always_load_in_tables>true</always_load_in_tables>
<values>
<value id="new">new</value>
<value id="assigned">assigned</value>
</values>
<sql>status</sql>
<default_value>new</default_value>
<is_null_allowed>false</is_null_allowed>
</field>
<field id="operational_status" xsi:type="AttributeMetaEnum">
<values>
<value id="ongoing">ongoing</value>
<value id="resolved">resolved</value>
<value id="closed">closed</value>
</values>
<sql>operational_status</sql>
<default_value>ongoing</default_value>
<mappings>
<mapping id="Ticket">
<attcode>status</attcode>
<metavalues>
<metavalue id="resolved">
<values>
<value id="resolved"/>
</values>
</metavalue>
<metavalue id="closed">
<values>
<value id="closed"/>
<value id="rejected"/>
</values>
</metavalue>
</metavalues>
</mapping>
</mappings>
</field>
</fields>
</class>
</classes>
</itop_design>

View File

@@ -0,0 +1,122 @@
<?xml version="1.0" encoding="UTF-8"?>
<itop_design xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.7">
<branding>
<themes>
<theme id="test-red" _delta="define">
<variables>
<variable id="backoffice-environment-banner-background-color">#C53030</variable>
<variable id="var1">#C53030</variable>
</variables>
<imports>
<import id="scss-variables">../css/scss-variables.scss</import>
</imports>
<stylesheets>
<stylesheet id="custom">../css/custom.scss</stylesheet>
</stylesheets>
</theme>
</themes>
</branding>
<classes>
<class id="ClassWithStateButNoLifecycle">
<properties>
<icon>images/class-with-lifecycle.png</icon>
</properties>
</class>
<class id="ClassWithStateAndLifecycle">
<properties>
<icon>images/class-with-lifecycle.png</icon>
</properties>
<lifecycle>
<attribute>foo</attribute>
</lifecycle>
</class>
<class id="ClassWithStateAndImage">
<properties>
<icon>images/class-with-lifecycle.png</icon>
</properties>
</class>
<class id="ClassWithImageOnly">
<properties>
<icon>images/class-with-lifecycle.png</icon>
</properties>
</class>
<class id="OtherClass">
<properties>
<icon revisionid="2" _delta="redefine">
<fileref ref="company_0faae3b9d86b7c382b2e4cdae570bc3c" revisionid="62"/>
</icon>
</properties>
<fields>
<field id="status" xsi:type="AttributeEnum">
<always_load_in_tables>true</always_load_in_tables>
<values>
<value id="new">new</value>
<value id="waiting_for_approval">waiting_for_approval</value>
</values>
</field>
<field id="operational_status" xsi:type="AttributeMetaEnum">
<values>
<value id="ongoing">ongoing</value>
<value id="resolved">resolved</value>
</values>
</field>
</fields>
</class>
</classes>
<menus>
<menu id="WelcomeMenuLink1" xsi:type="WebPageMenuNode" _delta="define">
<rank>100</rank>
<parent>WelcomeMenu</parent>
<url>$$http://fr.wikipedia.org/</url>
<in_new_window>true</in_new_window>
</menu>
<menu id="RequestManagement" xsi:type="MenuGroup" _delta="define">
<rank>30</rank>
<enable_stimulus/>
</menu>
</menus>
<branding>
<main_logo _delta="define">images/itop-logo.png</main_logo>
</branding>
<meta>
<previous_versions>
<previous_version_1_7>
<trashed_nodes>
<trashed_node id="XXX">
<parent_xpath>/itop_design/branding/themes</parent_xpath>
<node_tree>
<theme id="light-grey">
<variables/>
<imports>
<import id="css-variables">../css/css-variables.scss</import>
</imports>
<stylesheets>
<stylesheet id="jqueryui">../css/ui-lightness/jqueryui.scss</stylesheet>
<stylesheet id="main">../css/light-grey.scss</stylesheet>
</stylesheets>
</theme>
</node_tree>
</trashed_node>
<trashed_node id="XXX">
<parent_xpath>/itop_design/branding/themes/theme[@id="test-red"]/imports</parent_xpath>
<node_tree>
<import id="css-variables">../css/css-variables.scss</import>
</node_tree>
</trashed_node>
<trashed_node id="XXX">
<parent_xpath>/itop_design/branding/themes/theme[@id="test-red"]/stylesheets</parent_xpath>
<node_tree>
<stylesheet id="jqueryui">../css/ui-lightness/jqueryui.scss</stylesheet>
</node_tree>
</trashed_node>
<trashed_node id="XXX">
<parent_xpath>/itop_design/branding/themes/theme[@id="test-red"]/stylesheets</parent_xpath>
<node_tree>
<stylesheet id="main">../css/main.scss</stylesheet>
</node_tree>
</trashed_node>
</trashed_nodes>
</previous_version_1_7>
</previous_versions>
</meta>
</itop_design>

View File

@@ -0,0 +1,177 @@
<?xml version="1.0" encoding="UTF-8"?>
<itop_design xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="3.0">
<branding>
<themes>
<theme id="test-red" _delta="define">
<variables>
<variable id="ibo-page-banner--background-color">#C53030</variable>
<variable id="var1">#C53030</variable>
</variables>
<imports>
<import id="scss-variables" xsi:type="utilities">../css/scss-variables.scss</import>
</imports>
<stylesheets>
<stylesheet id="custom">../css/custom.scss</stylesheet>
</stylesheets>
</theme>
</themes>
</branding>
<classes>
<class id="ClassWithStateButNoLifecycle">
<properties>
<style>
<icon>images/class-with-lifecycle.png</icon>
</style>
<fields_semantic>
<state_attribute>foo</state_attribute>
</fields_semantic>
</properties>
</class>
<class id="ClassWithStateAndLifecycle">
<properties>
<style>
<icon>images/class-with-lifecycle.png</icon>
</style>
<fields_semantic>
<state_attribute>foo</state_attribute>
</fields_semantic>
</properties>
<lifecycle/>
</class>
<class id="ClassWithStateAndImage">
<properties>
<style>
<icon>images/class-with-lifecycle.png</icon>
</style>
<fields_semantic>
<state_attribute>foo</state_attribute>
<image_attribute>bar</image_attribute>
</fields_semantic>
</properties>
</class>
<class id="ClassWithImageOnly">
<properties>
<style>
<icon>images/class-with-lifecycle.png</icon>
</style>
<fields_semantic>
<image_attribute>bar</image_attribute>
</fields_semantic>
</properties>
</class>
<class id="OtherClass">
<properties>
<style>
<icon revisionid="2" _delta="redefine">
<fileref ref="company_0faae3b9d86b7c382b2e4cdae570bc3c" revisionid="62"/>
</icon>
<main_color>#4E79A5</main_color>
<complementary_color>white</complementary_color>
</style>
</properties>
<fields>
<field id="status" xsi:type="AttributeEnum">
<always_load_in_tables>true</always_load_in_tables>
<values>
<value id="new">
<code>new</code>
<style>
<main_color>#2C5382</main_color>
<complementary_color>#FFFFFF</complementary_color>
<decoration_classes/>
</style>
</value>
<value id="waiting_for_approval">
<code>waiting_for_approval</code>
</value>
</values>
<default_style>
<main_color>#2B6CB0</main_color>
<complementary_color>#FFFFFF</complementary_color>
<decoration_classes/>
</default_style>
</field>
<field id="operational_status" xsi:type="AttributeMetaEnum">
<values>
<value id="ongoing">
<code>ongoing</code>
<style>
<main_color>#2C5382</main_color>
<complementary_color>#FFFFFF</complementary_color>
<decoration_classes/>
</style>
</value>
<value id="resolved">
<code>resolved</code>
</value>
</values>
<default_style>
<main_color>#2B6CB0</main_color>
<complementary_color>#FFFFFF</complementary_color>
<decoration_classes/>
</default_style>
</field>
</fields>
</class>
</classes>
<menus>
<menu id="WelcomeMenuLink1" xsi:type="WebPageMenuNode" _delta="define">
<rank>100</rank>
<parent>WelcomeMenu</parent>
<url>$$http://fr.wikipedia.org/</url>
<in_new_window>true</in_new_window>
</menu>
<menu id="RequestManagement" xsi:type="MenuGroup" _delta="define">
<rank>30</rank>
<enable_stimulus/>
<style>
<decoration_classes>fas fa-comment-alt</decoration_classes>
</style>
</menu>
</menus>
<branding>
<main_logo _delta="define">images/itop-logo.png</main_logo>
<main_logo_compact _delta="define">images/itop-logo-square.png</main_logo_compact>
</branding>
<meta>
<previous_versions>
<previous_version_1_7>
<trashed_nodes>
<trashed_node id="1">
<parent_xpath>/itop_design/branding/themes</parent_xpath>
<node_tree>
<theme id="light-grey">
<variables/>
<imports>
<import id="css-variables">../css/css-variables.scss</import>
</imports>
<stylesheets>
<stylesheet id="jqueryui">../css/ui-lightness/jqueryui.scss</stylesheet>
<stylesheet id="main">../css/light-grey.scss</stylesheet>
</stylesheets>
</theme>
</node_tree>
</trashed_node>
<trashed_node id="2">
<parent_xpath>/itop_design/branding/themes/theme[@id="test-red"]/imports</parent_xpath>
<node_tree>
<import id="css-variables">../css/css-variables.scss</import>
</node_tree>
</trashed_node>
<trashed_node id="3">
<parent_xpath>/itop_design/branding/themes/theme[@id="test-red"]/stylesheets</parent_xpath>
<node_tree>
<stylesheet id="jqueryui">../css/ui-lightness/jqueryui.scss</stylesheet>
</node_tree>
</trashed_node>
<trashed_node id="4">
<parent_xpath>/itop_design/branding/themes/theme[@id="test-red"]/stylesheets</parent_xpath>
<node_tree>
<stylesheet id="main">../css/main.scss</stylesheet>
</node_tree>
</trashed_node>
</trashed_nodes>
</previous_version_1_7>
</previous_versions>
</meta>
</itop_design>

View File

@@ -0,0 +1,66 @@
<?xml version="1.0" encoding="UTF-8"?>
<itop_design xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="3.1">
<classes>
<class id="ClassWithAttributeLinkedSetEditModeNone">
<fields>
<field id="status" xsi:type="AttributeLinkedSet">
<legacy_edit_mode>none</legacy_edit_mode>
<relation_type>link</relation_type>
<read_only>true</read_only>
</field>
</fields>
</class>
<class id="ClassWithAttributeLinkedSetEditModeAddOnly">
<fields>
<field id="status" xsi:type="AttributeLinkedSet">
<legacy_edit_mode>add_only</legacy_edit_mode>
<relation_type>link</relation_type>
<read_only>false</read_only>
</field>
</fields>
</class>
<class id="ClassWithAttributeLinkedSetEditModeAddRemove">
<fields>
<field id="status" xsi:type="AttributeLinkedSet">
<legacy_edit_mode>add_remove</legacy_edit_mode>
<relation_type>link</relation_type>
<read_only>false</read_only>
</field>
</fields>
</class>
<class id="ClassWithAttributeLinkedSetEditModeActions">
<fields>
<field id="status" xsi:type="AttributeLinkedSet">
<legacy_edit_mode>actions</legacy_edit_mode>
<relation_type>link</relation_type>
<read_only>false</read_only>
</field>
</fields>
</class>
<class id="ClassWithAttributeLinkedSetEditModeInPlace">
<fields>
<field id="status" xsi:type="AttributeLinkedSet">
<legacy_edit_mode>in_place</legacy_edit_mode>
<relation_type>property</relation_type>
<read_only>false</read_only>
</field>
</fields>
</class>
<class id="ClassWithAttributeLinkedSetNoEditMode">
<fields>
<field id="status" xsi:type="AttributeLinkedSet">
<linked_class>Ticket</linked_class>
<relation_type>link</relation_type>
<read_only>false</read_only>
</field>
</fields>
</class>
<class id="ClassWithAttributeLinkedSetIndirect">
<fields>
<field id="status" xsi:type="AttributeLinkedSetIndirect">
<read_only>false</read_only>
</field>
</fields>
</class>
</classes>
</itop_design>

View File

@@ -0,0 +1,52 @@
<?xml version="1.0" encoding="UTF-8"?>
<itop_design xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="3.0">
<classes>
<class id="ClassWithAttributeLinkedSetEditModeNone">
<fields>
<field id="status" xsi:type="AttributeLinkedSet">
<edit_mode>none</edit_mode>
</field>
</fields>
</class>
<class id="ClassWithAttributeLinkedSetEditModeAddOnly">
<fields>
<field id="status" xsi:type="AttributeLinkedSet">
<edit_mode>add_only</edit_mode>
</field>
</fields>
</class>
<class id="ClassWithAttributeLinkedSetEditModeAddRemove">
<fields>
<field id="status" xsi:type="AttributeLinkedSet">
<edit_mode>add_remove</edit_mode>
</field>
</fields>
</class>
<class id="ClassWithAttributeLinkedSetEditModeActions">
<fields>
<field id="status" xsi:type="AttributeLinkedSet">
<edit_mode>actions</edit_mode>
</field>
</fields>
</class>
<class id="ClassWithAttributeLinkedSetEditModeInPlace">
<fields>
<field id="status" xsi:type="AttributeLinkedSet">
<edit_mode>in_place</edit_mode>
</field>
</fields>
</class>
<class id="ClassWithAttributeLinkedSetNoEditMode">
<fields>
<field id="status" xsi:type="AttributeLinkedSet">
<linked_class>Ticket</linked_class>
</field>
</fields>
</class>
<class id="ClassWithAttributeLinkedSetIndirect">
<fields>
<field id="status" xsi:type="AttributeLinkedSetIndirect"/>
</fields>
</class>
</classes>
</itop_design>

View File

@@ -0,0 +1,52 @@
<?xml version="1.0" encoding="UTF-8"?>
<itop_design xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="3.0">
<classes>
<class id="ClassWithAttributeLinkedSetEditModeNone">
<fields>
<field id="status" xsi:type="AttributeLinkedSet">
<edit_mode>none</edit_mode>
</field>
</fields>
</class>
<class id="ClassWithAttributeLinkedSetEditModeAddOnly">
<fields>
<field id="status" xsi:type="AttributeLinkedSet">
<edit_mode>add_only</edit_mode>
</field>
</fields>
</class>
<class id="ClassWithAttributeLinkedSetEditModeAddRemove">
<fields>
<field id="status" xsi:type="AttributeLinkedSet">
<edit_mode>add_remove</edit_mode>
</field>
</fields>
</class>
<class id="ClassWithAttributeLinkedSetEditModeActions">
<fields>
<field id="status" xsi:type="AttributeLinkedSet">
<edit_mode>actions</edit_mode>
</field>
</fields>
</class>
<class id="ClassWithAttributeLinkedSetEditModeInPlace">
<fields>
<field id="status" xsi:type="AttributeLinkedSet">
<edit_mode>in_place</edit_mode>
</field>
</fields>
</class>
<class id="ClassWithAttributeLinkedSetNoEditMode">
<fields>
<field id="status" xsi:type="AttributeLinkedSet">
<linked_class>Ticket</linked_class>
</field>
</fields>
</class>
<class id="ClassWithAttributeLinkedSetIndirect">
<fields>
<field id="status" xsi:type="AttributeLinkedSetIndirect"/>
</fields>
</class>
</classes>
</itop_design>

View File

@@ -0,0 +1,66 @@
<?xml version="1.0" encoding="UTF-8"?>
<itop_design xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="3.1">
<classes>
<class id="ClassWithAttributeLinkedSetEditModeNone">
<fields>
<field id="status" xsi:type="AttributeLinkedSet">
<legacy_edit_mode>none</legacy_edit_mode>
<relation_type>link</relation_type>
<read_only>true</read_only>
</field>
</fields>
</class>
<class id="ClassWithAttributeLinkedSetEditModeAddOnly">
<fields>
<field id="status" xsi:type="AttributeLinkedSet">
<legacy_edit_mode>add_only</legacy_edit_mode>
<relation_type>link</relation_type>
<read_only>false</read_only>
</field>
</fields>
</class>
<class id="ClassWithAttributeLinkedSetEditModeAddRemove">
<fields>
<field id="status" xsi:type="AttributeLinkedSet">
<legacy_edit_mode>add_remove</legacy_edit_mode>
<relation_type>link</relation_type>
<read_only>false</read_only>
</field>
</fields>
</class>
<class id="ClassWithAttributeLinkedSetEditModeActions">
<fields>
<field id="status" xsi:type="AttributeLinkedSet">
<legacy_edit_mode>actions</legacy_edit_mode>
<relation_type>link</relation_type>
<read_only>false</read_only>
</field>
</fields>
</class>
<class id="ClassWithAttributeLinkedSetEditModeInPlace">
<fields>
<field id="status" xsi:type="AttributeLinkedSet">
<legacy_edit_mode>in_place</legacy_edit_mode>
<relation_type>property</relation_type>
<read_only>false</read_only>
</field>
</fields>
</class>
<class id="ClassWithAttributeLinkedSetNoEditMode">
<fields>
<field id="status" xsi:type="AttributeLinkedSet">
<linked_class>Ticket</linked_class>
<relation_type>link</relation_type>
<read_only>false</read_only>
</field>
</fields>
</class>
<class id="ClassWithAttributeLinkedSetIndirect">
<fields>
<field id="status" xsi:type="AttributeLinkedSetIndirect">
<read_only>false</read_only>
</field>
</fields>
</class>
</classes>
</itop_design>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<itop_design xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.7">
<a>
<b/>
<d _delta="delete"/>
<f _delta="delete">
<g>I'm a future sibling</g>
</f>
</a>
</itop_design>

View File

@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<itop_design xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.7">
<a>
<b>
<c _delta="delete">In self delete</c>
</b>
<d _delta="delete">
<e>In parent delete</e>
</d>
<f _delta="delete">
<g>I'm a future sibling</g>
</f>
</a>
</itop_design>

View File

@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<itop_design xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.7">
<a>
<b/>
<d _delta="delete"/>
<f _delta="define">
<g>I'm a future sibling</g>
</f>
</a>
</itop_design>

View File

@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<itop_design xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.7">
<a>
<b>
<c _delta="delete">In self delete</c>
</b>
<d _delta="delete">
<e>In parent delete</e>
</d>
<f _delta="define">
<g>I'm a future sibling</g>
</f>
</a>
</itop_design>

View File

@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<itop_design xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.7">
<a>
<b/>
<d _delta="delete"/>
<f>
<g>I'm a future sibling</g>
<c _delta="delete">In self delete</c>
<e>In parent delete</e>
</f>
</a>
</itop_design>

View File

@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<itop_design xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.7">
<a>
<b>
<c _delta="delete">In self delete</c>
</b>
<d _delta="delete">
<e>In parent delete</e>
</d>
<f>
<g>I'm a future sibling</g>
</f>
</a>
</itop_design>

View File

@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<itop_design xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.7">
<a>
<b/>
<d _delta="force"/>
<f _delta="delete">
<g>I'm a future sibling</g>
</f>
</a>
</itop_design>

View File

@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<itop_design xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.7">
<a>
<b>
<c _delta="define">In self definition</c>
</b>
<d _delta="force">
<e>In parent definition</e>
</d>
<f _delta="delete">
<g>I'm a future sibling</g>
</f>
</a>
</itop_design>

View File

@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<itop_design xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.7">
<a>
<b/>
<d _delta="force"/>
<f _delta="define">
<g>I'm a future sibling</g>
<c>In self definition</c>
<e>In parent definition</e>
</f>
</a>
</itop_design>

View File

@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<itop_design xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.7">
<a>
<b>
<c _delta="define">In self definition</c>
</b>
<d _delta="force">
<e>In parent definition</e>
</d>
<f _delta="define">
<g>I'm a future sibling</g>
</f>
</a>
</itop_design>

View File

@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<itop_design xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.7">
<a>
<b/>
<d _delta="force"/>
<f>
<g>I'm a future sibling</g>
<c _delta="define">In self definition</c>
<e _delta="force">In parent definition</e>
</f>
</a>
</itop_design>

View File

@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<itop_design xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.7">
<a>
<b>
<c _delta="define">In self definition</c>
</b>
<d _delta="force">
<e>In parent definition</e>
</d>
<f>
<g>I'm a future sibling</g>
</f>
</a>
</itop_design>

View File

@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<itop_design xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.7">
<a>
<b/>
<f _delta="delete">
<g>I'm a future sibling</g>
</f>
</a>
</itop_design>

View File

@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<itop_design xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.7">
<a>
<b>
<c>Not in definition</c>
</b>
<f _delta="delete">
<g>I'm a future sibling</g>
</f>
</a>
</itop_design>

View File

@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<itop_design xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.7">
<a>
<b/>
<f _delta="define">
<g>I'm a future sibling</g>
<c>Not in definition</c>
</f>
</a>
</itop_design>

View File

@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<itop_design xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.7">
<a>
<b>
<c>Not in definition</c>
</b>
<f _delta="define">
<g>I'm a future sibling</g>
</f>
</a>
</itop_design>

View File

@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<itop_design xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.7">
<a>
<b/>
<f>
<g>I'm a future sibling</g>
<c>Not in definition</c>
</f>
</a>
</itop_design>

View File

@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<itop_design xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.7">
<a>
<b>
<c>Not in definition</c>
</b>
<f>
<g>I'm a future sibling</g>
</f>
</a>
</itop_design>

View File

@@ -0,0 +1,261 @@
<?php
namespace Combodo\iTop\Test\UnitTest\Setup;
use Combodo\iTop\Test\UnitTest\ItopTestCase;
use DOMDocument;
use DOMXPath;
use iTopDesignFormat;
/**
* @covers iTopDesignFormat
*
* @since 2.7.0 N°2586
* @package Combodo\iTop\Test\UnitTest\Setup
*/
class iTopDesignFormatTest extends ItopTestCase
{
const SAMPLES_DIR_PATH = 'Convert-samples/';
protected function setUp(): void
{
parent::setUp();
$this->RequireOnceItopFile('setup/modelfactory.class.inc.php');
$this->RequireOnceItopFile('setup/itopdesignformat.class.inc.php');
}
public function testGetPreviousDesignVersion()
{
$this->assertSame('3.0', iTopDesignFormat::GetPreviousDesignVersion('3.1'));
$this->assertSame('1.7', iTopDesignFormat::GetPreviousDesignVersion('3.0'));
$this->assertSame('1.6', iTopDesignFormat::GetPreviousDesignVersion('1.7'));
$this->assertSame('1.5', iTopDesignFormat::GetPreviousDesignVersion('1.6'));
$this->assertNull(iTopDesignFormat::GetPreviousDesignVersion('1.0'));
$this->assertNull(iTopDesignFormat::GetPreviousDesignVersion(''));
$this->assertNull(iTopDesignFormat::GetPreviousDesignVersion('NonExistingVersion'));
}
/**
* @covers iTopDesignFormat::Convert
* @dataProvider ConvertProvider
*
* @param string $sXmlFileName Corresponding files should exist in the `Convert-samples` dir with the `.expected` and `.input` suffixes
* Example "1.7_to_1.6" for `Convert-samples/1.7_to_1.6.expected.xml` and `Convert-samples/1.7_to_1.6.input.xml`
*
* @throws \Exception
*/
public function testConvert($sXmlFileName, $iExpectedErrors = 0, $sFirstErrorMessage = '')
{
$sSamplesRelDirPath = self::SAMPLES_DIR_PATH;
$sExpectedXml = $this->GetFileContent($sSamplesRelDirPath.$sXmlFileName.'.expected');
$oExpectedDesignFormat = static::GetItopFormatFromString($sExpectedXml);
$sTargetVersion = $oExpectedDesignFormat->GetVersion();
$sInputXml = $this->GetFileContent($sSamplesRelDirPath.$sXmlFileName.'.input');
$oInputDesignFormat = static::GetItopFormatFromString($sInputXml);
$bResult = $oInputDesignFormat->Convert($sTargetVersion);
$aErrors = $oInputDesignFormat->GetErrors();
$this->assertCount($iExpectedErrors, $aErrors,
'errors in input format: '.var_export($aErrors, true));
if ($iExpectedErrors > 0) {
$this->assertFalse($bResult);
$this->assertEquals($sFirstErrorMessage, $aErrors[0]);
}
/** @noinspection PhpRedundantOptionalArgumentInspection We REALLY want those options so specifying it anyway */
$sConvertedXml = $oInputDesignFormat->GetXmlAsString(null, true, false);
// Erase dynamic values
$sConvertedXml = preg_replace('@<trashed_node id="\w+"@', '<trashed_node id="XXX"', $sConvertedXml);
$this->assertEquals($sExpectedXml, $sConvertedXml);
}
/**
* Same provider as {@see testConvert} so that we need to modify only 1 provider when adding a new version
*
* Filters the dataprovider to get only upward conversions
* On each upward conversion, will take the expected file and tries to convert from its immediate previous version
* For example in '3.0_To_3.1' we will get the expected file which is in 3.1 version, and tries to convert this file from 3.0 to 3.1 : result must be the same content.
*
* This will guarantee that update-xml script will continue to work: we want to be able to convert files from version N to version N during version N dev
*
* @dataProvider ConvertProvider
*
* @param $sXmlFileName Corresponding files should exist in the `Convert-samples`, with a '.expected' suffix
*
* @return void
* @since 3.1.0 N°5779 method creation
*/
public function testConvertNToN($sXmlFileName)
{
$sSamplesRelDirPath = self::SAMPLES_DIR_PATH;
$sInputXml = $this->GetFileContent($sSamplesRelDirPath.$sXmlFileName.'.input');
$oInputDesignFormat = static::GetItopFormatFromString($sInputXml);
$sInputVersion = $oInputDesignFormat->GetVersion();
$sExpectedXml = $this->GetFileContent($sSamplesRelDirPath.$sXmlFileName.'.expected');
$oExpectedDesignFormat = static::GetItopFormatFromString($sExpectedXml);
$sExpectedVersion = $oExpectedDesignFormat->GetVersion();
if (version_compare($sInputVersion, $sExpectedVersion, '>=')) {
$this->markTestSkipped("This dataset correspond to a downward conversion ($sInputVersion to $sExpectedVersion) and we want to test upwards conversions => skipping !");
}
$sExpectedPreviousVersion = iTopDesignFormat::GetPreviousDesignVersion($sExpectedVersion);
$oExpectedDesignFormat->GetITopDesignNode()->setAttribute('version', $sExpectedPreviousVersion);
$bConversionResult = $oExpectedDesignFormat->Convert($sExpectedVersion);
$this->assertTrue($bConversionResult,
'There were conversion errors: '.var_export($oExpectedDesignFormat->GetErrors(), true));
/** @noinspection PhpRedundantOptionalArgumentInspection We REALLY want those options so specifying it anyway */
$sConvertedXml = $oExpectedDesignFormat->GetXmlAsString(null, true, false);
// Erase dynamic values
$sConvertedXml = preg_replace('@<trashed_node id="\w+"@', '<trashed_node id="XXX"', $sConvertedXml);
$this->assertEquals($sExpectedXml, $sConvertedXml, 'Havin a file with N version, applying conversion from N-1 to N should not change the content');
}
private static function GetItopFormatFromString(string $sFileContent): iTopDesignFormat
{
$oInputDocument = new DOMDocument();
/** @noinspection PhpComposerExtensionStubsInspection */
libxml_clear_errors();
$oInputDocument->formatOutput = true;
$oInputDocument->preserveWhiteSpace = false;
$oInputDocument->loadXML($sFileContent);
return new iTopDesignFormat($oInputDocument);
}
public function ConvertProvider()
{
return [
'1.6 to 1.7 2' => ['sXmlFileName' => '1.6_to_1.7_2'],
'1.7 to 1.6' => ['sXmlFileName' => '1.7_to_1.6'],
'1.7 to 1.6 2' => ['sXmlFileName' => '1.7_to_1.6_2'],
'1.7 to 3.0' => ['sXmlFileName' => '1.7_to_3.0'],
'3.0 to 1.7' => ['sXmlFileName' => '3.0_to_1.7'],
'3.0 to 3.1' => ['sXmlFileName' => '3.0_to_3.1'],
'3.1 to 3.0' => ['sXmlFileName' => '3.1_to_3.0'],
'Bug_4569' => ['sXmlFileName' => 'Bug_4569'],
];
}
/**
* @covers iTopDesignFormat::Convert
* @dataProvider ConvertBackAndForthProvider
*
* @param string $sTargetVersion
* @param string $sXmlFileName Example "1.7_to_1.6". Corresponding files should exist with the ".input" and ".Expected" suffix
*
* @throws \Exception
*/
public function testConvertBackAndForth($sTargetVersion, $sXmlFileName)
{
$sSamplesRelDirPath = 'Convert-samples/';
$sInputXml = $this->GetFileContent($sSamplesRelDirPath.$sXmlFileName.'.input');
$oInputDocument = new DOMDocument();
libxml_clear_errors();
$oInputDocument->preserveWhiteSpace = false;
$oInputDocument->loadXML($sInputXml);
$oXPath = new DOMXPath($oInputDocument);
$oItopDesignNode = $oXPath->query('/itop_design')->item(0);
if (!$oItopDesignNode) {
$this->fail('Bad XML format');
}
$sSourceVersion = $oItopDesignNode->getAttribute('version');
$oInputDocument->formatOutput = true;
$oDesignFormat = new iTopDesignFormat($oInputDocument);
$oDesignFormat->Convert($sTargetVersion);
$sConvertedXml = $oInputDocument->saveXML();
// Convert back
$oInputDocument = new DOMDocument();
libxml_clear_errors();
$oInputDocument->preserveWhiteSpace = false;
$oInputDocument->loadXML($sConvertedXml);
$oInputDocument->formatOutput = true;
$oDesignFormat = new iTopDesignFormat($oInputDocument);
$oDesignFormat->Convert($sSourceVersion);
$sConvertedXml = $oInputDocument->saveXML();
$this->assertEquals($sInputXml, $sConvertedXml);
}
public function ConvertBackAndForthProvider()
{
return [
'1.7 to 3.0' => ['3.0', '1.7'],
];
}
/**
* @covers iTopDesignFormat::MoveNode
* @dataProvider MoveNodeProvider
*
* @param string $sXmlFileName Example "from_deleted_to_not-in-definition"
*/
public function testMoveNode(string $sXmlFileName)
{
$sSamplesRelDirPath = 'MoveNode-samples/';
$sInputXml = $this->GetFileContent($sSamplesRelDirPath.$sXmlFileName.'.input');
$sExpectedXml = $this->GetFileContent($sSamplesRelDirPath.$sXmlFileName.'.expected');
// Prepare document
$oInputDocument = new DOMDocument();
libxml_clear_errors();
$oInputDocument->preserveWhiteSpace = false;
$oInputDocument->loadXML($sInputXml);
$oInputDocument->formatOutput = true;
$oDesignFormat = new iTopDesignFormat($oInputDocument);
$oXPath = new DOMXPath($oInputDocument);
// Move nodes
// Note: We could have pass the XPaths in the provider, but as for now they are the same for all cases, it's easier to read like this. Feel free to change it in the future if necessary.
$oFNode = $oXPath->query("//f")->item(0);
// - Self node
$oCNodeList = $oXPath->query("//c");
if ($oCNodeList->length > 0) {
$oCNode = $oCNodeList->item(0);
$this->InvokeNonPublicMethod('iTopDesignFormat', 'MoveNode', $oDesignFormat, [$oCNode, $oFNode]);
}
// - In parent node
$oENodeList = $oXPath->query("//e");
if ($oENodeList->length > 0) {
$oENode = $oENodeList->item(0);
$this->InvokeNonPublicMethod('iTopDesignFormat', 'MoveNode', $oDesignFormat, [$oENode, $oFNode]);
}
$sConvertedXml = $oInputDocument->saveXML();
$this->assertEquals($sExpectedXml, $sConvertedXml);
}
public function MoveNodeProvider()
{
return array(
'From deleted to deleted' => array('from_deleted_to_deleted'),
'From deleted to in definition' => array('from_deleted_to_in-definition'),
'From deleted to not in definition' => array('from_deleted_to_not-in-definition'),
'From in definition to deleted' => array('from_in-definition_to_deleted'),
'From in definition to in definition' => array('from_in-definition_to_in-definition'),
'From in definition to not in definition' => array('from_in-definition_to_not-in-definition'),
'From not in definition to deleted' => array('from_not-in-definition_to_deleted'),
'From not in definition to in definition' => array('from_not-in-definition_to_in-definition'),
'From not in definition to not in definition' => array('from_not-in-definition_to_not-in-definition'),
);
}
private function GetFileContent($sFileName)
{
$sCurrentPath = __DIR__;
return file_get_contents($sCurrentPath.DIRECTORY_SEPARATOR.$sFileName.'.xml');
}
}