@@ -36,11 +36,15 @@ final class ProcessRulesetBrokenRulesetTest extends AbstractRulesetTestCase
3636 */
3737 public function testBrokenRulesetEmptyFile ()
3838 {
39+ if (version_compare (LIBXML_DOTTED_VERSION , '2.12.0 ' , '>= ' ) === false ) {
40+ $ this ->markTestSkipped ('Test requires libxml2 2.12.0 or higher ' );
41+ }
42+
3943 $ standard = __DIR__ .'/ProcessRulesetBrokenRulesetEmptyFileTest.xml ' ;
4044 $ config = new ConfigDouble (["--standard= $ standard " ]);
4145
4246 $ regex = '`^Ruleset \S+ProcessRulesetBrokenRulesetEmptyFileTest\.xml is not valid\R ' ;
43- $ regex .= '( - On line 1, column 1: Document is empty\R)? $` ' ;
47+ $ regex .= '- On line 1, column 1: Document is empty\R$` ' ;
4448
4549 $ this ->expectRuntimeExceptionRegex ($ regex );
4650
@@ -49,6 +53,29 @@ public function testBrokenRulesetEmptyFile()
4953 }//end testBrokenRulesetEmptyFile()
5054
5155
56+ /**
57+ * Test displaying an informative error message when an empty XML ruleset file is encountered.
58+ *
59+ * @return void
60+ */
61+ public function testBrokenRulesetEmptyFileWithOldLibxml2 ()
62+ {
63+ if (version_compare (LIBXML_DOTTED_VERSION , '2.12.0 ' , '< ' ) === false ) {
64+ $ this ->markTestSkipped ('Test requires libxml2 < 2.12.0 ' );
65+ }
66+
67+ $ standard = __DIR__ .'/ProcessRulesetBrokenRulesetEmptyFileTest.xml ' ;
68+ $ config = new ConfigDouble (["--standard= $ standard " ]);
69+
70+ $ regex = '`^Ruleset \S+ProcessRulesetBrokenRulesetEmptyFileTest\.xml is not valid\R$` ' ;
71+
72+ $ this ->expectRuntimeExceptionRegex ($ regex );
73+
74+ new Ruleset ($ config );
75+
76+ }//end testBrokenRulesetEmptyFileWithOldLibxml2()
77+
78+
5279 /**
5380 * Test displaying an informative error message for a broken XML ruleset with a single XML error.
5481 *
@@ -76,13 +103,16 @@ public function testBrokenRulesetSingleError()
76103 */
77104 public function testBrokenRulesetMultiError ()
78105 {
106+ if (version_compare (LIBXML_DOTTED_VERSION , '2.12.0 ' , '>= ' ) === false ) {
107+ $ this ->markTestSkipped ('Test requires libxml2 >= v2.12.0 ' );
108+ }
109+
79110 $ standard = __DIR__ .'/ProcessRulesetBrokenRulesetMultiErrorTest.xml ' ;
80111 $ config = new ConfigDouble (["--standard= $ standard " ]);
81112
82113 $ regex = '`^Ruleset \S+ProcessRulesetBrokenRulesetMultiErrorTest\.xml is not valid\R ' ;
83114 $ regex .= '- On line 8, column 12: Opening and ending tag mismatch: property line 7 and rule\R ' ;
84- $ regex .= '- On line 10, column 11: Opening and ending tag mismatch: properties line 5 and ruleset\R ' ;
85- $ regex .= '(- On line 11, column 1: Premature end of data in tag rule line 4\R)?$` ' ;
115+ $ regex .= '- On line 10, column 11: Opening and ending tag mismatch: properties line 5 and ruleset\R$` ' ;
86116
87117 $ this ->expectRuntimeExceptionRegex ($ regex );
88118
@@ -91,4 +121,30 @@ public function testBrokenRulesetMultiError()
91121 }//end testBrokenRulesetMultiError()
92122
93123
124+ /**
125+ * Test displaying an informative error message for a broken XML ruleset with multiple XML errors.
126+ *
127+ * @return void
128+ */
129+ public function testBrokenRulesetMultiErrorWithOldLibxml2 ()
130+ {
131+ if (version_compare (LIBXML_DOTTED_VERSION , '2.12.0 ' , '< ' ) === false ) {
132+ $ this ->markTestSkipped ('Test requires libxml2 < v2.12.0 ' );
133+ }
134+
135+ $ standard = __DIR__ .'/ProcessRulesetBrokenRulesetMultiErrorTest.xml ' ;
136+ $ config = new ConfigDouble (["--standard= $ standard " ]);
137+
138+ $ regex = '`^Ruleset \S+ProcessRulesetBrokenRulesetMultiErrorTest\.xml is not valid\R ' ;
139+ $ regex .= '- On line 8, column 12: Opening and ending tag mismatch: property line 7 and rule\R ' ;
140+ $ regex .= '- On line 10, column 11: Opening and ending tag mismatch: properties line 5 and ruleset\R ' ;
141+ $ regex .= '- On line 11, column 1: Premature end of data in tag rule line 4\R$` ' ;
142+
143+ $ this ->expectRuntimeExceptionRegex ($ regex );
144+
145+ new Ruleset ($ config );
146+
147+ }//end testBrokenRulesetMultiErrorWithOldLibxml2()
148+
149+
94150}//end class
0 commit comments