Пример #1
0
 /**
  * It should provide a duplicate version of itself.
  */
 public function testDuplicate()
 {
     $this->document->loadXml($this->getXml());
     $duplicate = $this->document->duplicate();
     $this->assertNotsame($this->document, $duplicate);
     $this->assertNotsame($this->document->firstChild, $duplicate->firstChild);
     $this->assertNotsame($this->document->firstChild->firstChild, $duplicate->firstChild->firstChild);
 }
Пример #2
0
    private function getDocument()
    {
        $xml = <<<EOT
<?xml version="1.0"?>
<document>
    <article id="1">
        <title>Morning</title>
    </article>
    <article id="2">
        <title>Afternoon</title>
    </article>
</document>
EOT;
        $document = new Document();
        $document->loadXml($xml);
        return $document;
    }
Пример #3
0
    public function getReportsDocument()
    {
        $document = new Document();
        $report = <<<EOT
<?xml version="1.0"?>
<reports>
    <report title="Report Title">
        <description>Report Description</description>
        <table>
            <group name="body">
                <row>
                    <cell name="one">Hello</cell>
                    <cell name="two">Goodbye</cell>
                </row>
            </group>
        </table>
    </report>
</reports>
EOT;
        $document->loadXml($report);
        return $document;
    }
Пример #4
0
    /**
     * It should throw an exception if an attribute name has no - prefix.
     *
     * @expectedException \RuntimeException
     * @expectedExceptionMessage Expected attribute name to have a result key prefix, got "foo"
     */
    public function testInvalidAttribute()
    {
        $dom = new Document(1.0);
        $dom->loadXml(<<<EOT
<phpbench>
  <suite>
      <benchmark class="\\PhpBench\\Micro\\Math\\KdeBench">
      <subject name="benchKde">
        <variant>
          <iteration foo="12" />
        </variant>
      </subject>
      </benchmark>
  </suite>
</phpbench>
EOT
);
        $decoder = new XmlDecoder();
        $collection = $decoder->decode($dom);
    }