@@ -480,23 +480,25 @@ public function test_to_string_returns_updated_xml() {
480480 * @covers XMLProcessor::get_updated_xml
481481 */
482482 public function test_get_updated_xml_applies_the_updates_so_far_and_keeps_the_processor_on_the_current_tag () {
483- $ processor = XMLProcessor::create_from_string ( '<line id="remove" /><content enabled="yes" post-type="test">Test</content><text id="span-id"></text> ' );
483+ $ processor = XMLProcessor::create_from_string ( '<doc><line id="remove" /><content enabled="yes" post-type="test">Test</content><text id="span-id"></text></doc> ' );
484+ $ processor ->next_tag ();
485+
484486 $ processor ->next_tag ();
485487 $ processor ->remove_attribute ( '' , 'id ' );
486488
487489 $ processor ->next_tag ();
488490 $ processor ->set_attribute ( '' , 'id ' , 'content-id-1 ' );
489491
490492 $ this ->assertSame (
491- '<line /><content id="content-id-1" enabled="yes" post-type="test">Test</content><text id="span-id"></text> ' ,
493+ '<doc>< line /><content id="content-id-1" enabled="yes" post-type="test">Test</content><text id="span-id"></text></doc > ' ,
492494 $ processor ->get_updated_xml (),
493495 'Calling get_updated_xml after updating the attributes of the second tag returned different XML than expected '
494496 );
495497
496498 $ processor ->set_attribute ( '' , 'id ' , 'content-id-2 ' );
497499
498500 $ this ->assertSame (
499- '<line /><content id="content-id-2" enabled="yes" post-type="test">Test</content><text id="span-id"></text> ' ,
501+ '<doc>< line /><content id="content-id-2" enabled="yes" post-type="test">Test</content><text id="span-id"></text></doc > ' ,
500502 $ processor ->get_updated_xml (),
501503 'Calling get_updated_xml after updating the attributes of the second tag for the second time returned different XML than expected '
502504 );
@@ -505,7 +507,7 @@ public function test_get_updated_xml_applies_the_updates_so_far_and_keeps_the_pr
505507 $ processor ->remove_attribute ( '' , 'id ' );
506508
507509 $ this ->assertSame (
508- '<line /><content id="content-id-2" enabled="yes" post-type="test">Test</content><text ></text> ' ,
510+ '<doc>< line /><content id="content-id-2" enabled="yes" post-type="test">Test</content><text ></text></doc > ' ,
509511 $ processor ->get_updated_xml (),
510512 'Calling get_updated_xml after removing the id attribute of the third tag returned different XML than expected '
511513 );
@@ -1717,6 +1719,27 @@ public function test_detects_invalid_document_no_root_tag() {
17171719 $ this ->assertFalse ( $ processor ->next_tag (), 'Found an element when there was none. ' );
17181720 $ this ->assertTrue ( $ processor ->is_paused_at_incomplete_input (), 'Did not indicate that the XML input was incomplete. ' );
17191721 }
1722+
1723+ /**
1724+ *
1725+ * @covers XMLProcessor::next_tag
1726+ */
1727+ public function test_tolerates_illegal_extender_in_pi_target () {
1728+ $ processor = XMLProcessor::create_from_string (
1729+ '<!DOCTYPE animal [
1730+ <!ELEMENT animal ANY>
1731+ <?_˒ an illegal extender #x2d2 in PITarget ?>
1732+ ]>
1733+ <animal/>
1734+ '
1735+ );
1736+ $ this ->assertTrue ( $ processor ->next_tag (), 'Found an element when there was none. ' );
1737+ $ this ->assertEquals ( 'animal ' , $ processor ->get_tag_local_name (), 'Did not find the expected tag. ' );
1738+ $ this ->assertTrue ( $ processor ->next_token (), 'Found an element when there was none. ' );
1739+ $ this ->assertFalse ( $ processor ->next_token (), 'Found an element when there was none. ' );
1740+ $ this ->assertNull ( $ processor ->get_last_error (), 'Did not find the expected error. ' );
1741+ $ this ->assertNull ( $ processor ->get_exception (), 'Did not find the expected error. ' );
1742+ }
17201743
17211744 /**
17221745 *
0 commit comments