File tree Expand file tree Collapse file tree 8 files changed +36
-8
lines changed
dev/tests/unit/Magento/FunctionalTestFramework/Test/Config
src/Magento/FunctionalTestingFramework Expand file tree Collapse file tree 8 files changed +36
-8
lines changed Original file line number Diff line number Diff line change 66namespace Tests \unit \Magento \FunctionalTestFramework \Test \Config ;
77
88use Magento \FunctionalTestingFramework \Exceptions \Collector \ExceptionCollector ;
9+ use Magento \FunctionalTestingFramework \Config \Dom \ValidationException ;
910use Magento \FunctionalTestingFramework \Test \Config \ActionGroupDom ;
1011use Magento \FunctionalTestingFramework \Util \MagentoTestCase ;
1112
@@ -29,4 +30,21 @@ public function testActionGroupDomStepKeyValidation()
2930 $ this ->expectException (\Exception::class);
3031 $ exceptionCollector ->throwException ();
3132 }
33+
34+ /**
35+ * Test Action Group invalid XML
36+ */
37+ public function testActionGroupDomInvalidXmlValidation ()
38+ {
39+ $ sampleXml = "<actionGroups>
40+ <actionGroup name= \"sampleActionGroup \">
41+ <wait>
42+ </actionGroup>
43+ </actionGroups> " ;
44+
45+ $ exceptionCollector = new ExceptionCollector ();
46+ $ this ->expectException (ValidationException::class);
47+ $ this ->expectExceptionMessage ("XML Parse Error: invalid.xml \n" );
48+ new ActionGroupDom ($ sampleXml , 'invalid.xml ' , $ exceptionCollector );
49+ }
3250}
Original file line number Diff line number Diff line change 66
77namespace Magento \FunctionalTestingFramework \Config ;
88
9+ use Magento \FunctionalTestingFramework \Config \Dom \ValidationException ;
10+
911/**
1012 * Magento configuration XML DOM utility
1113 */
@@ -354,13 +356,21 @@ public function getDom()
354356 * Create DOM document based on $xml parameter
355357 *
356358 * @param string $xml
359+ * @param string $filename
357360 * @return \DOMDocument
358361 * @throws \Magento\FunctionalTestingFramework\Config\Dom\ValidationException
359362 */
360- protected function initDom ($ xml )
363+ protected function initDom ($ xml, $ filename = null )
361364 {
362365 $ dom = new \DOMDocument ();
363- $ dom ->loadXML ($ xml );
366+ try {
367+ $ domSuccess = $ dom ->loadXML ($ xml );
368+ if (!$ domSuccess ) {
369+ throw new \Exception ();
370+ }
371+ } catch (\Exception $ exception ) {
372+ throw new ValidationException ("XML Parse Error: $ filename \n" );
373+ }
364374 if ($ this ->schemaFile ) {
365375 $ errors = self ::validateDomDocument ($ dom , $ this ->schemaFile , $ this ->errorFormat );
366376 if (count ($ errors )) {
Original file line number Diff line number Diff line change @@ -65,7 +65,7 @@ public function __construct(
6565 */
6666 public function initDom ($ xml , $ filename = null )
6767 {
68- $ dom = parent ::initDom ($ xml );
68+ $ dom = parent ::initDom ($ xml, $ filename );
6969
7070 if (strpos ($ filename , self ::DATA_FILE_NAME_ENDING )) {
7171 $ entityNodes = $ dom ->getElementsByTagName ('entity ' );
Original file line number Diff line number Diff line change @@ -65,7 +65,7 @@ public function __construct(
6565 */
6666 public function initDom ($ xml , $ filename = null )
6767 {
68- $ dom = parent ::initDom ($ xml );
68+ $ dom = parent ::initDom ($ xml, $ filename );
6969
7070 if (strpos ($ filename , self ::METADATA_FILE_NAME_ENDING )) {
7171 $ operationNodes = $ dom ->getElementsByTagName ('operation ' );
Original file line number Diff line number Diff line change @@ -76,7 +76,7 @@ public function __construct(
7676 */
7777 public function initDom ($ xml , $ filename = null )
7878 {
79- $ dom = parent ::initDom ($ xml );
79+ $ dom = parent ::initDom ($ xml, $ filename );
8080
8181 $ pagesNode = $ dom ->getElementsByTagName ('pages ' )->item (0 );
8282 $ this ->validationUtil ->validateChildUniqueness ($ pagesNode , $ filename );
Original file line number Diff line number Diff line change @@ -67,7 +67,7 @@ public function __construct(
6767 */
6868 public function initDom ($ xml , $ filename = null )
6969 {
70- $ dom = parent ::initDom ($ xml );
70+ $ dom = parent ::initDom ($ xml, $ filename );
7171 $ sectionNodes = $ dom ->getElementsByTagName ('section ' );
7272 foreach ($ sectionNodes as $ sectionNode ) {
7373 $ sectionNode ->setAttribute (self ::SECTION_META_FILENAME_ATTRIBUTE , $ filename );
Original file line number Diff line number Diff line change @@ -26,7 +26,7 @@ class ActionGroupDom extends Dom
2626 */
2727 public function initDom ($ xml , $ filename = null )
2828 {
29- $ dom = parent ::initDom ($ xml );
29+ $ dom = parent ::initDom ($ xml, $ filename );
3030
3131 if (strpos ($ filename , self ::ACTION_GROUP_FILE_NAME_ENDING )) {
3232 $ actionGroupNodes = $ dom ->getElementsByTagName ('actionGroup ' );
Original file line number Diff line number Diff line change @@ -79,7 +79,7 @@ public function __construct(
7979 */
8080 public function initDom ($ xml , $ filename = null )
8181 {
82- $ dom = parent ::initDom ($ xml );
82+ $ dom = parent ::initDom ($ xml, $ filename );
8383
8484 if (strpos ($ filename , self ::TEST_FILE_NAME_ENDING )) {
8585 $ testNodes = $ dom ->getElementsByTagName ('test ' );
You can’t perform that action at this time.
0 commit comments