Passage en Namespace et tous les tests fonctionnels OK

This commit is contained in:
2021-05-10 11:48:15 +02:00
parent 536dd0d56b
commit eb30d8ef97
56 changed files with 1091 additions and 964 deletions

View File

@@ -7,32 +7,34 @@
namespace Domframework\Tests;
/** Test the robotstxt file
use Domframework\Robotstxt;
/** Test the Robotstxt file
*/
class robotstxtTest extends \PHPUnit_Framework_TestCase
class RobotstxtTest extends \PHPUnit_Framework_TestCase
{
// Empty Robots
public function test_Construct_1 ()
{
$robotstxt = new robotstxt ("", "domsearch");
$robotstxt = new Robotstxt ("", "domsearch");
$res = $robotstxt->allow ();
$this->assertSame ($res, ["/"]);
}
public function test_Construct_2 ()
{
$robotstxt = new robotstxt ("", "domsearch");
$robotstxt = new Robotstxt ("", "domsearch");
$res = $robotstxt->disallow ();
$this->assertSame ($res, array ());
}
public function test_Construct_3 ()
{
$robotstxt = new robotstxt ("", "domsearch");
$robotstxt = new Robotstxt ("", "domsearch");
$res = $robotstxt->sitemaps ();
$this->assertSame ($res, array ());
}
public function test_Construct_4 ()
{
$robotstxt = new robotstxt ("", "domsearch");
$robotstxt = new Robotstxt ("", "domsearch");
$res = $robotstxt->crawldelay ();
$this->assertSame ($res, 3);
}
@@ -40,14 +42,14 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
// Allow
public function test_allow_1 ()
{
$robotstxt = new robotstxt (
$robotstxt = new Robotstxt (
"User-Agent: *\nDisallow:\n", "domsearch");
$res = $robotstxt->allow ();
$this->assertSame ($res, ["/"]);
}
public function test_allow_2 ()
{
$robotstxt = new robotstxt (
$robotstxt = new Robotstxt (
"User-Agent: *\nDisallow:\n\nUser-Agent: DomSearch\nDisallow:\n",
"domsearch");
$res = $robotstxt->allow ();
@@ -55,7 +57,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
}
public function test_allow_3 ()
{
$robotstxt = new robotstxt (
$robotstxt = new Robotstxt (
"User-Agent: DomSearch\nDisallow:\n\nUser-Agent: *\nDisallow:\n",
"domsearch");
$res = $robotstxt->allow ();
@@ -63,7 +65,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
}
public function test_allow_4 ()
{
$robotstxt = new robotstxt (
$robotstxt = new Robotstxt (
"User-Agent: DomSearch\n".
"User-Agent: User1\n".
"User-Agent: User2\n".
@@ -77,14 +79,14 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
// Disallow
public function test_disallow_1 ()
{
$robotstxt = new robotstxt (
$robotstxt = new Robotstxt (
"User-Agent: *\nDisallow: /\n", "domsearch");
$res = $robotstxt->disallow ();
$this->assertSame ($res, ["/"]);
}
public function test_disallow_2 ()
{
$robotstxt = new robotstxt (
$robotstxt = new Robotstxt (
"User-Agent: *\nDisallow: /\n\nUser-Agent: DomSearch\nDisallow: /\n",
"domsearch");
$res = $robotstxt->disallow ();
@@ -92,7 +94,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
}
public function test_disallow_3 ()
{
$robotstxt = new robotstxt (
$robotstxt = new Robotstxt (
"User-Agent: DomSearch\nDisallow: /\n\nUser-Agent: *\nDisallow: /\n",
"domsearch");
$res = $robotstxt->disallow ();
@@ -102,7 +104,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
// Sitemaps
public function test_sitemaps_1 ()
{
$robotstxt = new robotstxt (
$robotstxt = new Robotstxt (
"User-Agent: DomSearch\nDisallow: /\n\nUser-Agent: *\nDisallow: /\n",
"domsearch");
$res = $robotstxt->sitemaps ();
@@ -110,7 +112,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
}
public function test_sitemaps_2 ()
{
$robotstxt = new robotstxt (
$robotstxt = new Robotstxt (
"User-Agent: *\nDisallow: /\nSitemap: http://example.com/sitemap.xml",
"domsearch");
$res = $robotstxt->sitemaps ();
@@ -118,7 +120,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
}
public function test_sitemaps_3 ()
{
$robotstxt = new robotstxt (
$robotstxt = new Robotstxt (
"User-Agent: *\nDisallow: /\n".
"Sitemap: http://example.com/sitemap.xml\n".
"Sitemap: http://example.com/SITEMAP.XML", "domsearch");
@@ -129,7 +131,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
public function test_sitemaps_error_1 ()
{
$robotstxt = new robotstxt (
$robotstxt = new Robotstxt (
"User-Agent: *\nDisallow: /\nSitemap: URL",
"domsearch");
$res = $robotstxt->errors ();
@@ -139,28 +141,28 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
// Host
public function test_host_1 ()
{
$robotstxt = new robotstxt (
$robotstxt = new Robotstxt (
"User-Agent: *\nDisallow: /\n", "domsearch");
$res = $robotstxt->host ();
$this->assertSame ($res, null);
}
public function test_host_2 ()
{
$robotstxt = new robotstxt (
$robotstxt = new Robotstxt (
"User-Agent: *\nDisallow: /\n\nHost: localhost", "domsearch");
$res = $robotstxt->host ();
$this->assertSame ($res, "localhost");
}
public function test_host_error_1 ()
{
$robotstxt = new robotstxt (
$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 (
$robotstxt = new Robotstxt (
"User-Agent: *\nDisallow: /\n\nHost: localhost\nHoST: toto", "domsearch");
$res = $robotstxt->errors ();
$this->assertSame ($res, [4 => "Multiple Hosts set"]);
@@ -169,48 +171,48 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
// URLAllow
public function test_urlallow_1 ()
{
$robotstxt = new robotstxt ("", "domsearch");
$robotstxt = new Robotstxt ("", "domsearch");
$res = $robotstxt->URLAllow ("/");
$this->assertSame ($res, true);
}
public function test_urlallow_2 ()
{
$robotstxt = new robotstxt (
$robotstxt = new Robotstxt (
"User-Agent: *\nDisallow: /", "domsearch");
$res = $robotstxt->URLAllow ("/");
$this->assertSame ($res, false);
}
public function test_urlallow_3 ()
{
$robotstxt = new robotstxt (
$robotstxt = new Robotstxt (
"User-Agent: *\nDisallow: /\nAllow: /allow/", "domsearch");
$res = $robotstxt->URLAllow ("/");
$this->assertSame ($res, false);
}
public function test_urlallow_4 ()
{
$robotstxt = new robotstxt (
$robotstxt = new Robotstxt (
"User-Agent: *\nDisallow: /\nAllow: /allow/", "domsearch");
$res = $robotstxt->URLAllow ("/allow/file");
$this->assertSame ($res, true);
}
public function test_urlallow_5 ()
{
$robotstxt = new robotstxt (
$robotstxt = new Robotstxt (
"User-Agent: *\nDisallow: /\nAllow: /allow/*.gif$", "domsearch");
$res = $robotstxt->URLAllow ("/allow/file.gif");
$this->assertSame ($res, true);
}
public function test_urlallow_6 ()
{
$robotstxt = new robotstxt (
$robotstxt = new Robotstxt (
"User-Agent: *\nDisallow: /\nAllow: /allow/*.gif$", "domsearch");
$res = $robotstxt->URLAllow ("/allow/.gif");
$this->assertSame ($res, false);
}
public function test_urlallow_7 ()
{
$robotstxt = new robotstxt (
$robotstxt = new Robotstxt (
"User-Agent: *\nDisallow: /\nAllow: /allow/*.gif\$", "domsearch");
$res = $robotstxt->URLAllow ("/allow/file.png");
$this->assertSame ($res, false);
@@ -220,7 +222,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
public function test_rfc_unhipbot_1 ()
{
// {{{
$robotstxt = new robotstxt (
$robotstxt = new Robotstxt (
"# /robots.txt for http://www.fict.org/
# comments to webmaster@fict.org
@@ -245,7 +247,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
public function test_rfc_unhipbot_2 ()
{
// {{{
$robotstxt = new robotstxt (
$robotstxt = new Robotstxt (
"# /robots.txt for http://www.fict.org/
# comments to webmaster@fict.org
@@ -270,7 +272,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
public function test_rfc_unhipbot_3 ()
{
// {{{
$robotstxt = new robotstxt (
$robotstxt = new Robotstxt (
"# /robots.txt for http://www.fict.org/
# comments to webmaster@fict.org
@@ -295,7 +297,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
public function test_rfc_unhipbot_4 ()
{
// {{{
$robotstxt = new robotstxt (
$robotstxt = new Robotstxt (
"# /robots.txt for http://www.fict.org/
# comments to webmaster@fict.org
@@ -320,7 +322,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
public function test_rfc_unhipbot_5 ()
{
// {{{
$robotstxt = new robotstxt (
$robotstxt = new Robotstxt (
"# /robots.txt for http://www.fict.org/
# comments to webmaster@fict.org
@@ -345,7 +347,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
public function test_rfc_unhipbot_6 ()
{
// {{{
$robotstxt = new robotstxt (
$robotstxt = new Robotstxt (
"# /robots.txt for http://www.fict.org/
# comments to webmaster@fict.org
@@ -370,7 +372,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
public function test_rfc_unhipbot_7 ()
{
// {{{
$robotstxt = new robotstxt (
$robotstxt = new Robotstxt (
"# /robots.txt for http://www.fict.org/
# comments to webmaster@fict.org
@@ -395,7 +397,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
public function test_rfc_unhipbot_8 ()
{
// {{{
$robotstxt = new robotstxt (
$robotstxt = new Robotstxt (
"# /robots.txt for http://www.fict.org/
# comments to webmaster@fict.org
@@ -420,7 +422,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
public function test_rfc_unhipbot_9 ()
{
// {{{
$robotstxt = new robotstxt (
$robotstxt = new Robotstxt (
"# /robots.txt for http://www.fict.org/
# comments to webmaster@fict.org
@@ -445,7 +447,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
public function test_rfc_unhipbot_10 ()
{
// {{{
$robotstxt = new robotstxt (
$robotstxt = new Robotstxt (
"# /robots.txt for http://www.fict.org/
# comments to webmaster@fict.org
@@ -470,7 +472,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
public function test_rfc_unhipbot_11 ()
{
// {{{
$robotstxt = new robotstxt (
$robotstxt = new Robotstxt (
"# /robots.txt for http://www.fict.org/
# comments to webmaster@fict.org
@@ -495,7 +497,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
public function test_rfc_webcrawler_1 ()
{
// {{{
$robotstxt = new robotstxt (
$robotstxt = new Robotstxt (
"# /robots.txt for http://www.fict.org/
# comments to webmaster@fict.org
@@ -520,7 +522,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
public function test_rfc_webcrawler_2 ()
{
// {{{
$robotstxt = new robotstxt (
$robotstxt = new Robotstxt (
"# /robots.txt for http://www.fict.org/
# comments to webmaster@fict.org
@@ -545,7 +547,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
public function test_rfc_webcrawler_3 ()
{
// {{{
$robotstxt = new robotstxt (
$robotstxt = new Robotstxt (
"# /robots.txt for http://www.fict.org/
# comments to webmaster@fict.org
@@ -570,7 +572,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
public function test_rfc_webcrawler_4 ()
{
// {{{
$robotstxt = new robotstxt (
$robotstxt = new Robotstxt (
"# /robots.txt for http://www.fict.org/
# comments to webmaster@fict.org
@@ -595,7 +597,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
public function test_rfc_webcrawler_5 ()
{
// {{{
$robotstxt = new robotstxt (
$robotstxt = new Robotstxt (
"# /robots.txt for http://www.fict.org/
# comments to webmaster@fict.org
@@ -620,7 +622,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
public function test_rfc_webcrawler_6 ()
{
// {{{
$robotstxt = new robotstxt (
$robotstxt = new Robotstxt (
"# /robots.txt for http://www.fict.org/
# comments to webmaster@fict.org
@@ -645,7 +647,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
public function test_rfc_webcrawler_7 ()
{
// {{{
$robotstxt = new robotstxt (
$robotstxt = new Robotstxt (
"# /robots.txt for http://www.fict.org/
# comments to webmaster@fict.org
@@ -670,7 +672,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
public function test_rfc_webcrawler_8 ()
{
// {{{
$robotstxt = new robotstxt (
$robotstxt = new Robotstxt (
"# /robots.txt for http://www.fict.org/
# comments to webmaster@fict.org
@@ -695,7 +697,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
public function test_rfc_webcrawler_9 ()
{
// {{{
$robotstxt = new robotstxt (
$robotstxt = new Robotstxt (
"# /robots.txt for http://www.fict.org/
# comments to webmaster@fict.org
@@ -720,7 +722,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
public function test_rfc_webcrawler_10 ()
{
// {{{
$robotstxt = new robotstxt (
$robotstxt = new Robotstxt (
"# /robots.txt for http://www.fict.org/
# comments to webmaster@fict.org
@@ -745,7 +747,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
public function test_rfc_webcrawler_11 ()
{
// {{{
$robotstxt = new robotstxt (
$robotstxt = new Robotstxt (
"# /robots.txt for http://www.fict.org/
# comments to webmaster@fict.org
@@ -770,7 +772,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
public function test_rfc_excite_1 ()
{
// {{{
$robotstxt = new robotstxt (
$robotstxt = new Robotstxt (
"# /robots.txt for http://www.fict.org/
# comments to webmaster@fict.org
@@ -795,7 +797,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
public function test_rfc_excite_2 ()
{
// {{{
$robotstxt = new robotstxt (
$robotstxt = new Robotstxt (
"# /robots.txt for http://www.fict.org/
# comments to webmaster@fict.org
@@ -820,7 +822,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
public function test_rfc_excite_3 ()
{
// {{{
$robotstxt = new robotstxt (
$robotstxt = new Robotstxt (
"# /robots.txt for http://www.fict.org/
# comments to webmaster@fict.org
@@ -845,7 +847,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
public function test_rfc_excite_4 ()
{
// {{{
$robotstxt = new robotstxt (
$robotstxt = new Robotstxt (
"# /robots.txt for http://www.fict.org/
# comments to webmaster@fict.org
@@ -870,7 +872,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
public function test_rfc_excite_5 ()
{
// {{{
$robotstxt = new robotstxt (
$robotstxt = new Robotstxt (
"# /robots.txt for http://www.fict.org/
# comments to webmaster@fict.org
@@ -895,7 +897,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
public function test_rfc_excite_6 ()
{
// {{{
$robotstxt = new robotstxt (
$robotstxt = new Robotstxt (
"# /robots.txt for http://www.fict.org/
# comments to webmaster@fict.org
@@ -920,7 +922,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
public function test_rfc_excite_7 ()
{
// {{{
$robotstxt = new robotstxt (
$robotstxt = new Robotstxt (
"# /robots.txt for http://www.fict.org/
# comments to webmaster@fict.org
@@ -945,7 +947,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
public function test_rfc_excite_8 ()
{
// {{{
$robotstxt = new robotstxt (
$robotstxt = new Robotstxt (
"# /robots.txt for http://www.fict.org/
# comments to webmaster@fict.org
@@ -970,7 +972,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
public function test_rfc_excite_9 ()
{
// {{{
$robotstxt = new robotstxt (
$robotstxt = new Robotstxt (
"# /robots.txt for http://www.fict.org/
# comments to webmaster@fict.org
@@ -995,7 +997,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
public function test_rfc_excite_10 ()
{
// {{{
$robotstxt = new robotstxt (
$robotstxt = new Robotstxt (
"# /robots.txt for http://www.fict.org/
# comments to webmaster@fict.org
@@ -1020,7 +1022,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
public function test_rfc_excite_11 ()
{
// {{{
$robotstxt = new robotstxt (
$robotstxt = new Robotstxt (
"# /robots.txt for http://www.fict.org/
# comments to webmaster@fict.org
@@ -1045,7 +1047,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
public function test_rfc_other_1 ()
{
// {{{
$robotstxt = new robotstxt (
$robotstxt = new Robotstxt (
"# /robots.txt for http://www.fict.org/
# comments to webmaster@fict.org
@@ -1069,7 +1071,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
public function test_rfc_other_2 ()
{
// {{{
$robotstxt = new robotstxt (
$robotstxt = new Robotstxt (
"# /robots.txt for http://www.fict.org/
# comments to webmaster@fict.org
@@ -1094,7 +1096,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
public function test_rfc_other_3 ()
{
// {{{
$robotstxt = new robotstxt (
$robotstxt = new Robotstxt (
"# /robots.txt for http://www.fict.org/
# comments to webmaster@fict.org
@@ -1119,7 +1121,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
public function test_rfc_other_4 ()
{
// {{{
$robotstxt = new robotstxt (
$robotstxt = new Robotstxt (
"# /robots.txt for http://www.fict.org/
# comments to webmaster@fict.org
@@ -1144,7 +1146,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
public function test_rfc_other_5 ()
{
// {{{
$robotstxt = new robotstxt (
$robotstxt = new Robotstxt (
"# /robots.txt for http://www.fict.org/
# comments to webmaster@fict.org
@@ -1169,7 +1171,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
public function test_rfc_other_6 ()
{
// {{{
$robotstxt = new robotstxt (
$robotstxt = new Robotstxt (
"# /robots.txt for http://www.fict.org/
# comments to webmaster@fict.org
@@ -1194,7 +1196,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
public function test_rfc_other_7 ()
{
// {{{
$robotstxt = new robotstxt (
$robotstxt = new Robotstxt (
"# /robots.txt for http://www.fict.org/
# comments to webmaster@fict.org
@@ -1219,7 +1221,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
public function test_rfc_other_8 ()
{
// {{{
$robotstxt = new robotstxt (
$robotstxt = new Robotstxt (
"# /robots.txt for http://www.fict.org/
# comments to webmaster@fict.org
@@ -1244,7 +1246,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
public function test_rfc_other_9 ()
{
// {{{
$robotstxt = new robotstxt (
$robotstxt = new Robotstxt (
"# /robots.txt for http://www.fict.org/
# comments to webmaster@fict.org
@@ -1269,7 +1271,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
public function test_rfc_other_10 ()
{
// {{{
$robotstxt = new robotstxt (
$robotstxt = new Robotstxt (
"# /robots.txt for http://www.fict.org/
# comments to webmaster@fict.org
@@ -1294,7 +1296,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
public function test_rfc_other_11 ()
{
// {{{
$robotstxt = new robotstxt (
$robotstxt = new Robotstxt (
"# /robots.txt for http://www.fict.org/
# comments to webmaster@fict.org