robotstxt : catch the errors with the associated lines.

robotstxt : more unit tests


git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@5986 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
2020-05-11 18:26:01 +00:00
parent 8f302cfede
commit e1f1ddaa24
2 changed files with 81 additions and 22 deletions

View File

@@ -119,6 +119,15 @@ class robotstxtTest extends PHPUnit_Framework_TestCase
["http://example.com/sitemap.xml", "http://example.com/SITEMAP.XML"]);
}
public function test_sitemaps_error_1 ()
{
$robotstxt = new robotstxt (
"User-Agent: *\nDisallow: /\nSitemap: URL",
"domsearch");
$res = $robotstxt->errors ();
$this->assertSame ($res, [2 => "Sitemap : Invalid URL provided"]);
}
// Host
public function test_host_1 ()
{
@@ -134,6 +143,20 @@ class robotstxtTest extends PHPUnit_Framework_TestCase
$res = $robotstxt->host ();
$this->assertSame ($res, "localhost");
}
public function test_host_error_1 ()
{
$robotstxt = new robotstxt (
"User-Agent: *\nDisallow: /\n\nHost: localhost\nHoST: toto", "domsearch");
$res = $robotstxt->host ();
$this->assertSame ($res, "localhost");
}
public function test_host_error_2 ()
{
$robotstxt = new robotstxt (
"User-Agent: *\nDisallow: /\n\nHost: localhost\nHoST: toto", "domsearch");
$res = $robotstxt->errors ();
$this->assertSame ($res, [4 => "Multiple Hosts set"]);
}
// URLAllow
public function test_urlallow_1 ()