/** * Tests JFeedParser::moveToClosingElement() with self-closing tags. * * @return void * * @since 12.3 */ public function testMoveToClosingElementWithSelfClosingTag() { // Set the XML for the internal reader and move the stream to the first <node> element. $this->_reader->Xml('<root><node test="first" /><node test="second"></node></root>'); // Advance the reader to the first <node> element. do { $this->_reader->read(); } while ($this->_reader->name != 'node'); // Ensure that the current node is <node test="first">. $this->assertEquals(XMLReader::ELEMENT, $this->_reader->nodeType); $this->assertEquals('node', $this->_reader->name); $this->assertEquals('first', $this->_reader->getAttribute('test')); // Move to the closing element, which should be </node>. TestReflection::invoke($this->_instance, 'moveToClosingElement'); $this->assertEquals(true, $this->_reader->isEmptyElement); $this->assertEquals('node', $this->_reader->name); // Advance the reader to the next element. do { $this->_reader->read(); } while ($this->_reader->nodeType != XMLReader::ELEMENT); // Ensure that the current node is <node test="first">. $this->assertEquals(XMLReader::ELEMENT, $this->_reader->nodeType); $this->assertEquals('node', $this->_reader->name); $this->assertEquals('second', $this->_reader->getAttribute('test')); }
/** * Tests JFeedParserRss::initialise() * * @param string $expected The expected rss version string. * @param string $xml The XML string for which to detect the version. * * @return void * * @dataProvider seedInitialise * @since 12.3 */ public function testInitialise($expected, $xml) { // Set the XML for the internal reader. $this->_reader->Xml($xml); // Advance the reader to the first element. do { $this->_reader->read(); } while ($this->_reader->nodeType != XMLReader::ELEMENT); TestReflection::invoke($this->_instance, 'initialise'); $this->assertAttributeEquals($expected, 'version', $this->_instance, 'The version string detected should match the expected value.'); // Verify that after detecting the version we are ready to start parsing. $this->assertEquals('test', $this->_reader->name); $this->assertEquals(XMLReader::ELEMENT, $this->_reader->nodeType); }