5 use PHPUnit\Framework\Assert;
45 while ( $this->xml->read() ) {
46 if ( $this->xml->nodeType == XMLReader::END_ELEMENT &&
47 $this->xml->name ==
$name
68 "Skipping to end of $name" );
69 while ( $this->xml->read() ) {
70 if ( $this->xml->nodeType == XMLReader::ELEMENT ) {
86 $this->xml =
new XMLReader();
88 Assert::assertTrue( $this->xml->open(
$fname ),
89 "Opening temporary file $fname via XMLReader failed" );
90 if ( $skip_siteinfo ) {
92 "Skipping past end of siteinfo" );
105 if ( $this->xml->read() ) {
108 Assert::assertEquals( $this->xml->nodeType, XMLReader::NONE,
109 "No proper entity left to parse" );
118 while ( $cont && ( ( $this->xml->nodeType == XMLReader::WHITESPACE )
119 || ( $this->xml->nodeType == XMLReader::SIGNIFICANT_WHITESPACE ) ) ) {
120 $cont = $this->xml->read();
133 Assert::assertEquals(
$name, $this->xml->name,
"Node name" );
134 Assert::assertEquals( XMLReader::ELEMENT, $this->xml->nodeType,
"Node type" );
136 Assert::assertTrue( $this->xml->read(),
"Skipping past start tag" );
149 Assert::assertEquals(
$name, $this->xml->name,
"Node name" );
150 Assert::assertEquals( XMLReader::END_ELEMENT, $this->xml->nodeType,
"Node type" );
152 Assert::assertTrue( $this->xml->read(),
"Skipping past end tag" );
170 if ( $text !==
false ) {
171 Assert::assertEquals( $text, $this->xml->value,
"Text of node " .
$name );
173 Assert::assertTrue( $this->xml->read(),
"Skipping past processed text of " .
$name );
227 $text_sha1, $text =
false, $parentid =
false,
234 if ( $parentid !==
false ) {
255 if ( $this->xml->name ==
"text" ) {
258 $this->
assertText( $id, $text_id, $text_bytes, $text );
265 if ( !$text_found ) {
266 $this->
assertText( $id, $text_id, $text_bytes, $text );
273 public function assertText( $id, $text_id, $text_bytes, $text ) {
275 if ( $text_bytes !==
false ) {
276 Assert::assertEquals( $this->xml->getAttribute(
"bytes" ), $text_bytes,
277 "Attribute 'bytes' of revision " . $id );
280 if ( $text ===
false ) {
282 Assert::assertEquals( $this->xml->getAttribute(
"id" ), $text_id,
283 "Text id of revision " . $id );
284 Assert::assertFalse( $this->xml->hasValue,
"Revision has text" );
285 Assert::assertTrue( $this->xml->read(),
"Skipping text start tag" );
286 if ( ( $this->xml->nodeType == XMLReader::END_ELEMENT )
287 && ( $this->xml->name ==
"text" )
294 Assert::assertTrue( $this->xml->read(),
"Skipping text start tag" );
295 Assert::assertEquals( $text, $this->xml->value,
"Text of revision " . $id );
296 Assert::assertTrue( $this->xml->read(),
"Skipping past text" );
316 $subtype,
$title, $parameters = []
331 if ( $comment !==
null ) {
339 $parameters_xml =
unserialize( $this->xml->value );
340 Assert::assertEquals( $parameters, $parameters_xml );
341 Assert::assertTrue( $this->xml->read(),
"Skipping past processed text of params" );