File tree 8 files changed +36
-8
lines changed
dev/tests/unit/Magento/FunctionalTestFramework/Test/Config
src/Magento/FunctionalTestingFramework
8 files changed +36
-8
lines changed Original file line number Diff line number Diff line change 6
6
namespace Tests \unit \Magento \FunctionalTestFramework \Test \Config ;
7
7
8
8
use Magento \FunctionalTestingFramework \Exceptions \Collector \ExceptionCollector ;
9
+ use Magento \FunctionalTestingFramework \Config \Dom \ValidationException ;
9
10
use Magento \FunctionalTestingFramework \Test \Config \ActionGroupDom ;
10
11
use Magento \FunctionalTestingFramework \Util \MagentoTestCase ;
11
12
@@ -29,4 +30,21 @@ public function testActionGroupDomStepKeyValidation()
29
30
$ this ->expectException (\Exception::class);
30
31
$ exceptionCollector ->throwException ();
31
32
}
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
+ }
32
50
}
Original file line number Diff line number Diff line change 6
6
7
7
namespace Magento \FunctionalTestingFramework \Config ;
8
8
9
+ use Magento \FunctionalTestingFramework \Config \Dom \ValidationException ;
10
+
9
11
/**
10
12
* Magento configuration XML DOM utility
11
13
*/
@@ -354,13 +356,21 @@ public function getDom()
354
356
* Create DOM document based on $xml parameter
355
357
*
356
358
* @param string $xml
359
+ * @param string $filename
357
360
* @return \DOMDocument
358
361
* @throws \Magento\FunctionalTestingFramework\Config\Dom\ValidationException
359
362
*/
360
- protected function initDom ($ xml )
363
+ protected function initDom ($ xml, $ filename = null )
361
364
{
362
365
$ 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
+ }
364
374
if ($ this ->schemaFile ) {
365
375
$ errors = self ::validateDomDocument ($ dom , $ this ->schemaFile , $ this ->errorFormat );
366
376
if (count ($ errors )) {
Original file line number Diff line number Diff line change @@ -65,7 +65,7 @@ public function __construct(
65
65
*/
66
66
public function initDom ($ xml , $ filename = null )
67
67
{
68
- $ dom = parent ::initDom ($ xml );
68
+ $ dom = parent ::initDom ($ xml, $ filename );
69
69
70
70
if (strpos ($ filename , self ::DATA_FILE_NAME_ENDING )) {
71
71
$ entityNodes = $ dom ->getElementsByTagName ('entity ' );
Original file line number Diff line number Diff line change @@ -65,7 +65,7 @@ public function __construct(
65
65
*/
66
66
public function initDom ($ xml , $ filename = null )
67
67
{
68
- $ dom = parent ::initDom ($ xml );
68
+ $ dom = parent ::initDom ($ xml, $ filename );
69
69
70
70
if (strpos ($ filename , self ::METADATA_FILE_NAME_ENDING )) {
71
71
$ operationNodes = $ dom ->getElementsByTagName ('operation ' );
Original file line number Diff line number Diff line change @@ -76,7 +76,7 @@ public function __construct(
76
76
*/
77
77
public function initDom ($ xml , $ filename = null )
78
78
{
79
- $ dom = parent ::initDom ($ xml );
79
+ $ dom = parent ::initDom ($ xml, $ filename );
80
80
81
81
$ pagesNode = $ dom ->getElementsByTagName ('pages ' )->item (0 );
82
82
$ this ->validationUtil ->validateChildUniqueness ($ pagesNode , $ filename );
Original file line number Diff line number Diff line change @@ -67,7 +67,7 @@ public function __construct(
67
67
*/
68
68
public function initDom ($ xml , $ filename = null )
69
69
{
70
- $ dom = parent ::initDom ($ xml );
70
+ $ dom = parent ::initDom ($ xml, $ filename );
71
71
$ sectionNodes = $ dom ->getElementsByTagName ('section ' );
72
72
foreach ($ sectionNodes as $ sectionNode ) {
73
73
$ 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
26
26
*/
27
27
public function initDom ($ xml , $ filename = null )
28
28
{
29
- $ dom = parent ::initDom ($ xml );
29
+ $ dom = parent ::initDom ($ xml, $ filename );
30
30
31
31
if (strpos ($ filename , self ::ACTION_GROUP_FILE_NAME_ENDING )) {
32
32
$ actionGroupNodes = $ dom ->getElementsByTagName ('actionGroup ' );
Original file line number Diff line number Diff line change @@ -79,7 +79,7 @@ public function __construct(
79
79
*/
80
80
public function initDom ($ xml , $ filename = null )
81
81
{
82
- $ dom = parent ::initDom ($ xml );
82
+ $ dom = parent ::initDom ($ xml, $ filename );
83
83
84
84
if (strpos ($ filename , self ::TEST_FILE_NAME_ENDING )) {
85
85
$ testNodes = $ dom ->getElementsByTagName ('test ' );
You can’t perform that action at this time.
0 commit comments