HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
File: D:/HostingSpaces/SBogers10/momsecurity.komma.nl/vendor/phpbench/dom/tests/Unit/DocumentTest.php
<?php

/*
 * This file is part of the PhpBench DOM  package
 *
 * (c) Daniel Leech <daniel@dantleech.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace PhpBench\Dom\Tests\Unit;

use PhpBench\Dom\Document;

class DocumentTest extends \PHPUnit_Framework_TestCase
{
    /**
     * @var Document
     */
    private $document;

    public function setUp()
    {
        $this->document = new Document(1.0);
    }

    /**
     * It should perform an XPath query.
     */
    public function testQuery()
    {
        $this->document->loadXml($this->getXml());
        $nodeList = $this->document->query('//record');
        $this->assertInstanceOf('DOMNodeList', $nodeList);
        $this->assertEquals(2, $nodeList->length);
    }

    /**
     * It should evaluate an XPath expression.
     */
    public function testEvaluate()
    {
        $this->document->loadXml($this->getXml());
        $result = $this->document->evaluate('count(//record)');
        $this->assertEquals(2, $result);
    }

    /**
     * It should create a root element.
     */
    public function testCreateRoot()
    {
        $this->document->createRoot('hello');
        $this->assertContains('<hello/>', $this->document->saveXml());
    }

    /**
     * It should return a formatted string representation of the document.
     */
    public function testDump()
    {
        $this->document->loadXml($this->getXml());
        $this->assertEquals(
            trim($this->getXml()),
            trim($this->document->dump())
        );
    }

    /**
     * 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);
    }


    private function getXml()
    {
        $xml = <<<EOT
<?xml version="1.0"?>
<document>
    <record id="1">
        <title>Hello</title>
    </record>
    <record id="2">
        <title>World</title>
    </record>
</document>
EOT;

        return $xml;
    }
}