Skip to content
This repository was archived by the owner on May 30, 2025. It is now read-only.

Commit 5d9f8e0

Browse files
committed
XML Processor: Add auto pulling semantics to move through larger documents without explicit is_paused_at_incomplete_input() calls
1 parent a25f943 commit 5d9f8e0

File tree

3 files changed

+196581
-5
lines changed

3 files changed

+196581
-5
lines changed

components/XML/Tests/XMLProcessorTest.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
*/
88

99
use PHPUnit\Framework\TestCase;
10+
use WordPress\ByteStream\ReadStream\FileReadStream;
1011
use WordPress\XML\XMLProcessor;
1112

1213
/**
@@ -1854,4 +1855,25 @@ public function test_doctype_in_tag_content_is_syntax_error() {
18541855
$this->assertFalse( $processor->next_token(), 'Did not reject DOCTYPE in tag content' );
18551856
$this->assertEquals( 'syntax', $processor->get_last_error(), 'Did not detect a syntax error' );
18561857
}
1858+
1859+
public function test_auto_pulling_of_entities() {
1860+
$processor = XMLProcessor::create_for_streaming(
1861+
FileReadStream::from_path(__DIR__ . '/fixtures/10MB.xml')
1862+
);
1863+
1864+
$count_tags = 0;
1865+
while ( $processor->next_tag() ) {
1866+
$count_tags++;
1867+
}
1868+
$this->assertEquals( 120604, $count_tags, 'Did not find the expected number of tags.' );
1869+
}
1870+
1871+
public function test_get_all_modifiable_text_until_next_tag() {
1872+
$processor = XMLProcessor::create_for_streaming(
1873+
FileReadStream::from_path(__DIR__ . '/fixtures/10MB.xml')
1874+
);
1875+
$processor->next_tag('content:encoded');
1876+
$text = $processor->get_all_modifiable_text_until_next_tag();
1877+
$this->assertEquals( 82924, strlen($text), 'Did not find the expected number of bytes.' );
1878+
}
18571879
}

0 commit comments

Comments
 (0)