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

XML Processor: Add auto pulling semantics #24

Draft
wants to merge 1 commit into
base: trunk
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions components/XML/Tests/XMLProcessorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*/

use PHPUnit\Framework\TestCase;
use WordPress\ByteStream\ReadStream\FileReadStream;
use WordPress\XML\XMLProcessor;

/**
Expand Down Expand Up @@ -1854,4 +1855,25 @@ public function test_doctype_in_tag_content_is_syntax_error() {
$this->assertFalse( $processor->next_token(), 'Did not reject DOCTYPE in tag content' );
$this->assertEquals( 'syntax', $processor->get_last_error(), 'Did not detect a syntax error' );
}

public function test_auto_pulling_of_entities() {
$processor = XMLProcessor::create_for_streaming(
FileReadStream::from_path(__DIR__ . '/fixtures/10MB.xml')
);

$count_tags = 0;
while ( $processor->next_tag() ) {
$count_tags++;
}
$this->assertEquals( 120604, $count_tags, 'Did not find the expected number of tags.' );
}

public function test_get_all_modifiable_text_until_next_tag() {
$processor = XMLProcessor::create_for_streaming(
FileReadStream::from_path(__DIR__ . '/fixtures/10MB.xml')
);
$processor->next_tag('content:encoded');
$text = $processor->get_all_modifiable_text_until_next_tag();
$this->assertEquals( 82924, strlen($text), 'Did not find the expected number of bytes.' );
}
}
Loading