コード例 #1
0
ファイル: CrawlerTest.php プロジェクト: mihaeu/tarantula
    public function testFindsAllLinks()
    {
        $crawler = new Crawler(new HttpClient('http://google.com'));
        $html = <<<EOT
<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>
    <h1><a href="/test">link</a></h1>
    <header></header>
    <main>
        <a href="back">back</a>
        <a href="http://google.com/gmail">back</a>
        <a href="http://test2">FOREIGN URL SHOULD BE IGNORED</a>
    </main>
</body>
</html>
EOT;
        $this->assertCount(3, $crawler->findAllLinks($html));
    }