Prewk\XmlStringStreamer\Parser\UniqueNodeTest::test_multiple_roots PHP Метод

test_multiple_roots() публичный Метод

public test_multiple_roots ( )
    public function test_multiple_roots()
    {
        $node1 = <<<eot
            <child>
                <foo baz="attribute" />
                <bar/>
                <index>1</index>
            </child>
eot;
        $node2 = <<<eot
            <child>
                <foo baz="attribute" />
                <bar/>
                <index>2</index>
            </child>
eot;
        $node3 = <<<eot
            <child>
                <foo baz="attribute" />
                <bar/>
                <index>3</index>
            </child>
eot;
        $node4 = <<<eot
            <child>
                <foo baz="attribute" />
                <bar/>
                <index>3</index>
            </child>
eot;
        $xml = <<<eot
            <?xml version="1.0"?>
            <root-a>
                {$node1}
                {$node2}
            </root-a>
            <root-b>
                {$node3}
                {$node4}
            </root-b>
eot;
        $stream = $this->getStreamMock($xml, 50);
        $parser = new UniqueNode(array("uniqueNode" => "child"));
        $this->assertEquals(trim($node1), trim($parser->getNodeFrom($stream)), "Node 1 should be obtained on the first getNodeFrom from root-a");
        $this->assertEquals(trim($node2), trim($parser->getNodeFrom($stream)), "Node 2 should be obtained on the second getNodeFrom from root-a");
        $this->assertEquals(trim($node3), trim($parser->getNodeFrom($stream)), "Node 3 should be obtained on the third getNodeFrom from root-b");
        $this->assertEquals(trim($node4), trim($parser->getNodeFrom($stream)), "Node 4 should be obtained on the third getNodeFrom from root-b");
        $this->assertFalse(false, "When no nodes are left, false should be returned");
    }