PEAR2_Services_LinkbackPEAR2_Services_Linkback-0.2.1/tests/PEAR2/Services/Linkback/DomLoaderTest.php

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
namespace PEAR2\Services\Linkback;

class DomLoaderTest extends \PHPUnit_Framework_TestCase
{
    public function setUp()
    {
        parent::setUp();
        $this->dl = new DomLoader();
    }

    public function testLoadHtml()
    {
        $res = \HTTP_Request2_Adapter_Mock::createResponseFromString(
            "HTTP/1.0 200 OK\n"
            . "Content-type: text/html\n"
            . "\n"
            . '<html><head><title></title></head><body></body></html>'
        );
        $doc = $this->dl->load($res->getBody(), $res);
        $this->assertInstanceOf('DomDocument', $doc);
    }

    public function testLoadHtmlBroken()
    {
        $res = \HTTP_Request2_Adapter_Mock::createResponseFromString(
            "HTTP/1.0 200 OK\n"
            . "Content-type: text/html\n"
            . "\n"
            . '<html><head><title>a&b</title></head><body></body></html>'
        );
        $doc = $this->dl->load($res->getBody(), $res);
        $this->assertInstanceOf('DomDocument', $doc);
        //we should not get any PHP warnings here
    }
}
?>
EOF