- /**
- * Asserts that the xml reader is at an element of given name, and optionally
- * skips past it.
- *
- * @param string $name The name of the element to check for
- * (e.g.: "mediawiki" for <mediawiki>)
- * @param bool $skip (optional) if true, skip past the found element
- */
- protected function assertNodeStart( $name, $skip = true ) {
- $this->assertEquals( $name, $this->xml->name, "Node name" );
- $this->assertEquals( XMLReader::ELEMENT, $this->xml->nodeType, "Node type" );
- if ( $skip ) {
- $this->assertTrue( $this->xml->read(), "Skipping past start tag" );
- }
- }
-
- /**
- * Asserts that the xml reader is at an closing element of given name, and optionally
- * skips past it.
- *
- * @param string $name The name of the closing element to check for
- * (e.g.: "mediawiki" for </mediawiki>)
- * @param bool $skip (optional) if true, skip past the found element
- */
- protected function assertNodeEnd( $name, $skip = true ) {
- $this->assertEquals( $name, $this->xml->name, "Node name" );
- $this->assertEquals( XMLReader::END_ELEMENT, $this->xml->nodeType, "Node type" );
- if ( $skip ) {
- $this->assertTrue( $this->xml->read(), "Skipping past end tag" );
- }
- }
-
- /**
- * Asserts that the xml reader is at an element of given tag that contains a given text,
- * and skips over the element.
- *
- * @param string $name The name of the element to check for
- * (e.g.: "mediawiki" for <mediawiki>...</mediawiki>)
- * @param string|bool $text If string, check if it equals the elements text.
- * If false, ignore the element's text
- * @param bool $skip_ws (optional) if true, skip past white spaces that trail the
- * closing element.
- */
- protected function assertTextNode( $name, $text, $skip_ws = true ) {
- $this->assertNodeStart( $name );
-
- if ( $text !== false ) {
- $this->assertEquals( $text, $this->xml->value, "Text of node " . $name );
- }
- $this->assertTrue( $this->xml->read(), "Skipping past processed text of " . $name );
- $this->assertNodeEnd( $name );
-
- if ( $skip_ws ) {
- $this->skipWhitespace();
- }
- }
-
- /**
- * Asserts that the xml reader is at the start of a page element and skips over the first
- * tags, after checking them.
- *
- * Besides the opening page element, this function also checks for and skips over the
- * title, ns, and id tags. Hence after this function, the xml reader is at the first
- * revision of the current page.
- *
- * @param int $id Id of the page to assert
- * @param int $ns Number of namespage to assert
- * @param string $name Title of the current page
- */
- protected function assertPageStart( $id, $ns, $name ) {
- $this->assertNodeStart( "page" );
- $this->skipWhitespace();
-
- $this->assertTextNode( "title", $name );
- $this->assertTextNode( "ns", $ns );
- $this->assertTextNode( "id", $id );
- }