"));
+ }
// Chaining
- public function testChain1 ()
- {
- $this->expectOutputString("t1
t2
");
- $md = new Markdown ();
- printf ($md->html ("# t1\n## t2"));
- }
+ public function testChain1()
+ {
+ $this->expectOutputString("t1
t2
");
+ $md = new Markdown();
+ printf($md->html("# t1\n## t2"));
+ }
- public function testChainCode1 ()
- {
- $this->expectOutputString("
+ public function testChainCode1()
+ {
+ $this->expectOutputString("
* OK
");
- $md = new Markdown ();
- printf ($md->html (" \n * OK"));
- }
+ $md = new Markdown();
+ printf($md->html(" \n * OK"));
+ }
- public function testChainCode2 ()
- {
- $this->expectOutputString("
+ public function testChainCode2()
+ {
+ $this->expectOutputString("
* * * * * www-data OK
");
- $md = new Markdown ();
- printf ($md->html (" \n * * * * * www-data OK"));
- }
+ $md = new Markdown();
+ printf($md->html(" \n * * * * * www-data OK"));
+ }
- public function testChainCode3 ()
- {
- $this->expectOutputString("To write
+ public function testChainCode3()
+ {
+ $this->expectOutputString("To write
* * * * * www-data OK
");
- $md = new Markdown ();
- printf ($md->html ("To write
+ $md = new Markdown();
+ printf($md->html("To write
* * * * * www-data OK"));
- }
+ }
- public function testUnnumberredAndText1 ()
- {
- $this->expectOutputString("Hi
+ public function testUnnumberredAndText1()
+ {
+ $this->expectOutputString("Hi
");
- $md = new Markdown ();
- printf ($md->html ("Hi
+ $md = new Markdown();
+ printf($md->html("Hi
* line1
* line2
end"));
- }
+ }
- public function testCarriageReturn1 ()
- {
- $this->expectOutputString("line1 line2
");
- $md = new Markdown ();
- printf ($md->html ("line1\nline2\n"));
- }
+ public function testCarriageReturn1()
+ {
+ $this->expectOutputString("line1 line2
");
+ $md = new Markdown();
+ printf($md->html("line1\nline2\n"));
+ }
- public function testCarriageReturn2 ()
- {
- $this->expectOutputString("line1
line2
");
- $md = new Markdown ();
- printf ($md->html ("line1 \nline2\n"));
- }
+ public function testCarriageReturn2()
+ {
+ $this->expectOutputString("line1
line2
");
+ $md = new Markdown();
+ printf($md->html("line1 \nline2\n"));
+ }
- public function testCarriageReturn3 ()
- {
- $this->expectOutputString("line1 line2 line3.
");
- $md = new Markdown ();
- printf ($md->html ("line1
+ public function testCarriageReturn3()
+ {
+ $this->expectOutputString("line1 line2 line3.
");
+ $md = new Markdown();
+ printf($md->html("line1
line2
line3."));
- }
+ }
- public function testHTMLSpecialChars1 ()
- {
- $this->expectOutputString("toto&titi
");
- $md = new Markdown ();
- printf ($md->html ("toto&titi"));
- }
+ public function testHTMLSpecialChars1()
+ {
+ $this->expectOutputString("toto&titi
");
+ $md = new Markdown();
+ printf($md->html("toto&titi"));
+ }
- public function testHTMLSpecialChars2 ()
- {
- $this->expectOutputString("totoétiti
");
- $md = new Markdown ();
- printf ($md->html ("totoétiti"));
- }
+ public function testHTMLSpecialChars2()
+ {
+ $this->expectOutputString("totoétiti
");
+ $md = new Markdown();
+ printf($md->html("totoétiti"));
+ }
}
diff --git a/Tests/OutputdlTest.php b/Tests/OutputdlTest.php
index a4b9440..4b240f4 100644
--- a/Tests/OutputdlTest.php
+++ b/Tests/OutputdlTest.php
@@ -1,4 +1,5 @@
@@ -12,97 +13,102 @@ use Domframework\Outputdl;
/** Test the Outputdl.php file */
class OutputdlTest extends \PHPUnit_Framework_TestCase
{
- public function test_outputdl_init ()
- {
- exec ("rm -f /tmp/testDFWoutputDL*");
- file_put_contents ("/tmp/testDFWoutputDL",
- str_repeat (
- "1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\n",
- 1000)
- );
- symlink ("/etc/passwd", "/tmp/testDFWoutputDL2");
- symlink ("/tmp/testDFWoutputDL", "/tmp/testDFWoutputDL3");
- }
+ public function test_outputdl_init()
+ {
+ exec("rm -f /tmp/testDFWoutputDL*");
+ file_put_contents(
+ "/tmp/testDFWoutputDL",
+ str_repeat(
+ "1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\n",
+ 1000
+ )
+ );
+ symlink("/etc/passwd", "/tmp/testDFWoutputDL2");
+ symlink("/tmp/testDFWoutputDL", "/tmp/testDFWoutputDL3");
+ }
- public function test_outputdl_1 ()
- {
- // Check the full download content
- $outputdl = new Outputdl ();
- $this->expectOutputString (str_repeat (
- "1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\n",
- 1000));
- $outputdl->downloadFile ("/tmp/testDFWoutputDL");
- }
+ public function test_outputdl_1()
+ {
+ // Check the full download content
+ $outputdl = new Outputdl();
+ $this->expectOutputString(str_repeat(
+ "1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\n",
+ 1000
+ ));
+ $outputdl->downloadFile("/tmp/testDFWoutputDL");
+ }
- public function test_outputdl_Announce_1 ()
- {
- // Check the announce of Resume mode Enabled
- $outputdl = new Outputdl ();
- $outputdl->downloadFile ("/tmp/testDFWoutputDL");
- $res = $outputdl->headers ();
- $this->assertSame (in_array ("Accept-Ranges: bytes", $res), true);
- }
+ public function test_outputdl_Announce_1()
+ {
+ // Check the announce of Resume mode Enabled
+ $outputdl = new Outputdl();
+ $outputdl->downloadFile("/tmp/testDFWoutputDL");
+ $res = $outputdl->headers();
+ $this->assertSame(in_array("Accept-Ranges: bytes", $res), true);
+ }
- public function test_outputdl_Announce_2 ()
- {
- // Check the announce of Resume mode Disabled
- $outputdl = new Outputdl ();
- $outputdl->resumeAllow (false);
- $outputdl->downloadFile ("/tmp/testDFWoutputDL");
- $res = $outputdl->headers ();
- $this->assertSame (in_array ("Accept-Ranges: none", $res), true);
- }
+ public function test_outputdl_Announce_2()
+ {
+ // Check the announce of Resume mode Disabled
+ $outputdl = new Outputdl();
+ $outputdl->resumeAllow(false);
+ $outputdl->downloadFile("/tmp/testDFWoutputDL");
+ $res = $outputdl->headers();
+ $this->assertSame(in_array("Accept-Ranges: none", $res), true);
+ }
- public function test_outputdl_Partial_1 ()
- {
- // Check the content get with provided range
- $outputdl = new Outputdl ();
- $_SERVER["HTTP_RANGE"] = "bytes=3-9";
- $this->expectOutputString ("4567890");
- $outputdl->downloadFile ("/tmp/testDFWoutputDL");
- unset ($_SERVER["HTTP_RANGE"]);
- }
+ public function test_outputdl_Partial_1()
+ {
+ // Check the content get with provided range
+ $outputdl = new Outputdl();
+ $_SERVER["HTTP_RANGE"] = "bytes=3-9";
+ $this->expectOutputString("4567890");
+ $outputdl->downloadFile("/tmp/testDFWoutputDL");
+ unset($_SERVER["HTTP_RANGE"]);
+ }
- public function test_outputdl_Partial_2 ()
- {
- // Check the content get with provided range
- $outputdl = new Outputdl ();
- $_SERVER["HTTP_RANGE"] = "bytes=3-";
- $this->expectOutputString (substr (str_repeat (
- "1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\n",
- 1000), 3));
- $outputdl->downloadFile ("/tmp/testDFWoutputDL");
- unset ($_SERVER["HTTP_RANGE"]);
- }
+ public function test_outputdl_Partial_2()
+ {
+ // Check the content get with provided range
+ $outputdl = new Outputdl();
+ $_SERVER["HTTP_RANGE"] = "bytes=3-";
+ $this->expectOutputString(substr(str_repeat(
+ "1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\n",
+ 1000
+ ), 3));
+ $outputdl->downloadFile("/tmp/testDFWoutputDL");
+ unset($_SERVER["HTTP_RANGE"]);
+ }
- public function test_outputdl_Partial_3 ()
- {
- // Check the content get with provided range
- $outputdl = new Outputdl ();
- $_SERVER["HTTP_RANGE"] = "bytes=0-";
- $this->expectOutputString (str_repeat (
- "1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\n",
- 1000));
- $outputdl->downloadFile ("/tmp/testDFWoutputDL");
- unset ($_SERVER["HTTP_RANGE"]);
- }
+ public function test_outputdl_Partial_3()
+ {
+ // Check the content get with provided range
+ $outputdl = new Outputdl();
+ $_SERVER["HTTP_RANGE"] = "bytes=0-";
+ $this->expectOutputString(str_repeat(
+ "1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\n",
+ 1000
+ ));
+ $outputdl->downloadFile("/tmp/testDFWoutputDL");
+ unset($_SERVER["HTTP_RANGE"]);
+ }
- public function test_outputdl_Partial_4 ()
- {
- // Check the content get with provided range
- $outputdl = new Outputdl ();
- $_SERVER["HTTP_RANGE"] = "bytes=-5";
- $this->expectOutputString ("wxyz\n");
- $outputdl->downloadFile ("/tmp/testDFWoutputDL");
- unset ($_SERVER["HTTP_RANGE"]);
- }
+ public function test_outputdl_Partial_4()
+ {
+ // Check the content get with provided range
+ $outputdl = new Outputdl();
+ $_SERVER["HTTP_RANGE"] = "bytes=-5";
+ $this->expectOutputString("wxyz\n");
+ $outputdl->downloadFile("/tmp/testDFWoutputDL");
+ unset($_SERVER["HTTP_RANGE"]);
+ }
- public function test_outputdl_Partial_5 ()
- {
- // Check the content get with provided range
- $outputdl = new Outputdl ();
- $_SERVER["HTTP_RANGE"] = "bytes=0-3,6-9";
- $this->expectOutputString ("--Qm91bmRhcnk=\r
+ public function test_outputdl_Partial_5()
+ {
+ // Check the content get with provided range
+ $outputdl = new Outputdl();
+ $_SERVER["HTTP_RANGE"] = "bytes=0-3,6-9";
+ $this->expectOutputString("--Qm91bmRhcnk=\r
Content-Range: bytes 0-3/63000\r
Content-Type: application/octet-stream\r
\r
@@ -114,92 +120,102 @@ Content-Type: application/octet-stream\r
7890\r
--Qm91bmRhcnk=--\r
");
- $outputdl->downloadFile ("/tmp/testDFWoutputDL");
- unset ($_SERVER["HTTP_RANGE"]);
- }
+ $outputdl->downloadFile("/tmp/testDFWoutputDL");
+ unset($_SERVER["HTTP_RANGE"]);
+ }
- public function test_outputdl_PartialWrong_1 ()
- {
- // Check the invalid provided range
- unset ($_SERVER["HTTP_RANGE"]);
- $outputdl = new Outputdl ();
- $_SERVER["HTTP_RANGE"] = "bytes=99999-";
- $this->expectException ("Exception", "Invalid range provided", 416);
- $outputdl->downloadFile ("/tmp/testDFWoutputDL");
- }
+ public function test_outputdl_PartialWrong_1()
+ {
+ // Check the invalid provided range
+ unset($_SERVER["HTTP_RANGE"]);
+ $outputdl = new Outputdl();
+ $_SERVER["HTTP_RANGE"] = "bytes=99999-";
+ $this->expectException("Exception", "Invalid range provided", 416);
+ $outputdl->downloadFile("/tmp/testDFWoutputDL");
+ }
- public function test_outputdl_PartialWrong_2 ()
- {
- // Check the invalid provided range
- unset ($_SERVER["HTTP_RANGE"]);
- $outputdl = new Outputdl ();
- $_SERVER["HTTP_RANGE"] = "bytes=9-3";
- $this->expectException ("Exception", "Invalid range provided", 416);
- $outputdl->downloadFile ("/tmp/testDFWoutputDL");
- }
+ public function test_outputdl_PartialWrong_2()
+ {
+ // Check the invalid provided range
+ unset($_SERVER["HTTP_RANGE"]);
+ $outputdl = new Outputdl();
+ $_SERVER["HTTP_RANGE"] = "bytes=9-3";
+ $this->expectException("Exception", "Invalid range provided", 416);
+ $outputdl->downloadFile("/tmp/testDFWoutputDL");
+ }
- public function test_outputdl_PartialWrong_3 ()
- {
- // Check the invalid provided range
- unset ($_SERVER["HTTP_RANGE"]);
- $outputdl = new Outputdl ();
- $_SERVER["HTTP_RANGE"] = "bytes=9-999999";
- $this->expectException ("Exception", "Invalid range provided", 416);
- $outputdl->downloadFile ("/tmp/testDFWoutputDL");
- }
+ public function test_outputdl_PartialWrong_3()
+ {
+ // Check the invalid provided range
+ unset($_SERVER["HTTP_RANGE"]);
+ $outputdl = new Outputdl();
+ $_SERVER["HTTP_RANGE"] = "bytes=9-999999";
+ $this->expectException("Exception", "Invalid range provided", 416);
+ $outputdl->downloadFile("/tmp/testDFWoutputDL");
+ }
- public function test_outputdl_PartialWrong_4 ()
- {
- // Check the invalid provided range
- unset ($_SERVER["HTTP_RANGE"]);
- $outputdl = new Outputdl ();
- $_SERVER["HTTP_RANGE"] = "bytes=-";
- $this->expectException ("Exception", "Invalid range provided", 416);
- $outputdl->downloadFile ("/tmp/testDFWoutputDL");
- }
+ public function test_outputdl_PartialWrong_4()
+ {
+ // Check the invalid provided range
+ unset($_SERVER["HTTP_RANGE"]);
+ $outputdl = new Outputdl();
+ $_SERVER["HTTP_RANGE"] = "bytes=-";
+ $this->expectException("Exception", "Invalid range provided", 416);
+ $outputdl->downloadFile("/tmp/testDFWoutputDL");
+ }
- public function test_outputdl_invalidBase_1 ()
- {
- // Check the base comparison : OK
- unset ($_SERVER["HTTP_RANGE"]);
- $outputdl = new Outputdl ();
- $outputdl->base ("/tmp");
- $this->expectOutputString (str_repeat (
- "1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\n",
- 1000));
- $outputdl->downloadFile ("/tmp/testDFWoutputDL");
- }
+ public function test_outputdl_invalidBase_1()
+ {
+ // Check the base comparison : OK
+ unset($_SERVER["HTTP_RANGE"]);
+ $outputdl = new Outputdl();
+ $outputdl->base("/tmp");
+ $this->expectOutputString(str_repeat(
+ "1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\n",
+ 1000
+ ));
+ $outputdl->downloadFile("/tmp/testDFWoutputDL");
+ }
- public function test_outputdl_invalidBase_2 ()
- {
- // Check the base comparison : BAD
- unset ($_SERVER["HTTP_RANGE"]);
- $outputdl = new Outputdl ();
- $outputdl->base ("/tmp");
- $this->expectException ("Exception",
- "Invalid file to download : out of base", 406);
- $outputdl->downloadFile ("../../../../../..//etc/passwd");
- }
+ public function test_outputdl_invalidBase_2()
+ {
+ // Check the base comparison : BAD
+ unset($_SERVER["HTTP_RANGE"]);
+ $outputdl = new Outputdl();
+ $outputdl->base("/tmp");
+ $this->expectException(
+ "Exception",
+ "Invalid file to download : out of base",
+ 406
+ );
+ $outputdl->downloadFile("../../../../../..//etc/passwd");
+ }
- public function test_outputdl_invalidFile_1 ()
- {
- // Check the base comparison : BAD Symlink
- unset ($_SERVER["HTTP_RANGE"]);
- $outputdl = new Outputdl ();
- $outputdl->base ("/tmp");
- $this->expectException ("Exception",
- "Invalid file to download : not a file", 406);
- $outputdl->downloadFile ("/tmp/testDFWoutputDL3");
- }
+ public function test_outputdl_invalidFile_1()
+ {
+ // Check the base comparison : BAD Symlink
+ unset($_SERVER["HTTP_RANGE"]);
+ $outputdl = new Outputdl();
+ $outputdl->base("/tmp");
+ $this->expectException(
+ "Exception",
+ "Invalid file to download : not a file",
+ 406
+ );
+ $outputdl->downloadFile("/tmp/testDFWoutputDL3");
+ }
- public function test_outputdl_invalidFile_2 ()
- {
- // Check the base comparison : Non existing
- unset ($_SERVER["HTTP_RANGE"]);
- $outputdl = new Outputdl ();
- $outputdl->base ("/tmp");
- $this->expectException ("Exception",
- "Invalid file to download : file doesn't exists", 404);
- $outputdl->downloadFile ("/tmp/testDFWoutputNON");
- }
+ public function test_outputdl_invalidFile_2()
+ {
+ // Check the base comparison : Non existing
+ unset($_SERVER["HTTP_RANGE"]);
+ $outputdl = new Outputdl();
+ $outputdl->base("/tmp");
+ $this->expectException(
+ "Exception",
+ "Invalid file to download : file doesn't exists",
+ 404
+ );
+ $outputdl->downloadFile("/tmp/testDFWoutputNON");
+ }
}
diff --git a/Tests/OutputhtmlTest.php b/Tests/OutputhtmlTest.php
index 178003e..2c45a62 100644
--- a/Tests/OutputhtmlTest.php
+++ b/Tests/OutputhtmlTest.php
@@ -1,4 +1,5 @@
@@ -13,52 +14,59 @@ use Domframework\Outputhtml;
class OutputhtmlTest extends \PHPUnit_Framework_TestCase
{
/** Entry null */
- public function testlayout1 ()
- {
- $this->expectOutputRegex ("#\s+#");
- $output = new Outputhtml ();
- $res = $output->out ("");
- }
+ public function testlayout1()
+ {
+ $this->expectOutputRegex("#\s+#");
+ $output = new Outputhtml();
+ $res = $output->out("");
+ }
- public function testlayout2 ()
- {
- $this->expectOutputRegex("#data#");
- $output = new Outputhtml ();
- $res = $output->out ("data");
- }
+ public function testlayout2()
+ {
+ $this->expectOutputRegex("#data#");
+ $output = new Outputhtml();
+ $res = $output->out("data");
+ }
- public function testlayout3 ()
- {
- $this->expectOutputRegex("#data#");
- $output = new Outputhtml ();
- $res = $output->out ("data", "title");
- }
+ public function testlayout3()
+ {
+ $this->expectOutputRegex("#data#");
+ $output = new Outputhtml();
+ $res = $output->out("data", "title");
+ }
- public function testlayout4 ()
- {
- $this->expectOutputString("
+ public function testlayout4()
+ {
+ $this->expectOutputString("
Text
-"." "."
+" . " " . "
\n");
- $output = new Outputhtml ();
- $output->out ("data", "title", FALSE, FALSE, "Tests/layout.html" );
- }
+ $output = new Outputhtml();
+ $output->out("data", "title", false, false, "Tests/layout.html");
+ }
- public function testlayout5 ()
- {
- $this->expectOutputString("
+ public function testlayout5()
+ {
+ $this->expectOutputString("
Text
VARIABLE
\n");
- $output = new Outputhtml ();
- $variable = array ("var"=>"VARIABLE");
- $output->out ("data", "title", FALSE, FALSE, "Tests/layout.html",
- null, $variable);
- }
+ $output = new Outputhtml();
+ $variable = array ("var" => "VARIABLE");
+ $output->out(
+ "data",
+ "title",
+ false,
+ false,
+ "Tests/layout.html",
+ null,
+ $variable
+ );
+ }
}
diff --git a/Tests/OutputjsonTest.php b/Tests/OutputjsonTest.php
index a04e07a..e41167b 100644
--- a/Tests/OutputjsonTest.php
+++ b/Tests/OutputjsonTest.php
@@ -1,4 +1,5 @@
@@ -13,26 +14,26 @@ use Domframework\Outputjson;
class OutputjsonTest extends \PHPUnit_Framework_TestCase
{
/** Entry null */
- public function testoutputjson1 ()
- {
- $this->expectOutputString("\"\"");
- $output = new Outputjson ();
- $output->out ("");
- }
+ public function testoutputjson1()
+ {
+ $this->expectOutputString("\"\"");
+ $output = new Outputjson();
+ $output->out("");
+ }
/** Entry string */
- public function testoutputjson2 ()
- {
- $this->expectOutputString("\"string\"");
- $output = new Outputjson ();
- $output->out ("string");
- }
+ public function testoutputjson2()
+ {
+ $this->expectOutputString("\"string\"");
+ $output = new Outputjson();
+ $output->out("string");
+ }
/** Entry array */
- public function testoutputjson3 ()
- {
- $this->expectOutputString("[1,2,3]");
- $output = new Outputjson ();
- $output->out (array (1,2,3));
- }
+ public function testoutputjson3()
+ {
+ $this->expectOutputString("[1,2,3]");
+ $output = new Outputjson();
+ $output->out(array (1,2,3));
+ }
}
diff --git a/Tests/PasswordTest.php b/Tests/PasswordTest.php
index aa401c3..bc30245 100644
--- a/Tests/PasswordTest.php
+++ b/Tests/PasswordTest.php
@@ -1,4 +1,5 @@
@@ -13,224 +14,237 @@ use Domframework\Password;
*/
class PasswordTest extends \PHPUnit_Framework_TestCase
{
- public function test_cryptPasswd_1 ()
- {
- $res = Password::cryptPasswd ("AAA");
- $this->assertSame ($res[0] == "$" && strlen ($res) > 8, true);
- }
+ public function test_cryptPasswd_1()
+ {
+ $res = Password::cryptPasswd("AAA");
+ $this->assertSame($res[0] == "$" && strlen($res) > 8, true);
+ }
- public function test_cryptPasswd_2 ()
- {
- // Test the randomization of the salt : must be different each time
- $res1 = Password::cryptPasswd ("AAA");
- echo "RES1=$res1\n";
- $res2 = Password::cryptPasswd ("AAA");
- echo "RES2=$res2\n";
- $res3 = Password::cryptPasswd ("AAA");
- echo "RES3=$res3\n";
- $this->assertSame (count (array_unique (array ($res1, $res2, $res3))), 3);
- // Three passwords : each must have a different result
- }
+ public function test_cryptPasswd_2()
+ {
+ // Test the randomization of the salt : must be different each time
+ $res1 = Password::cryptPasswd("AAA");
+ echo "RES1=$res1\n";
+ $res2 = Password::cryptPasswd("AAA");
+ echo "RES2=$res2\n";
+ $res3 = Password::cryptPasswd("AAA");
+ echo "RES3=$res3\n";
+ $this->assertSame(count(array_unique(array ($res1, $res2, $res3))), 3);
+ // Three passwords : each must have a different result
+ }
- public function test_cryptPasswd_3 ()
- {
- $this->expectException ();
- $res = Password::cryptPasswd (false);
- }
+ public function test_cryptPasswd_3()
+ {
+ $this->expectException();
+ $res = Password::cryptPasswd(false);
+ }
- public function test_cryptPassword_MYSQL ()
- {
- $password = new password ();
- $res = $password->cryptPassword ("AAA", "MYSQL");
- $this->assertSame ($res, "*5AF9D0EA5F6406FB0EDD0507F81C1D5CEBE8AC9C");
- }
+ public function test_cryptPassword_MYSQL()
+ {
+ $password = new password();
+ $res = $password->cryptPassword("AAA", "MYSQL");
+ $this->assertSame($res, "*5AF9D0EA5F6406FB0EDD0507F81C1D5CEBE8AC9C");
+ }
- public function test_cryptPassword_CRYPT_STD_DES ()
- {
- $password = new password ();
- $res = $password->cryptPassword ("AAA", "CRYPT_STD_DES");
- $this->assertSame (strlen ($res), 13);
- }
+ public function test_cryptPassword_CRYPT_STD_DES()
+ {
+ $password = new password();
+ $res = $password->cryptPassword("AAA", "CRYPT_STD_DES");
+ $this->assertSame(strlen($res), 13);
+ }
- public function test_cryptPassword_CRYPT_EXT_DES ()
- {
- $password = new password ();
- $res = $password->cryptPassword ("AAA", "CRYPT_EXT_DES");
- $this->assertSame (strlen ($res), 13);
- }
+ public function test_cryptPassword_CRYPT_EXT_DES()
+ {
+ $password = new password();
+ $res = $password->cryptPassword("AAA", "CRYPT_EXT_DES");
+ $this->assertSame(strlen($res), 13);
+ }
- public function test_cryptPassword_CRYPT_MD5 ()
- {
- $password = new password ();
- $res = $password->cryptPassword ("AAA", "CRYPT_MD5");
- $this->assertSame (substr ($res, 0, 3) === "$1$" && strlen ($res) === 34,
- true);
- }
+ public function test_cryptPassword_CRYPT_MD5()
+ {
+ $password = new password();
+ $res = $password->cryptPassword("AAA", "CRYPT_MD5");
+ $this->assertSame(
+ substr($res, 0, 3) === "$1$" && strlen($res) === 34,
+ true
+ );
+ }
- public function test_cryptPassword_CRYPT_BLOWFISH ()
- {
- $password = new password ();
- $res = $password->cryptPassword ("AAA", "CRYPT_BLOWFISH");
- $this->assertSame (substr ($res, 0, 4) === "$2y$" && strlen ($res) === 24,
- true);
- }
+ public function test_cryptPassword_CRYPT_BLOWFISH()
+ {
+ $password = new password();
+ $res = $password->cryptPassword("AAA", "CRYPT_BLOWFISH");
+ $this->assertSame(
+ substr($res, 0, 4) === "$2y$" && strlen($res) === 24,
+ true
+ );
+ }
- public function test_cryptPassword_CRYPT_SHA256 ()
- {
- $password = new password ();
- $res = $password->cryptPassword ("AAA", "CRYPT_SHA256");
- $this->assertSame (
- substr ($res, 0, 10) === "$5\$rounds=" && strlen ($res) === 75,
- true);
- }
+ public function test_cryptPassword_CRYPT_SHA256()
+ {
+ $password = new password();
+ $res = $password->cryptPassword("AAA", "CRYPT_SHA256");
+ $this->assertSame(
+ substr($res, 0, 10) === "$5\$rounds=" && strlen($res) === 75,
+ true
+ );
+ }
- public function test_cryptPassword_CRYPT_SHA512 ()
- {
- $password = new password ();
- $res = $password->cryptPassword ("AAA", "CRYPT_SHA512");
- $this->assertSame (
- substr ($res, 0, 10) === "$6\$rounds=" && strlen ($res) === 118,
- true);
- }
+ public function test_cryptPassword_CRYPT_SHA512()
+ {
+ $password = new password();
+ $res = $password->cryptPassword("AAA", "CRYPT_SHA512");
+ $this->assertSame(
+ substr($res, 0, 10) === "$6\$rounds=" && strlen($res) === 118,
+ true
+ );
+ }
- public function test_cryptPassword_PASSWORD_BCRYPT ()
- {
- $password = new password ();
- $res = $password->cryptPassword ("AAA", "PASSWORD_BCRYPT");
- $this->assertSame (
- substr ($res, 0, 7) === "$2y\$10\$" && strlen ($res) === 60,
- true);
- }
+ public function test_cryptPassword_PASSWORD_BCRYPT()
+ {
+ $password = new password();
+ $res = $password->cryptPassword("AAA", "PASSWORD_BCRYPT");
+ $this->assertSame(
+ substr($res, 0, 7) === "$2y\$10\$" && strlen($res) === 60,
+ true
+ );
+ }
- public function test_cryptPassword_PASSWORD_ARGON2I ()
- {
- $password = new password ();
- $res = $password->cryptPassword ("AAA", "PASSWORD_ARGON2I");
- $this->assertSame (
- substr ($res, 0, 11) === "\$argon2i\$v=" && strlen ($res) === 96,
- true);
- }
+ public function test_cryptPassword_PASSWORD_ARGON2I()
+ {
+ $password = new password();
+ $res = $password->cryptPassword("AAA", "PASSWORD_ARGON2I");
+ $this->assertSame(
+ substr($res, 0, 11) === "\$argon2i\$v=" && strlen($res) === 96,
+ true
+ );
+ }
- public function test_cryptPassword_PASSWORD_ARGON2ID ()
- {
- $password = new password ();
- $res = $password->cryptPassword ("AAA", "PASSWORD_ARGON2ID");
- $this->assertSame (
- substr ($res, 0, 12) === "\$argon2id\$v=" && strlen ($res) === 97,
- true);
- }
+ public function test_cryptPassword_PASSWORD_ARGON2ID()
+ {
+ $password = new password();
+ $res = $password->cryptPassword("AAA", "PASSWORD_ARGON2ID");
+ $this->assertSame(
+ substr($res, 0, 12) === "\$argon2id\$v=" && strlen($res) === 97,
+ true
+ );
+ }
- public function test_cryptPassword_UNKNOWN ()
- {
- $this->expectException ();
- $password = new password ();
- $res = $password->cryptPassword ("AAA", "UNKNOWN");
- }
+ public function test_cryptPassword_UNKNOWN()
+ {
+ $this->expectException();
+ $password = new password();
+ $res = $password->cryptPassword("AAA", "UNKNOWN");
+ }
- public function test_checkPassword_1 ()
- {
- $res = Password::checkPassword ("AAA", "AAA");
- $this->assertSame ($res, false);
- }
+ public function test_checkPassword_1()
+ {
+ $res = Password::checkPassword("AAA", "AAA");
+ $this->assertSame($res, false);
+ }
- public function test_checkPassword_2 ()
- {
- $crypt = Password::cryptPasswd ("AAA");
- $res = Password::checkPassword ("AAA", $crypt);
- $this->assertSame ($res, true);
- }
+ public function test_checkPassword_2()
+ {
+ $crypt = Password::cryptPasswd("AAA");
+ $res = Password::checkPassword("AAA", $crypt);
+ $this->assertSame($res, true);
+ }
- public function test_checkPassword_3 ()
- {
- $res = Password::checkPassword ("AAA", Password::cryptPasswd ("BBB"));
- $this->assertSame ($res, false);
- }
+ public function test_checkPassword_3()
+ {
+ $res = Password::checkPassword("AAA", Password::cryptPasswd("BBB"));
+ $this->assertSame($res, false);
+ }
- public function test_checkPassword_4 ()
- {
- $res = Password::checkPassword ("AAA",
- '$2y$11$Y.E98jbjgDpV61eK..9MT.klzTeg7ulO4WH/B5yA8cAGMIh.zoNXq');
- $this->assertSame ($res, true);
- }
+ public function test_checkPassword_4()
+ {
+ $res = Password::checkPassword(
+ "AAA",
+ '$2y$11$Y.E98jbjgDpV61eK..9MT.klzTeg7ulO4WH/B5yA8cAGMIh.zoNXq'
+ );
+ $this->assertSame($res, true);
+ }
- public function test_checkPassword_invalid1 ()
- {
- $this->expectException ();
- $res = Password::checkPassword (false,
- '$2y$11$Y.E98jbjgDpV61eK..9MT.klzTeg7ulO4WH/B5yA8cAGMIh.zoNXq');
- }
+ public function test_checkPassword_invalid1()
+ {
+ $this->expectException();
+ $res = Password::checkPassword(
+ false,
+ '$2y$11$Y.E98jbjgDpV61eK..9MT.klzTeg7ulO4WH/B5yA8cAGMIh.zoNXq'
+ );
+ }
- public function test_checkPassword_invalid2 ()
- {
- $this->expectException ();
- $res = Password::checkPassword ("AAA", false);
- }
+ public function test_checkPassword_invalid2()
+ {
+ $this->expectException();
+ $res = Password::checkPassword("AAA", false);
+ }
- public function test_generateASCII_defaultsize ()
- {
- $res = Password::generateASCII ();
- $this->assertSame (strlen ($res), 12);
- }
+ public function test_generateASCII_defaultsize()
+ {
+ $res = Password::generateASCII();
+ $this->assertSame(strlen($res), 12);
+ }
- public function test_generateASCII_toobig ()
- {
- $this->expectException ();
- $res = Password::generateASCII (112);
- }
+ public function test_generateASCII_toobig()
+ {
+ $this->expectException();
+ $res = Password::generateASCII(112);
+ }
- public function test_generateASCII_toosmall ()
- {
- $this->expectException ();
- $res = Password::generateASCII (0);
- }
+ public function test_generateASCII_toosmall()
+ {
+ $this->expectException();
+ $res = Password::generateASCII(0);
+ }
- public function test_generateAlphanum_defaultsize ()
- {
- $res = Password::generateAlphanum ();
- $this->assertSame (strlen ($res), 12);
- }
+ public function test_generateAlphanum_defaultsize()
+ {
+ $res = Password::generateAlphanum();
+ $this->assertSame(strlen($res), 12);
+ }
- public function test_generateAlphanum_toobig ()
- {
- $this->expectException ();
- $res = Password::generateAlphanum (112);
- }
+ public function test_generateAlphanum_toobig()
+ {
+ $this->expectException();
+ $res = Password::generateAlphanum(112);
+ }
- public function test_generateAlphanum_toosmall ()
- {
- $this->expectException ();
- $res = Password::generateAlphanum (0);
- }
+ public function test_generateAlphanum_toosmall()
+ {
+ $this->expectException();
+ $res = Password::generateAlphanum(0);
+ }
- public function test_generateAlphabetical_defaultsize ()
- {
- $res = Password::generateAlphabetical ();
- $this->assertSame (strlen ($res), 12);
- }
+ public function test_generateAlphabetical_defaultsize()
+ {
+ $res = Password::generateAlphabetical();
+ $this->assertSame(strlen($res), 12);
+ }
- public function test_generateAlphabetical_toobig ()
- {
- $this->expectException ();
- $res = Password::generateAlphabetical (112);
- }
+ public function test_generateAlphabetical_toobig()
+ {
+ $this->expectException();
+ $res = Password::generateAlphabetical(112);
+ }
- public function test_generateAlphabetical_toosmall ()
- {
- $this->expectException ();
- $res = Password::generateAlphabetical (0);
- }
+ public function test_generateAlphabetical_toosmall()
+ {
+ $this->expectException();
+ $res = Password::generateAlphabetical(0);
+ }
- public function test_listMethods_1 ()
- {
- $password = new password ();
- $res = $password->listMethods();
- $this->assertSame (count ($res) > 7, true);
- }
+ public function test_listMethods_1()
+ {
+ $password = new password();
+ $res = $password->listMethods();
+ $this->assertSame(count($res) > 7, true);
+ }
- public function test_salt_1 ()
- {
- $password = new password ();
- $res = $password->salt();
- $this->assertSame (strlen ($res) > 20, true);
- }
+ public function test_salt_1()
+ {
+ $password = new password();
+ $res = $password->salt();
+ $this->assertSame(strlen($res) > 20, true);
+ }
}
diff --git a/Tests/QueueTest.php b/Tests/QueueTest.php
index 05b097b..d4915e2 100644
--- a/Tests/QueueTest.php
+++ b/Tests/QueueTest.php
@@ -1,4 +1,5 @@
@@ -12,8 +13,8 @@ use Domframework\Queue;
/** Test the Queue.php file */
class QueueTest extends \PHPUnit_Framework_TestCase
{
- public function test ()
- {
- $queue = new Queue ();
- }
+ public function test()
+ {
+ $queue = new Queue();
+ }
}
diff --git a/Tests/QueuefileTest.php b/Tests/QueuefileTest.php
index d6a9fb4..8aa6d0c 100644
--- a/Tests/QueuefileTest.php
+++ b/Tests/QueuefileTest.php
@@ -1,4 +1,5 @@
@@ -12,131 +13,131 @@ use Domframework\Queuefile;
/** Test the Queuefile.php file */
class QueuefileTest extends \PHPUnit_Framework_TestCase
{
- public function test_clean ()
- {
- if (file_exists ("/tmp/queuefileTest/queuefileTest.json"))
- unlink ("/tmp/queuefileTest/queuefileTest.json");
- }
+ public function test_clean()
+ {
+ if (file_exists("/tmp/queuefileTest/queuefileTest.json")) {
+ unlink("/tmp/queuefileTest/queuefileTest.json");
+ }
+ }
- public function test_add1 ()
- {
- $queuefile = new Queuefile ();
- $queuefile->connect ("file:///tmp/queuefileTest/queuefileTest.json");
- $res = $queuefile->add ("test1");
- $this->assertSame (true, is_object ($res));
- }
+ public function test_add1()
+ {
+ $queuefile = new Queuefile();
+ $queuefile->connect("file:///tmp/queuefileTest/queuefileTest.json");
+ $res = $queuefile->add("test1");
+ $this->assertSame(true, is_object($res));
+ }
- public function test_count1 ()
- {
- $queuefile = new Queuefile ();
- $queuefile->connect ("file:///tmp/queuefileTest/queuefileTest.json");
- $res = $queuefile->count ();
- $this->assertSame (1, $res);
- }
+ public function test_count1()
+ {
+ $queuefile = new Queuefile();
+ $queuefile->connect("file:///tmp/queuefileTest/queuefileTest.json");
+ $res = $queuefile->count();
+ $this->assertSame(1, $res);
+ }
- public function test_add2 ()
- {
- $queuefile = new Queuefile ();
- $queuefile->connect ("file:///tmp/queuefileTest/queuefileTest.json");
- $res = $queuefile->add ("test2");
- $this->assertSame (true, is_object ($res));
- }
+ public function test_add2()
+ {
+ $queuefile = new Queuefile();
+ $queuefile->connect("file:///tmp/queuefileTest/queuefileTest.json");
+ $res = $queuefile->add("test2");
+ $this->assertSame(true, is_object($res));
+ }
- public function test_count2 ()
- {
- $queuefile = new Queuefile ();
- $queuefile->connect ("file:///tmp/queuefileTest/queuefileTest.json");
- $res = $queuefile->count ();
- $this->assertSame (2, $res);
- }
+ public function test_count2()
+ {
+ $queuefile = new Queuefile();
+ $queuefile->connect("file:///tmp/queuefileTest/queuefileTest.json");
+ $res = $queuefile->count();
+ $this->assertSame(2, $res);
+ }
- public function test_getFirst1 ()
- {
- $queuefile = new Queuefile ();
- $queuefile->connect ("file:///tmp/queuefileTest/queuefileTest.json");
- $res = $queuefile->getFirst ();
- $this->assertSame ("test1", $res);
- }
+ public function test_getFirst1()
+ {
+ $queuefile = new Queuefile();
+ $queuefile->connect("file:///tmp/queuefileTest/queuefileTest.json");
+ $res = $queuefile->getFirst();
+ $this->assertSame("test1", $res);
+ }
- public function test_getLast1 ()
- {
- $queuefile = new Queuefile ();
- $queuefile->connect ("file:///tmp/queuefileTest/queuefileTest.json");
- $res = $queuefile->getLast ();
- $this->assertSame ("test2", $res);
- }
+ public function test_getLast1()
+ {
+ $queuefile = new Queuefile();
+ $queuefile->connect("file:///tmp/queuefileTest/queuefileTest.json");
+ $res = $queuefile->getLast();
+ $this->assertSame("test2", $res);
+ }
- public function test_getRange1 ()
- {
- $queuefile = new Queuefile ();
- $queuefile->connect ("file:///tmp/queuefileTest/queuefileTest.json");
- $res = $queuefile->getRange (1, 1);
- $this->assertSame (["test2"], $res);
- }
+ public function test_getRange1()
+ {
+ $queuefile = new Queuefile();
+ $queuefile->connect("file:///tmp/queuefileTest/queuefileTest.json");
+ $res = $queuefile->getRange(1, 1);
+ $this->assertSame(["test2"], $res);
+ }
- public function test_getRange2 ()
- {
- $queuefile = new Queuefile ();
- $queuefile->connect ("file:///tmp/queuefileTest/queuefileTest.json");
- $res = $queuefile->getRange (0, 2);
- $this->assertSame (["test1", "test2"], $res);
- }
+ public function test_getRange2()
+ {
+ $queuefile = new Queuefile();
+ $queuefile->connect("file:///tmp/queuefileTest/queuefileTest.json");
+ $res = $queuefile->getRange(0, 2);
+ $this->assertSame(["test1", "test2"], $res);
+ }
- public function test_getRange3 ()
- {
- $queuefile = new Queuefile ();
- $queuefile->connect ("file:///tmp/queuefileTest/queuefileTest.json");
- $this->expectException ();
- $res = $queuefile->getRange (0, 3);
- }
+ public function test_getRange3()
+ {
+ $queuefile = new Queuefile();
+ $queuefile->connect("file:///tmp/queuefileTest/queuefileTest.json");
+ $this->expectException();
+ $res = $queuefile->getRange(0, 3);
+ }
- public function test_getAll1 ()
- {
- $queuefile = new Queuefile ();
- $queuefile->connect ("file:///tmp/queuefileTest/queuefileTest.json");
- $res = $queuefile->getAll ();
- $this->assertSame (["test1", "test2"], $res);
- }
+ public function test_getAll1()
+ {
+ $queuefile = new Queuefile();
+ $queuefile->connect("file:///tmp/queuefileTest/queuefileTest.json");
+ $res = $queuefile->getAll();
+ $this->assertSame(["test1", "test2"], $res);
+ }
// AFTER THIS TEST THE FILE WILL BE EMPTY
- public function test_getAll2 ()
- {
- $queuefile = new Queuefile ();
- $queuefile->connect ("file:///tmp/queuefileTest/queuefileTest.json");
- $res = $queuefile->clear ();
- $this->assertSame (true, is_object ($res));
- }
+ public function test_getAll2()
+ {
+ $queuefile = new Queuefile();
+ $queuefile->connect("file:///tmp/queuefileTest/queuefileTest.json");
+ $res = $queuefile->clear();
+ $this->assertSame(true, is_object($res));
+ }
- public function test_count3 ()
- {
- $queuefile = new Queuefile ();
- $queuefile->connect ("file:///tmp/queuefileTest/queuefileTest.json");
- $res = $queuefile->count ();
- $this->assertSame (0, $res);
- }
+ public function test_count3()
+ {
+ $queuefile = new Queuefile();
+ $queuefile->connect("file:///tmp/queuefileTest/queuefileTest.json");
+ $res = $queuefile->count();
+ $this->assertSame(0, $res);
+ }
- public function test_getAll3 ()
- {
- $queuefile = new Queuefile ();
- $queuefile->connect ("file:///tmp/queuefileTest/queuefileTest.json");
- $res = $queuefile->getAll ();
- $this->assertSame ([], $res);
- }
+ public function test_getAll3()
+ {
+ $queuefile = new Queuefile();
+ $queuefile->connect("file:///tmp/queuefileTest/queuefileTest.json");
+ $res = $queuefile->getAll();
+ $this->assertSame([], $res);
+ }
- public function test_getFirst2 ()
- {
- $queuefile = new Queuefile ();
- $queuefile->connect ("file:///tmp/queuefileTest/queuefileTest.json");
- $res = $queuefile->getFirst ();
- $this->assertSame (null, $res);
- }
-
- public function test_getLast2 ()
- {
- $queuefile = new Queuefile ();
- $queuefile->connect ("file:///tmp/queuefileTest/queuefileTest.json");
- $res = $queuefile->getLast ();
- $this->assertSame (null, $res);
- }
+ public function test_getFirst2()
+ {
+ $queuefile = new Queuefile();
+ $queuefile->connect("file:///tmp/queuefileTest/queuefileTest.json");
+ $res = $queuefile->getFirst();
+ $this->assertSame(null, $res);
+ }
+ public function test_getLast2()
+ {
+ $queuefile = new Queuefile();
+ $queuefile->connect("file:///tmp/queuefileTest/queuefileTest.json");
+ $res = $queuefile->getLast();
+ $this->assertSame(null, $res);
+ }
}
diff --git a/Tests/RatelimitTest.php b/Tests/RatelimitTest.php
index e44e62b..49e58db 100644
--- a/Tests/RatelimitTest.php
+++ b/Tests/RatelimitTest.php
@@ -1,4 +1,5 @@
@@ -12,8 +13,8 @@ use Domframework\Ratelimit;
/** Test the Ratelimit.php file */
class RatelimitTest extends \PHPUnit_Framework_TestCase
{
- public function test_ratelimit0 ()
- {
- $ratelimit = new Ratelimit ();
- }
+ public function test_ratelimit0()
+ {
+ $ratelimit = new Ratelimit();
+ }
}
diff --git a/Tests/RatelimitfileTest.php b/Tests/RatelimitfileTest.php
index 0293e54..66961da 100644
--- a/Tests/RatelimitfileTest.php
+++ b/Tests/RatelimitfileTest.php
@@ -1,4 +1,5 @@
@@ -12,65 +13,65 @@ use Domframework\Ratelimitfile;
/** Test the Ratelimitfile.php file */
class RatelimitfileTest extends \PHPUnit_Framework_TestCase
{
- public function test_ratelimitfile0 ()
- {
- exec ("rm -rf /tmp/testDFWratelimit");
- }
+ public function testRatelimitfile0()
+ {
+ exec("rm -rf /tmp/testDFWratelimit");
+ }
- public function test_ratelimitfile1 ()
- {
- // Create one non ratelimited entry
- $ratelimitfile = new Ratelimitfile ();
- $ratelimitfile->storageDir = "/tmp/testDFWratelimit";
- $res = $ratelimitfile->set ("TOTO");
- $this->assertSame (true, $res);
- }
+ public function testRatelimitfile1()
+ {
+ // Create one non ratelimited entry
+ $ratelimitfile = new Ratelimitfile();
+ $ratelimitfile->storageDir = "/tmp/testDFWratelimit";
+ $res = $ratelimitfile->set("TOTO");
+ $this->assertSame(true, $res);
+ }
- public function test_ratelimitfile2 ()
- {
- // Too much entries
- $ratelimitfile = new Ratelimitfile ();
- $ratelimitfile->storageDir = "/tmp/testDFWratelimit";
- $ratelimitfile->set ("TOTO");
- $ratelimitfile->set ("TOTO");
- $ratelimitfile->set ("TOTO");
- $ratelimitfile->set ("TOTO");
- $ratelimitfile->set ("TOTO");
- $ratelimitfile->set ("TOTO");
- $ratelimitfile->set ("TOTO");
- $ratelimitfile->set ("TOTO");
- $ratelimitfile->set ("TOTO");
- $res = $ratelimitfile->set ("TOTO");
- $this->assertSame (false, $res);
- }
+ public function testRatelimitfile2()
+ {
+ // Too much entries
+ $ratelimitfile = new Ratelimitfile();
+ $ratelimitfile->storageDir = "/tmp/testDFWratelimit";
+ $ratelimitfile->set("TOTO");
+ $ratelimitfile->set("TOTO");
+ $ratelimitfile->set("TOTO");
+ $ratelimitfile->set("TOTO");
+ $ratelimitfile->set("TOTO");
+ $ratelimitfile->set("TOTO");
+ $ratelimitfile->set("TOTO");
+ $ratelimitfile->set("TOTO");
+ $ratelimitfile->set("TOTO");
+ $res = $ratelimitfile->set("TOTO");
+ $this->assertSame(false, $res);
+ }
- public function test_ratelimitfile3 ()
- {
- // Del the ratelimited entry
- $ratelimitfile = new Ratelimitfile ();
- $ratelimitfile->storageDir = "/tmp/testDFWratelimit";
- $res = $ratelimitfile->del ("TOTO");
- $this->assertSame (true, $res);
- }
+ public function testRatelimitfile3()
+ {
+ // Del the ratelimited entry
+ $ratelimitfile = new Ratelimitfile();
+ $ratelimitfile->storageDir = "/tmp/testDFWratelimit";
+ $res = $ratelimitfile->del("TOTO");
+ $this->assertSame(true, $res);
+ }
- public function test_ratelimitfile4 ()
- {
- // Create one non ratelimited entry
- $ratelimitfile = new Ratelimitfile ();
- $ratelimitfile->storageDir = "/tmp/testDFWratelimit";
- $res = $ratelimitfile->set ("TOTO");
- $this->assertSame (true, $res);
- }
+ public function testRatelimitfile4()
+ {
+ // Create one non ratelimited entry
+ $ratelimitfile = new Ratelimitfile();
+ $ratelimitfile->storageDir = "/tmp/testDFWratelimit";
+ $res = $ratelimitfile->set("TOTO");
+ $this->assertSame(true, $res);
+ }
- public function test_ratelimitfile5 ()
- {
- // Clean expired entries
- sleep (2);
- $ratelimitfile = new Ratelimitfile ();
- $ratelimitfile->unittime = 1;
- $ratelimitfile->storageDir = "/tmp/testDFWratelimit";
- $ratelimitfile->clean ();
- $res = count (glob ("/tmp/testDFWratelimit/*"));
- $this->assertSame (0, $res);
- }
+ public function testRatelimitfile5()
+ {
+ // Clean expired entries
+ sleep(2);
+ $ratelimitfile = new Ratelimitfile();
+ $ratelimitfile->unittime = 1;
+ $ratelimitfile->storageDir = "/tmp/testDFWratelimit";
+ $ratelimitfile->clean();
+ $res = count(glob("/tmp/testDFWratelimit/*"));
+ $this->assertSame(0, $res);
+ }
}
diff --git a/Tests/RestTest.php b/Tests/RestTest.php
index 2032e9d..b729020 100644
--- a/Tests/RestTest.php
+++ b/Tests/RestTest.php
@@ -1,4 +1,5 @@
@@ -14,52 +15,52 @@ class RestTest extends \PHPUnit_Framework_TestCase
{
/** No param, JSON by default
*/
- public function testChooseType1 ()
- {
- $rest = new Rest ();
- $res = $rest->chooseType ();
- $this->assertSame ($res, "json");
- }
+ public function testChooseType1()
+ {
+ $rest = new Rest();
+ $res = $rest->chooseType();
+ $this->assertSame($res, "json");
+ }
/** If limited allowedTypes, return the first one as default
*/
- public function testChooseType2 ()
- {
- $rest = new Rest ();
- $rest->allowedtypes = array ("xml", "csv");
- $res = $rest->chooseType ();
- $this->assertSame ($res, "xml");
- }
+ public function testChooseType2()
+ {
+ $rest = new Rest();
+ $rest->allowedtypes = array ("xml", "csv");
+ $res = $rest->chooseType();
+ $this->assertSame($res, "xml");
+ }
/** Choose by the user specification : exact match
*/
- public function testChooseType3 ()
- {
- $rest = new Rest ();
- $_SERVER["HTTP_ACCEPT"] = "text/html,application/xml;q=0.9,*/*;q=0.8";
- $res = $rest->chooseType ();
- $this->assertSame ($res, "xml");
- }
+ public function testChooseType3()
+ {
+ $rest = new Rest();
+ $_SERVER["HTTP_ACCEPT"] = "text/html,application/xml;q=0.9,*/*;q=0.8";
+ $res = $rest->chooseType();
+ $this->assertSame($res, "xml");
+ }
/** Choose by the user specification : generic match
*/
- public function testChooseType4 ()
- {
- $rest = new Rest ();
- $_SERVER["HTTP_ACCEPT"] = "text/html;q=0.9,*/*;q=0.8";
- $res = $rest->chooseType ();
- $this->assertSame ($res, "json");
- }
+ public function testChooseType4()
+ {
+ $rest = new Rest();
+ $_SERVER["HTTP_ACCEPT"] = "text/html;q=0.9,*/*;q=0.8";
+ $res = $rest->chooseType();
+ $this->assertSame($res, "json");
+ }
/** Choose by the user specification : generic match with limited allowed
* types
*/
- public function testChooseType5 ()
- {
- $rest = new Rest ();
- $rest->allowedtypes = array ("xml", "csv");
- $_SERVER["HTTP_ACCEPT"] = "text/html;q=0.9,*/*;q=0.8";
- $res = $rest->chooseType ();
- $this->assertSame ($res, "xml");
- }
+ public function testChooseType5()
+ {
+ $rest = new Rest();
+ $rest->allowedtypes = array ("xml", "csv");
+ $_SERVER["HTTP_ACCEPT"] = "text/html;q=0.9,*/*;q=0.8";
+ $res = $rest->chooseType();
+ $this->assertSame($res, "xml");
+ }
}
diff --git a/Tests/RobotstxtTest.php b/Tests/RobotstxtTest.php
index ad159eb..8b494a5 100644
--- a/Tests/RobotstxtTest.php
+++ b/Tests/RobotstxtTest.php
@@ -1,4 +1,5 @@
@@ -14,216 +15,253 @@ use Domframework\Robotstxt;
class RobotstxtTest extends \PHPUnit_Framework_TestCase
{
// Empty Robots
- public function test_Construct_1 ()
- {
- $robotstxt = new Robotstxt ("", "domsearch");
- $res = $robotstxt->allow ();
- $this->assertSame ($res, ["/"]);
- }
- public function test_Construct_2 ()
- {
- $robotstxt = new Robotstxt ("", "domsearch");
- $res = $robotstxt->disallow ();
- $this->assertSame ($res, array ());
- }
- public function test_Construct_3 ()
- {
- $robotstxt = new Robotstxt ("", "domsearch");
- $res = $robotstxt->sitemaps ();
- $this->assertSame ($res, array ());
- }
- public function test_Construct_4 ()
- {
- $robotstxt = new Robotstxt ("", "domsearch");
- $res = $robotstxt->crawldelay ();
- $this->assertSame ($res, null);
- }
+ public function test_Construct_1()
+ {
+ $robotstxt = new Robotstxt("", "domsearch");
+ $res = $robotstxt->allow();
+ $this->assertSame($res, ["/"]);
+ }
+ public function test_Construct_2()
+ {
+ $robotstxt = new Robotstxt("", "domsearch");
+ $res = $robotstxt->disallow();
+ $this->assertSame($res, array ());
+ }
+ public function test_Construct_3()
+ {
+ $robotstxt = new Robotstxt("", "domsearch");
+ $res = $robotstxt->sitemaps();
+ $this->assertSame($res, array ());
+ }
+ public function test_Construct_4()
+ {
+ $robotstxt = new Robotstxt("", "domsearch");
+ $res = $robotstxt->crawldelay();
+ $this->assertSame($res, null);
+ }
// Allow
- public function test_allow_1 ()
- {
- $robotstxt = new Robotstxt (
- "User-Agent: *\nDisallow:\n", "domsearch");
- $res = $robotstxt->allow ();
- $this->assertSame ($res, ["/"]);
- }
- public function test_allow_2 ()
- {
- $robotstxt = new Robotstxt (
- "User-Agent: *\nDisallow:\n\nUser-Agent: DomSearch\nDisallow:\n",
- "domsearch");
- $res = $robotstxt->allow ();
- $this->assertSame ($res, ["/"]);
- }
- public function test_allow_3 ()
- {
- $robotstxt = new Robotstxt (
- "User-Agent: DomSearch\nDisallow:\n\nUser-Agent: *\nDisallow:\n",
- "domsearch");
- $res = $robotstxt->allow ();
- $this->assertSame ($res, ["/"]);
- }
- public function test_allow_4 ()
- {
- $robotstxt = new Robotstxt (
- "User-Agent: DomSearch\n".
- "User-Agent: User1\n".
- "User-Agent: User2\n".
- "Disallow:\n\n".
- "User-Agent: *\n".
- "Disallow: /\n", "domsearch");
- $res = $robotstxt->allow ();
- $this->assertSame ($res, ["/"]);
- }
+ public function test_allow_1()
+ {
+ $robotstxt = new Robotstxt(
+ "User-Agent: *\nDisallow:\n",
+ "domsearch"
+ );
+ $res = $robotstxt->allow();
+ $this->assertSame($res, ["/"]);
+ }
+ public function test_allow_2()
+ {
+ $robotstxt = new Robotstxt(
+ "User-Agent: *\nDisallow:\n\nUser-Agent: DomSearch\nDisallow:\n",
+ "domsearch"
+ );
+ $res = $robotstxt->allow();
+ $this->assertSame($res, ["/"]);
+ }
+ public function test_allow_3()
+ {
+ $robotstxt = new Robotstxt(
+ "User-Agent: DomSearch\nDisallow:\n\nUser-Agent: *\nDisallow:\n",
+ "domsearch"
+ );
+ $res = $robotstxt->allow();
+ $this->assertSame($res, ["/"]);
+ }
+ public function test_allow_4()
+ {
+ $robotstxt = new Robotstxt(
+ "User-Agent: DomSearch\n" .
+ "User-Agent: User1\n" .
+ "User-Agent: User2\n" .
+ "Disallow:\n\n" .
+ "User-Agent: *\n" .
+ "Disallow: /\n",
+ "domsearch"
+ );
+ $res = $robotstxt->allow();
+ $this->assertSame($res, ["/"]);
+ }
// Disallow
- public function test_disallow_1 ()
- {
- $robotstxt = new Robotstxt (
- "User-Agent: *\nDisallow: /\n", "domsearch");
- $res = $robotstxt->disallow ();
- $this->assertSame ($res, ["/"]);
- }
- public function test_disallow_2 ()
- {
- $robotstxt = new Robotstxt (
- "User-Agent: *\nDisallow: /\n\nUser-Agent: DomSearch\nDisallow: /\n",
- "domsearch");
- $res = $robotstxt->disallow ();
- $this->assertSame ($res, ["/"]);
- }
- public function test_disallow_3 ()
- {
- $robotstxt = new Robotstxt (
- "User-Agent: DomSearch\nDisallow: /\n\nUser-Agent: *\nDisallow: /\n",
- "domsearch");
- $res = $robotstxt->disallow ();
- $this->assertSame ($res, ["/"]);
- }
+ public function test_disallow_1()
+ {
+ $robotstxt = new Robotstxt(
+ "User-Agent: *\nDisallow: /\n",
+ "domsearch"
+ );
+ $res = $robotstxt->disallow();
+ $this->assertSame($res, ["/"]);
+ }
+ public function test_disallow_2()
+ {
+ $robotstxt = new Robotstxt(
+ "User-Agent: *\nDisallow: /\n\nUser-Agent: DomSearch\nDisallow: /\n",
+ "domsearch"
+ );
+ $res = $robotstxt->disallow();
+ $this->assertSame($res, ["/"]);
+ }
+ public function test_disallow_3()
+ {
+ $robotstxt = new Robotstxt(
+ "User-Agent: DomSearch\nDisallow: /\n\nUser-Agent: *\nDisallow: /\n",
+ "domsearch"
+ );
+ $res = $robotstxt->disallow();
+ $this->assertSame($res, ["/"]);
+ }
// Sitemaps
- public function test_sitemaps_1 ()
- {
- $robotstxt = new Robotstxt (
- "User-Agent: DomSearch\nDisallow: /\n\nUser-Agent: *\nDisallow: /\n",
- "domsearch");
- $res = $robotstxt->sitemaps ();
- $this->assertSame ($res, []);
- }
- public function test_sitemaps_2 ()
- {
- $robotstxt = new Robotstxt (
- "User-Agent: *\nDisallow: /\nSitemap: http://example.com/sitemap.xml",
- "domsearch");
- $res = $robotstxt->sitemaps ();
- $this->assertSame ($res, ["http://example.com/sitemap.xml"]);
- }
- public function test_sitemaps_3 ()
- {
- $robotstxt = new Robotstxt (
- "User-Agent: *\nDisallow: /\n".
- "Sitemap: http://example.com/sitemap.xml\n".
- "Sitemap: http://example.com/SITEMAP.XML", "domsearch");
- $res = $robotstxt->sitemaps ();
- $this->assertSame ($res,
- ["http://example.com/sitemap.xml", "http://example.com/SITEMAP.XML"]);
- }
+ public function test_sitemaps_1()
+ {
+ $robotstxt = new Robotstxt(
+ "User-Agent: DomSearch\nDisallow: /\n\nUser-Agent: *\nDisallow: /\n",
+ "domsearch"
+ );
+ $res = $robotstxt->sitemaps();
+ $this->assertSame($res, []);
+ }
+ public function test_sitemaps_2()
+ {
+ $robotstxt = new Robotstxt(
+ "User-Agent: *\nDisallow: /\nSitemap: http://example.com/sitemap.xml",
+ "domsearch"
+ );
+ $res = $robotstxt->sitemaps();
+ $this->assertSame($res, ["http://example.com/sitemap.xml"]);
+ }
+ public function test_sitemaps_3()
+ {
+ $robotstxt = new Robotstxt(
+ "User-Agent: *\nDisallow: /\n" .
+ "Sitemap: http://example.com/sitemap.xml\n" .
+ "Sitemap: http://example.com/SITEMAP.XML",
+ "domsearch"
+ );
+ $res = $robotstxt->sitemaps();
+ $this->assertSame(
+ $res,
+ ["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"]);
- }
+ 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 ()
- {
- $robotstxt = new Robotstxt (
- "User-Agent: *\nDisallow: /\n", "domsearch");
- $res = $robotstxt->host ();
- $this->assertSame ($res, null);
- }
- public function test_host_2 ()
- {
- $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 (
- "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"]);
- }
+ public function test_host_1()
+ {
+ $robotstxt = new Robotstxt(
+ "User-Agent: *\nDisallow: /\n",
+ "domsearch"
+ );
+ $res = $robotstxt->host();
+ $this->assertSame($res, null);
+ }
+ public function test_host_2()
+ {
+ $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(
+ "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 ()
- {
- $robotstxt = new Robotstxt ("", "domsearch");
- $res = $robotstxt->URLAllow ("/");
- $this->assertSame ($res, true);
- }
- public function test_urlallow_2 ()
- {
- $robotstxt = new Robotstxt (
- "User-Agent: *\nDisallow: /", "domsearch");
- $res = $robotstxt->URLAllow ("/");
- $this->assertSame ($res, false);
- }
- public function test_urlallow_3 ()
- {
- $robotstxt = new Robotstxt (
- "User-Agent: *\nDisallow: /\nAllow: /allow/", "domsearch");
- $res = $robotstxt->URLAllow ("/");
- $this->assertSame ($res, false);
- }
- public function test_urlallow_4 ()
- {
- $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 (
- "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 (
- "User-Agent: *\nDisallow: /\nAllow: /allow/*.gif$", "domsearch");
- $res = $robotstxt->URLAllow ("/allow/.gif");
- $this->assertSame ($res, false);
- }
- public function test_urlallow_7 ()
- {
- $robotstxt = new Robotstxt (
- "User-Agent: *\nDisallow: /\nAllow: /allow/*.gif\$", "domsearch");
- $res = $robotstxt->URLAllow ("/allow/file.png");
- $this->assertSame ($res, false);
- }
+ public function test_urlallow_1()
+ {
+ $robotstxt = new Robotstxt("", "domsearch");
+ $res = $robotstxt->URLAllow("/");
+ $this->assertSame($res, true);
+ }
+ public function test_urlallow_2()
+ {
+ $robotstxt = new Robotstxt(
+ "User-Agent: *\nDisallow: /",
+ "domsearch"
+ );
+ $res = $robotstxt->URLAllow("/");
+ $this->assertSame($res, false);
+ }
+ public function test_urlallow_3()
+ {
+ $robotstxt = new Robotstxt(
+ "User-Agent: *\nDisallow: /\nAllow: /allow/",
+ "domsearch"
+ );
+ $res = $robotstxt->URLAllow("/");
+ $this->assertSame($res, false);
+ }
+ public function test_urlallow_4()
+ {
+ $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(
+ "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(
+ "User-Agent: *\nDisallow: /\nAllow: /allow/*.gif$",
+ "domsearch"
+ );
+ $res = $robotstxt->URLAllow("/allow/.gif");
+ $this->assertSame($res, false);
+ }
+ public function test_urlallow_7()
+ {
+ $robotstxt = new Robotstxt(
+ "User-Agent: *\nDisallow: /\nAllow: /allow/*.gif\$",
+ "domsearch"
+ );
+ $res = $robotstxt->URLAllow("/allow/file.png");
+ $this->assertSame($res, false);
+ }
// Tests like http://www.robotstxt.org/norobots-rfc.txt
- public function test_rfc_unhipbot_1 ()
- {
- // {{{
- $robotstxt = new Robotstxt (
- "# /robots.txt for http://www.fict.org/
+ public function test_rfc_unhipbot_1()
+ {
+ // {{{
+ $robotstxt = new Robotstxt(
+ "# /robots.txt for http://www.fict.org/
# comments to webmaster@fict.org
User-agent: unhipbot
@@ -238,17 +276,20 @@ class RobotstxtTest extends \PHPUnit_Framework_TestCase
Allow: /org/
Allow: /serv
Allow: /~mak
- Disallow: /", "unhipbot"
- );
- // }}}
- $this->assertSame (
- $robotstxt->URLAllow ("http://www.fict.org/"), false);
- }
- public function test_rfc_unhipbot_2 ()
- {
- // {{{
- $robotstxt = new Robotstxt (
- "# /robots.txt for http://www.fict.org/
+ Disallow: /",
+ "unhipbot"
+ );
+ // }}}
+ $this->assertSame(
+ $robotstxt->URLAllow("http://www.fict.org/"),
+ false
+ );
+ }
+ public function test_rfc_unhipbot_2()
+ {
+ // {{{
+ $robotstxt = new Robotstxt(
+ "# /robots.txt for http://www.fict.org/
# comments to webmaster@fict.org
User-agent: unhipbot
@@ -263,17 +304,20 @@ class RobotstxtTest extends \PHPUnit_Framework_TestCase
Allow: /org/
Allow: /serv
Allow: /~mak
- Disallow: /", "unhipbot"
- );
- // }}}
- $this->assertSame (
- $robotstxt->URLAllow ("http://www.fict.org/index.html"), false);
- }
- public function test_rfc_unhipbot_3 ()
- {
- // {{{
- $robotstxt = new Robotstxt (
- "# /robots.txt for http://www.fict.org/
+ Disallow: /",
+ "unhipbot"
+ );
+ // }}}
+ $this->assertSame(
+ $robotstxt->URLAllow("http://www.fict.org/index.html"),
+ false
+ );
+ }
+ public function test_rfc_unhipbot_3()
+ {
+ // {{{
+ $robotstxt = new Robotstxt(
+ "# /robots.txt for http://www.fict.org/
# comments to webmaster@fict.org
User-agent: unhipbot
@@ -288,17 +332,20 @@ class RobotstxtTest extends \PHPUnit_Framework_TestCase
Allow: /org/
Allow: /serv
Allow: /~mak
- Disallow: /", "unhipbot"
- );
- // }}}
- $this->assertSame (
- $robotstxt->URLAllow ("http://www.fict.org/robots.txt"), true);
- }
- public function test_rfc_unhipbot_4 ()
- {
- // {{{
- $robotstxt = new Robotstxt (
- "# /robots.txt for http://www.fict.org/
+ Disallow: /",
+ "unhipbot"
+ );
+ // }}}
+ $this->assertSame(
+ $robotstxt->URLAllow("http://www.fict.org/robots.txt"),
+ true
+ );
+ }
+ public function test_rfc_unhipbot_4()
+ {
+ // {{{
+ $robotstxt = new Robotstxt(
+ "# /robots.txt for http://www.fict.org/
# comments to webmaster@fict.org
User-agent: unhipbot
@@ -313,17 +360,20 @@ class RobotstxtTest extends \PHPUnit_Framework_TestCase
Allow: /org/
Allow: /serv
Allow: /~mak
- Disallow: /", "unhipbot"
- );
- // }}}
- $this->assertSame (
- $robotstxt->URLAllow ("http://www.fict.org/server.html"), false);
- }
- public function test_rfc_unhipbot_5 ()
- {
- // {{{
- $robotstxt = new Robotstxt (
- "# /robots.txt for http://www.fict.org/
+ Disallow: /",
+ "unhipbot"
+ );
+ // }}}
+ $this->assertSame(
+ $robotstxt->URLAllow("http://www.fict.org/server.html"),
+ false
+ );
+ }
+ public function test_rfc_unhipbot_5()
+ {
+ // {{{
+ $robotstxt = new Robotstxt(
+ "# /robots.txt for http://www.fict.org/
# comments to webmaster@fict.org
User-agent: unhipbot
@@ -338,17 +388,20 @@ class RobotstxtTest extends \PHPUnit_Framework_TestCase
Allow: /org/
Allow: /serv
Allow: /~mak
- Disallow: /", "unhipbot"
- );
- // }}}
- $this->assertSame (
- $robotstxt->URLAllow ("http://www.fict.org/services/fast.html"), false);
- }
- public function test_rfc_unhipbot_6 ()
- {
- // {{{
- $robotstxt = new Robotstxt (
- "# /robots.txt for http://www.fict.org/
+ Disallow: /",
+ "unhipbot"
+ );
+ // }}}
+ $this->assertSame(
+ $robotstxt->URLAllow("http://www.fict.org/services/fast.html"),
+ false
+ );
+ }
+ public function test_rfc_unhipbot_6()
+ {
+ // {{{
+ $robotstxt = new Robotstxt(
+ "# /robots.txt for http://www.fict.org/
# comments to webmaster@fict.org
User-agent: unhipbot
@@ -363,17 +416,20 @@ class RobotstxtTest extends \PHPUnit_Framework_TestCase
Allow: /org/
Allow: /serv
Allow: /~mak
- Disallow: /", "unhipbot"
- );
- // }}}
- $this->assertSame (
- $robotstxt->URLAllow ("http://www.fict.org/services/slow.html"), false);
- }
- public function test_rfc_unhipbot_7 ()
- {
- // {{{
- $robotstxt = new Robotstxt (
- "# /robots.txt for http://www.fict.org/
+ Disallow: /",
+ "unhipbot"
+ );
+ // }}}
+ $this->assertSame(
+ $robotstxt->URLAllow("http://www.fict.org/services/slow.html"),
+ false
+ );
+ }
+ public function test_rfc_unhipbot_7()
+ {
+ // {{{
+ $robotstxt = new Robotstxt(
+ "# /robots.txt for http://www.fict.org/
# comments to webmaster@fict.org
User-agent: unhipbot
@@ -388,17 +444,20 @@ class RobotstxtTest extends \PHPUnit_Framework_TestCase
Allow: /org/
Allow: /serv
Allow: /~mak
- Disallow: /", "unhipbot"
- );
- // }}}
- $this->assertSame (
- $robotstxt->URLAllow ("http://www.fict.org/orgo.gif"), false);
- }
- public function test_rfc_unhipbot_8 ()
- {
- // {{{
- $robotstxt = new Robotstxt (
- "# /robots.txt for http://www.fict.org/
+ Disallow: /",
+ "unhipbot"
+ );
+ // }}}
+ $this->assertSame(
+ $robotstxt->URLAllow("http://www.fict.org/orgo.gif"),
+ false
+ );
+ }
+ public function test_rfc_unhipbot_8()
+ {
+ // {{{
+ $robotstxt = new Robotstxt(
+ "# /robots.txt for http://www.fict.org/
# comments to webmaster@fict.org
User-agent: unhipbot
@@ -413,17 +472,20 @@ class RobotstxtTest extends \PHPUnit_Framework_TestCase
Allow: /org/
Allow: /serv
Allow: /~mak
- Disallow: /", "unhipbot"
- );
- // }}}
- $this->assertSame (
- $robotstxt->URLAllow ("http://www.fict.org/org/about.html"), false);
- }
- public function test_rfc_unhipbot_9 ()
- {
- // {{{
- $robotstxt = new Robotstxt (
- "# /robots.txt for http://www.fict.org/
+ Disallow: /",
+ "unhipbot"
+ );
+ // }}}
+ $this->assertSame(
+ $robotstxt->URLAllow("http://www.fict.org/org/about.html"),
+ false
+ );
+ }
+ public function test_rfc_unhipbot_9()
+ {
+ // {{{
+ $robotstxt = new Robotstxt(
+ "# /robots.txt for http://www.fict.org/
# comments to webmaster@fict.org
User-agent: unhipbot
@@ -438,17 +500,20 @@ class RobotstxtTest extends \PHPUnit_Framework_TestCase
Allow: /org/
Allow: /serv
Allow: /~mak
- Disallow: /", "unhipbot"
- );
- // }}}
- $this->assertSame (
- $robotstxt->URLAllow ("http://www.fict.org/org/plans.html"), false);
- }
- public function test_rfc_unhipbot_10 ()
- {
- // {{{
- $robotstxt = new Robotstxt (
- "# /robots.txt for http://www.fict.org/
+ Disallow: /",
+ "unhipbot"
+ );
+ // }}}
+ $this->assertSame(
+ $robotstxt->URLAllow("http://www.fict.org/org/plans.html"),
+ false
+ );
+ }
+ public function test_rfc_unhipbot_10()
+ {
+ // {{{
+ $robotstxt = new Robotstxt(
+ "# /robots.txt for http://www.fict.org/
# comments to webmaster@fict.org
User-agent: unhipbot
@@ -463,17 +528,20 @@ class RobotstxtTest extends \PHPUnit_Framework_TestCase
Allow: /org/
Allow: /serv
Allow: /~mak
- Disallow: /", "unhipbot"
- );
- // }}}
- $this->assertSame (
- $robotstxt->URLAllow ("http://www.fict.org/~jim/jim.html"), false);
- }
- public function test_rfc_unhipbot_11 ()
- {
- // {{{
- $robotstxt = new Robotstxt (
- "# /robots.txt for http://www.fict.org/
+ Disallow: /",
+ "unhipbot"
+ );
+ // }}}
+ $this->assertSame(
+ $robotstxt->URLAllow("http://www.fict.org/~jim/jim.html"),
+ false
+ );
+ }
+ public function test_rfc_unhipbot_11()
+ {
+ // {{{
+ $robotstxt = new Robotstxt(
+ "# /robots.txt for http://www.fict.org/
# comments to webmaster@fict.org
User-agent: unhipbot
@@ -488,17 +556,20 @@ class RobotstxtTest extends \PHPUnit_Framework_TestCase
Allow: /org/
Allow: /serv
Allow: /~mak
- Disallow: /", "unhipbot"
- );
- // }}}
- $this->assertSame (
- $robotstxt->URLAllow ("http://www.fict.org/~mak/mak.html"), false);
- }
- public function test_rfc_webcrawler_1 ()
- {
- // {{{
- $robotstxt = new Robotstxt (
- "# /robots.txt for http://www.fict.org/
+ Disallow: /",
+ "unhipbot"
+ );
+ // }}}
+ $this->assertSame(
+ $robotstxt->URLAllow("http://www.fict.org/~mak/mak.html"),
+ false
+ );
+ }
+ public function test_rfc_webcrawler_1()
+ {
+ // {{{
+ $robotstxt = new Robotstxt(
+ "# /robots.txt for http://www.fict.org/
# comments to webmaster@fict.org
User-agent: unhipbot
@@ -513,17 +584,20 @@ class RobotstxtTest extends \PHPUnit_Framework_TestCase
Allow: /org/
Allow: /serv
Allow: /~mak
- Disallow: /", "webcrawler"
- );
- // }}}
- $this->assertSame (
- $robotstxt->URLAllow ("http://www.fict.org/"), true);
- }
- public function test_rfc_webcrawler_2 ()
- {
- // {{{
- $robotstxt = new Robotstxt (
- "# /robots.txt for http://www.fict.org/
+ Disallow: /",
+ "webcrawler"
+ );
+ // }}}
+ $this->assertSame(
+ $robotstxt->URLAllow("http://www.fict.org/"),
+ true
+ );
+ }
+ public function test_rfc_webcrawler_2()
+ {
+ // {{{
+ $robotstxt = new Robotstxt(
+ "# /robots.txt for http://www.fict.org/
# comments to webmaster@fict.org
User-agent: unhipbot
@@ -538,17 +612,20 @@ class RobotstxtTest extends \PHPUnit_Framework_TestCase
Allow: /org/
Allow: /serv
Allow: /~mak
- Disallow: /", "webcrawler"
- );
- // }}}
- $this->assertSame (
- $robotstxt->URLAllow ("http://www.fict.org/index.html"), true);
- }
- public function test_rfc_webcrawler_3 ()
- {
- // {{{
- $robotstxt = new Robotstxt (
- "# /robots.txt for http://www.fict.org/
+ Disallow: /",
+ "webcrawler"
+ );
+ // }}}
+ $this->assertSame(
+ $robotstxt->URLAllow("http://www.fict.org/index.html"),
+ true
+ );
+ }
+ public function test_rfc_webcrawler_3()
+ {
+ // {{{
+ $robotstxt = new Robotstxt(
+ "# /robots.txt for http://www.fict.org/
# comments to webmaster@fict.org
User-agent: unhipbot
@@ -563,17 +640,20 @@ class RobotstxtTest extends \PHPUnit_Framework_TestCase
Allow: /org/
Allow: /serv
Allow: /~mak
- Disallow: /", "webcrawler"
- );
- // }}}
- $this->assertSame (
- $robotstxt->URLAllow ("http://www.fict.org/robots.txt"), true);
- }
- public function test_rfc_webcrawler_4 ()
- {
- // {{{
- $robotstxt = new Robotstxt (
- "# /robots.txt for http://www.fict.org/
+ Disallow: /",
+ "webcrawler"
+ );
+ // }}}
+ $this->assertSame(
+ $robotstxt->URLAllow("http://www.fict.org/robots.txt"),
+ true
+ );
+ }
+ public function test_rfc_webcrawler_4()
+ {
+ // {{{
+ $robotstxt = new Robotstxt(
+ "# /robots.txt for http://www.fict.org/
# comments to webmaster@fict.org
User-agent: unhipbot
@@ -588,17 +668,20 @@ class RobotstxtTest extends \PHPUnit_Framework_TestCase
Allow: /org/
Allow: /serv
Allow: /~mak
- Disallow: /", "webcrawler"
- );
- // }}}
- $this->assertSame (
- $robotstxt->URLAllow ("http://www.fict.org/server.html"), true);
- }
- public function test_rfc_webcrawler_5 ()
- {
- // {{{
- $robotstxt = new Robotstxt (
- "# /robots.txt for http://www.fict.org/
+ Disallow: /",
+ "webcrawler"
+ );
+ // }}}
+ $this->assertSame(
+ $robotstxt->URLAllow("http://www.fict.org/server.html"),
+ true
+ );
+ }
+ public function test_rfc_webcrawler_5()
+ {
+ // {{{
+ $robotstxt = new Robotstxt(
+ "# /robots.txt for http://www.fict.org/
# comments to webmaster@fict.org
User-agent: unhipbot
@@ -613,17 +696,20 @@ class RobotstxtTest extends \PHPUnit_Framework_TestCase
Allow: /org/
Allow: /serv
Allow: /~mak
- Disallow: /", "webcrawler"
- );
- // }}}
- $this->assertSame (
- $robotstxt->URLAllow ("http://www.fict.org/services/fast.html"), true);
- }
- public function test_rfc_webcrawler_6 ()
- {
- // {{{
- $robotstxt = new Robotstxt (
- "# /robots.txt for http://www.fict.org/
+ Disallow: /",
+ "webcrawler"
+ );
+ // }}}
+ $this->assertSame(
+ $robotstxt->URLAllow("http://www.fict.org/services/fast.html"),
+ true
+ );
+ }
+ public function test_rfc_webcrawler_6()
+ {
+ // {{{
+ $robotstxt = new Robotstxt(
+ "# /robots.txt for http://www.fict.org/
# comments to webmaster@fict.org
User-agent: unhipbot
@@ -638,17 +724,20 @@ class RobotstxtTest extends \PHPUnit_Framework_TestCase
Allow: /org/
Allow: /serv
Allow: /~mak
- Disallow: /", "webcrawler"
- );
- // }}}
- $this->assertSame (
- $robotstxt->URLAllow ("http://www.fict.org/services/slow.html"), true);
- }
- public function test_rfc_webcrawler_7 ()
- {
- // {{{
- $robotstxt = new Robotstxt (
- "# /robots.txt for http://www.fict.org/
+ Disallow: /",
+ "webcrawler"
+ );
+ // }}}
+ $this->assertSame(
+ $robotstxt->URLAllow("http://www.fict.org/services/slow.html"),
+ true
+ );
+ }
+ public function test_rfc_webcrawler_7()
+ {
+ // {{{
+ $robotstxt = new Robotstxt(
+ "# /robots.txt for http://www.fict.org/
# comments to webmaster@fict.org
User-agent: unhipbot
@@ -663,17 +752,20 @@ class RobotstxtTest extends \PHPUnit_Framework_TestCase
Allow: /org/
Allow: /serv
Allow: /~mak
- Disallow: /", "webcrawler"
- );
- // }}}
- $this->assertSame (
- $robotstxt->URLAllow ("http://www.fict.org/orgo.gif"), true);
- }
- public function test_rfc_webcrawler_8 ()
- {
- // {{{
- $robotstxt = new Robotstxt (
- "# /robots.txt for http://www.fict.org/
+ Disallow: /",
+ "webcrawler"
+ );
+ // }}}
+ $this->assertSame(
+ $robotstxt->URLAllow("http://www.fict.org/orgo.gif"),
+ true
+ );
+ }
+ public function test_rfc_webcrawler_8()
+ {
+ // {{{
+ $robotstxt = new Robotstxt(
+ "# /robots.txt for http://www.fict.org/
# comments to webmaster@fict.org
User-agent: unhipbot
@@ -688,17 +780,20 @@ class RobotstxtTest extends \PHPUnit_Framework_TestCase
Allow: /org/
Allow: /serv
Allow: /~mak
- Disallow: /", "webcrawler"
- );
- // }}}
- $this->assertSame (
- $robotstxt->URLAllow ("http://www.fict.org/org/about.html"), true);
- }
- public function test_rfc_webcrawler_9 ()
- {
- // {{{
- $robotstxt = new Robotstxt (
- "# /robots.txt for http://www.fict.org/
+ Disallow: /",
+ "webcrawler"
+ );
+ // }}}
+ $this->assertSame(
+ $robotstxt->URLAllow("http://www.fict.org/org/about.html"),
+ true
+ );
+ }
+ public function test_rfc_webcrawler_9()
+ {
+ // {{{
+ $robotstxt = new Robotstxt(
+ "# /robots.txt for http://www.fict.org/
# comments to webmaster@fict.org
User-agent: unhipbot
@@ -713,17 +808,20 @@ class RobotstxtTest extends \PHPUnit_Framework_TestCase
Allow: /org/
Allow: /serv
Allow: /~mak
- Disallow: /", "webcrawler"
- );
- // }}}
- $this->assertSame (
- $robotstxt->URLAllow ("http://www.fict.org/org/plans.html"), true);
- }
- public function test_rfc_webcrawler_10 ()
- {
- // {{{
- $robotstxt = new Robotstxt (
- "# /robots.txt for http://www.fict.org/
+ Disallow: /",
+ "webcrawler"
+ );
+ // }}}
+ $this->assertSame(
+ $robotstxt->URLAllow("http://www.fict.org/org/plans.html"),
+ true
+ );
+ }
+ public function test_rfc_webcrawler_10()
+ {
+ // {{{
+ $robotstxt = new Robotstxt(
+ "# /robots.txt for http://www.fict.org/
# comments to webmaster@fict.org
User-agent: unhipbot
@@ -738,17 +836,20 @@ class RobotstxtTest extends \PHPUnit_Framework_TestCase
Allow: /org/
Allow: /serv
Allow: /~mak
- Disallow: /", "webcrawler"
- );
- // }}}
- $this->assertSame (
- $robotstxt->URLAllow ("http://www.fict.org/~jim/jim.html"), true);
- }
- public function test_rfc_webcrawler_11 ()
- {
- // {{{
- $robotstxt = new Robotstxt (
- "# /robots.txt for http://www.fict.org/
+ Disallow: /",
+ "webcrawler"
+ );
+ // }}}
+ $this->assertSame(
+ $robotstxt->URLAllow("http://www.fict.org/~jim/jim.html"),
+ true
+ );
+ }
+ public function test_rfc_webcrawler_11()
+ {
+ // {{{
+ $robotstxt = new Robotstxt(
+ "# /robots.txt for http://www.fict.org/
# comments to webmaster@fict.org
User-agent: unhipbot
@@ -763,17 +864,20 @@ class RobotstxtTest extends \PHPUnit_Framework_TestCase
Allow: /org/
Allow: /serv
Allow: /~mak
- Disallow: /", "webcrawler"
- );
- // }}}
- $this->assertSame (
- $robotstxt->URLAllow ("http://www.fict.org/~mak/mak.html"), true);
- }
- public function test_rfc_excite_1 ()
- {
- // {{{
- $robotstxt = new Robotstxt (
- "# /robots.txt for http://www.fict.org/
+ Disallow: /",
+ "webcrawler"
+ );
+ // }}}
+ $this->assertSame(
+ $robotstxt->URLAllow("http://www.fict.org/~mak/mak.html"),
+ true
+ );
+ }
+ public function test_rfc_excite_1()
+ {
+ // {{{
+ $robotstxt = new Robotstxt(
+ "# /robots.txt for http://www.fict.org/
# comments to webmaster@fict.org
User-agent: unhipbot
@@ -788,17 +892,20 @@ class RobotstxtTest extends \PHPUnit_Framework_TestCase
Allow: /org/
Allow: /serv
Allow: /~mak
- Disallow: /", "excite"
- );
- // }}}
- $this->assertSame (
- $robotstxt->URLAllow ("http://www.fict.org/"), true);
- }
- public function test_rfc_excite_2 ()
- {
- // {{{
- $robotstxt = new Robotstxt (
- "# /robots.txt for http://www.fict.org/
+ Disallow: /",
+ "excite"
+ );
+ // }}}
+ $this->assertSame(
+ $robotstxt->URLAllow("http://www.fict.org/"),
+ true
+ );
+ }
+ public function test_rfc_excite_2()
+ {
+ // {{{
+ $robotstxt = new Robotstxt(
+ "# /robots.txt for http://www.fict.org/
# comments to webmaster@fict.org
User-agent: unhipbot
@@ -813,17 +920,20 @@ class RobotstxtTest extends \PHPUnit_Framework_TestCase
Allow: /org/
Allow: /serv
Allow: /~mak
- Disallow: /", "excite"
- );
- // }}}
- $this->assertSame (
- $robotstxt->URLAllow ("http://www.fict.org/index.html"), true);
- }
- public function test_rfc_excite_3 ()
- {
- // {{{
- $robotstxt = new Robotstxt (
- "# /robots.txt for http://www.fict.org/
+ Disallow: /",
+ "excite"
+ );
+ // }}}
+ $this->assertSame(
+ $robotstxt->URLAllow("http://www.fict.org/index.html"),
+ true
+ );
+ }
+ public function test_rfc_excite_3()
+ {
+ // {{{
+ $robotstxt = new Robotstxt(
+ "# /robots.txt for http://www.fict.org/
# comments to webmaster@fict.org
User-agent: unhipbot
@@ -838,17 +948,20 @@ class RobotstxtTest extends \PHPUnit_Framework_TestCase
Allow: /org/
Allow: /serv
Allow: /~mak
- Disallow: /", "excite"
- );
- // }}}
- $this->assertSame (
- $robotstxt->URLAllow ("http://www.fict.org/robots.txt"), true);
- }
- public function test_rfc_excite_4 ()
- {
- // {{{
- $robotstxt = new Robotstxt (
- "# /robots.txt for http://www.fict.org/
+ Disallow: /",
+ "excite"
+ );
+ // }}}
+ $this->assertSame(
+ $robotstxt->URLAllow("http://www.fict.org/robots.txt"),
+ true
+ );
+ }
+ public function test_rfc_excite_4()
+ {
+ // {{{
+ $robotstxt = new Robotstxt(
+ "# /robots.txt for http://www.fict.org/
# comments to webmaster@fict.org
User-agent: unhipbot
@@ -863,17 +976,20 @@ class RobotstxtTest extends \PHPUnit_Framework_TestCase
Allow: /org/
Allow: /serv
Allow: /~mak
- Disallow: /", "excite"
- );
- // }}}
- $this->assertSame (
- $robotstxt->URLAllow ("http://www.fict.org/server.html"), true);
- }
- public function test_rfc_excite_5 ()
- {
- // {{{
- $robotstxt = new Robotstxt (
- "# /robots.txt for http://www.fict.org/
+ Disallow: /",
+ "excite"
+ );
+ // }}}
+ $this->assertSame(
+ $robotstxt->URLAllow("http://www.fict.org/server.html"),
+ true
+ );
+ }
+ public function test_rfc_excite_5()
+ {
+ // {{{
+ $robotstxt = new Robotstxt(
+ "# /robots.txt for http://www.fict.org/
# comments to webmaster@fict.org
User-agent: unhipbot
@@ -888,17 +1004,20 @@ class RobotstxtTest extends \PHPUnit_Framework_TestCase
Allow: /org/
Allow: /serv
Allow: /~mak
- Disallow: /", "excite"
- );
- // }}}
- $this->assertSame (
- $robotstxt->URLAllow ("http://www.fict.org/services/fast.html"), true);
- }
- public function test_rfc_excite_6 ()
- {
- // {{{
- $robotstxt = new Robotstxt (
- "# /robots.txt for http://www.fict.org/
+ Disallow: /",
+ "excite"
+ );
+ // }}}
+ $this->assertSame(
+ $robotstxt->URLAllow("http://www.fict.org/services/fast.html"),
+ true
+ );
+ }
+ public function test_rfc_excite_6()
+ {
+ // {{{
+ $robotstxt = new Robotstxt(
+ "# /robots.txt for http://www.fict.org/
# comments to webmaster@fict.org
User-agent: unhipbot
@@ -913,17 +1032,20 @@ class RobotstxtTest extends \PHPUnit_Framework_TestCase
Allow: /org/
Allow: /serv
Allow: /~mak
- Disallow: /", "excite"
- );
- // }}}
- $this->assertSame (
- $robotstxt->URLAllow ("http://www.fict.org/services/slow.html"), true);
- }
- public function test_rfc_excite_7 ()
- {
- // {{{
- $robotstxt = new Robotstxt (
- "# /robots.txt for http://www.fict.org/
+ Disallow: /",
+ "excite"
+ );
+ // }}}
+ $this->assertSame(
+ $robotstxt->URLAllow("http://www.fict.org/services/slow.html"),
+ true
+ );
+ }
+ public function test_rfc_excite_7()
+ {
+ // {{{
+ $robotstxt = new Robotstxt(
+ "# /robots.txt for http://www.fict.org/
# comments to webmaster@fict.org
User-agent: unhipbot
@@ -938,17 +1060,20 @@ class RobotstxtTest extends \PHPUnit_Framework_TestCase
Allow: /org/
Allow: /serv
Allow: /~mak
- Disallow: /", "excite"
- );
- // }}}
- $this->assertSame (
- $robotstxt->URLAllow ("http://www.fict.org/orgo.gif"), true);
- }
- public function test_rfc_excite_8 ()
- {
- // {{{
- $robotstxt = new Robotstxt (
- "# /robots.txt for http://www.fict.org/
+ Disallow: /",
+ "excite"
+ );
+ // }}}
+ $this->assertSame(
+ $robotstxt->URLAllow("http://www.fict.org/orgo.gif"),
+ true
+ );
+ }
+ public function test_rfc_excite_8()
+ {
+ // {{{
+ $robotstxt = new Robotstxt(
+ "# /robots.txt for http://www.fict.org/
# comments to webmaster@fict.org
User-agent: unhipbot
@@ -963,17 +1088,20 @@ class RobotstxtTest extends \PHPUnit_Framework_TestCase
Allow: /org/
Allow: /serv
Allow: /~mak
- Disallow: /", "excite"
- );
- // }}}
- $this->assertSame (
- $robotstxt->URLAllow ("http://www.fict.org/org/about.html"), true);
- }
- public function test_rfc_excite_9 ()
- {
- // {{{
- $robotstxt = new Robotstxt (
- "# /robots.txt for http://www.fict.org/
+ Disallow: /",
+ "excite"
+ );
+ // }}}
+ $this->assertSame(
+ $robotstxt->URLAllow("http://www.fict.org/org/about.html"),
+ true
+ );
+ }
+ public function test_rfc_excite_9()
+ {
+ // {{{
+ $robotstxt = new Robotstxt(
+ "# /robots.txt for http://www.fict.org/
# comments to webmaster@fict.org
User-agent: unhipbot
@@ -988,17 +1116,20 @@ class RobotstxtTest extends \PHPUnit_Framework_TestCase
Allow: /org/
Allow: /serv
Allow: /~mak
- Disallow: /", "excite"
- );
- // }}}
- $this->assertSame (
- $robotstxt->URLAllow ("http://www.fict.org/org/plans.html"), true);
- }
- public function test_rfc_excite_10 ()
- {
- // {{{
- $robotstxt = new Robotstxt (
- "# /robots.txt for http://www.fict.org/
+ Disallow: /",
+ "excite"
+ );
+ // }}}
+ $this->assertSame(
+ $robotstxt->URLAllow("http://www.fict.org/org/plans.html"),
+ true
+ );
+ }
+ public function test_rfc_excite_10()
+ {
+ // {{{
+ $robotstxt = new Robotstxt(
+ "# /robots.txt for http://www.fict.org/
# comments to webmaster@fict.org
User-agent: unhipbot
@@ -1013,17 +1144,20 @@ class RobotstxtTest extends \PHPUnit_Framework_TestCase
Allow: /org/
Allow: /serv
Allow: /~mak
- Disallow: /", "excite"
- );
- // }}}
- $this->assertSame (
- $robotstxt->URLAllow ("http://www.fict.org/~jim/jim.html"), true);
- }
- public function test_rfc_excite_11 ()
- {
- // {{{
- $robotstxt = new Robotstxt (
- "# /robots.txt for http://www.fict.org/
+ Disallow: /",
+ "excite"
+ );
+ // }}}
+ $this->assertSame(
+ $robotstxt->URLAllow("http://www.fict.org/~jim/jim.html"),
+ true
+ );
+ }
+ public function test_rfc_excite_11()
+ {
+ // {{{
+ $robotstxt = new Robotstxt(
+ "# /robots.txt for http://www.fict.org/
# comments to webmaster@fict.org
User-agent: unhipbot
@@ -1038,17 +1172,20 @@ class RobotstxtTest extends \PHPUnit_Framework_TestCase
Allow: /org/
Allow: /serv
Allow: /~mak
- Disallow: /", "excite"
- );
- // }}}
- $this->assertSame (
- $robotstxt->URLAllow ("http://www.fict.org/~mak/mak.html"), true);
- }
- public function test_rfc_other_1 ()
- {
- // {{{
- $robotstxt = new Robotstxt (
- "# /robots.txt for http://www.fict.org/
+ Disallow: /",
+ "excite"
+ );
+ // }}}
+ $this->assertSame(
+ $robotstxt->URLAllow("http://www.fict.org/~mak/mak.html"),
+ true
+ );
+ }
+ public function test_rfc_other_1()
+ {
+ // {{{
+ $robotstxt = new Robotstxt(
+ "# /robots.txt for http://www.fict.org/
# comments to webmaster@fict.org
User-agent: unhipbot
@@ -1063,16 +1200,17 @@ class RobotstxtTest extends \PHPUnit_Framework_TestCase
Allow: /org/
Allow: /serv
Allow: /~mak
- Disallow: /", "other"
- );
- // }}}
- $this->assertSame ($robotstxt->URLAllow ("http://www.fict.org/"), false);
- }
- public function test_rfc_other_2 ()
- {
- // {{{
- $robotstxt = new Robotstxt (
- "# /robots.txt for http://www.fict.org/
+ Disallow: /",
+ "other"
+ );
+ // }}}
+ $this->assertSame($robotstxt->URLAllow("http://www.fict.org/"), false);
+ }
+ public function test_rfc_other_2()
+ {
+ // {{{
+ $robotstxt = new Robotstxt(
+ "# /robots.txt for http://www.fict.org/
# comments to webmaster@fict.org
User-agent: unhipbot
@@ -1087,17 +1225,20 @@ class RobotstxtTest extends \PHPUnit_Framework_TestCase
Allow: /org/
Allow: /serv
Allow: /~mak
- Disallow: /", "other"
- );
- // }}}
- $this->assertSame (
- $robotstxt->URLAllow ("http://www.fict.org/index.html"), false);
- }
- public function test_rfc_other_3 ()
- {
- // {{{
- $robotstxt = new Robotstxt (
- "# /robots.txt for http://www.fict.org/
+ Disallow: /",
+ "other"
+ );
+ // }}}
+ $this->assertSame(
+ $robotstxt->URLAllow("http://www.fict.org/index.html"),
+ false
+ );
+ }
+ public function test_rfc_other_3()
+ {
+ // {{{
+ $robotstxt = new Robotstxt(
+ "# /robots.txt for http://www.fict.org/
# comments to webmaster@fict.org
User-agent: unhipbot
@@ -1112,17 +1253,20 @@ class RobotstxtTest extends \PHPUnit_Framework_TestCase
Allow: /org/
Allow: /serv
Allow: /~mak
- Disallow: /", "other"
- );
- // }}}
- $this->assertSame (
- $robotstxt->URLAllow ("http://www.fict.org/robots.txt"), true);
- }
- public function test_rfc_other_4 ()
- {
- // {{{
- $robotstxt = new Robotstxt (
- "# /robots.txt for http://www.fict.org/
+ Disallow: /",
+ "other"
+ );
+ // }}}
+ $this->assertSame(
+ $robotstxt->URLAllow("http://www.fict.org/robots.txt"),
+ true
+ );
+ }
+ public function test_rfc_other_4()
+ {
+ // {{{
+ $robotstxt = new Robotstxt(
+ "# /robots.txt for http://www.fict.org/
# comments to webmaster@fict.org
User-agent: unhipbot
@@ -1137,17 +1281,20 @@ class RobotstxtTest extends \PHPUnit_Framework_TestCase
Allow: /org/
Allow: /serv
Allow: /~mak
- Disallow: /", "other"
- );
- // }}}
- $this->assertSame (
- $robotstxt->URLAllow ("http://www.fict.org/server.html"), true);
- }
- public function test_rfc_other_5 ()
- {
- // {{{
- $robotstxt = new Robotstxt (
- "# /robots.txt for http://www.fict.org/
+ Disallow: /",
+ "other"
+ );
+ // }}}
+ $this->assertSame(
+ $robotstxt->URLAllow("http://www.fict.org/server.html"),
+ true
+ );
+ }
+ public function test_rfc_other_5()
+ {
+ // {{{
+ $robotstxt = new Robotstxt(
+ "# /robots.txt for http://www.fict.org/
# comments to webmaster@fict.org
User-agent: unhipbot
@@ -1162,17 +1309,20 @@ class RobotstxtTest extends \PHPUnit_Framework_TestCase
Allow: /org/
Allow: /serv
Allow: /~mak
- Disallow: /", "other"
- );
- // }}}
- $this->assertSame (
- $robotstxt->URLAllow ("http://www.fict.org/services/fast.html"), true);
- }
- public function test_rfc_other_6 ()
- {
- // {{{
- $robotstxt = new Robotstxt (
- "# /robots.txt for http://www.fict.org/
+ Disallow: /",
+ "other"
+ );
+ // }}}
+ $this->assertSame(
+ $robotstxt->URLAllow("http://www.fict.org/services/fast.html"),
+ true
+ );
+ }
+ public function test_rfc_other_6()
+ {
+ // {{{
+ $robotstxt = new Robotstxt(
+ "# /robots.txt for http://www.fict.org/
# comments to webmaster@fict.org
User-agent: unhipbot
@@ -1187,17 +1337,20 @@ class RobotstxtTest extends \PHPUnit_Framework_TestCase
Allow: /org/
Allow: /serv
Allow: /~mak
- Disallow: /", "other"
- );
- // }}}
- $this->assertSame (
- $robotstxt->URLAllow ("http://www.fict.org/services/slow.html"), true);
- }
- public function test_rfc_other_7 ()
- {
- // {{{
- $robotstxt = new Robotstxt (
- "# /robots.txt for http://www.fict.org/
+ Disallow: /",
+ "other"
+ );
+ // }}}
+ $this->assertSame(
+ $robotstxt->URLAllow("http://www.fict.org/services/slow.html"),
+ true
+ );
+ }
+ public function test_rfc_other_7()
+ {
+ // {{{
+ $robotstxt = new Robotstxt(
+ "# /robots.txt for http://www.fict.org/
# comments to webmaster@fict.org
User-agent: unhipbot
@@ -1212,17 +1365,20 @@ class RobotstxtTest extends \PHPUnit_Framework_TestCase
Allow: /org/
Allow: /serv
Allow: /~mak
- Disallow: /", "other"
- );
- // }}}
- $this->assertSame (
- $robotstxt->URLAllow ("http://www.fict.org/orgo.gif"), false);
- }
- public function test_rfc_other_8 ()
- {
- // {{{
- $robotstxt = new Robotstxt (
- "# /robots.txt for http://www.fict.org/
+ Disallow: /",
+ "other"
+ );
+ // }}}
+ $this->assertSame(
+ $robotstxt->URLAllow("http://www.fict.org/orgo.gif"),
+ false
+ );
+ }
+ public function test_rfc_other_8()
+ {
+ // {{{
+ $robotstxt = new Robotstxt(
+ "# /robots.txt for http://www.fict.org/
# comments to webmaster@fict.org
User-agent: unhipbot
@@ -1237,17 +1393,20 @@ class RobotstxtTest extends \PHPUnit_Framework_TestCase
Allow: /org/
Allow: /serv
Allow: /~mak
- Disallow: /", "other"
- );
- // }}}
- $this->assertSame (
- $robotstxt->URLAllow ("http://www.fict.org/org/about.html"), true);
- }
- public function test_rfc_other_9 ()
- {
- // {{{
- $robotstxt = new Robotstxt (
- "# /robots.txt for http://www.fict.org/
+ Disallow: /",
+ "other"
+ );
+ // }}}
+ $this->assertSame(
+ $robotstxt->URLAllow("http://www.fict.org/org/about.html"),
+ true
+ );
+ }
+ public function test_rfc_other_9()
+ {
+ // {{{
+ $robotstxt = new Robotstxt(
+ "# /robots.txt for http://www.fict.org/
# comments to webmaster@fict.org
User-agent: unhipbot
@@ -1262,17 +1421,20 @@ class RobotstxtTest extends \PHPUnit_Framework_TestCase
Allow: /org/
Allow: /serv
Allow: /~mak
- Disallow: /", "other"
- );
- // }}}
- $this->assertSame (
- $robotstxt->URLAllow ("http://www.fict.org/org/plans.html"), false);
- }
- public function test_rfc_other_10 ()
- {
- // {{{
- $robotstxt = new Robotstxt (
- "# /robots.txt for http://www.fict.org/
+ Disallow: /",
+ "other"
+ );
+ // }}}
+ $this->assertSame(
+ $robotstxt->URLAllow("http://www.fict.org/org/plans.html"),
+ false
+ );
+ }
+ public function test_rfc_other_10()
+ {
+ // {{{
+ $robotstxt = new Robotstxt(
+ "# /robots.txt for http://www.fict.org/
# comments to webmaster@fict.org
User-agent: unhipbot
@@ -1287,17 +1449,20 @@ class RobotstxtTest extends \PHPUnit_Framework_TestCase
Allow: /org/
Allow: /serv
Allow: /~mak
- Disallow: /", "other"
- );
- // }}}
- $this->assertSame (
- $robotstxt->URLAllow ("http://www.fict.org/~jim/jim.html"), false);
- }
- public function test_rfc_other_11 ()
- {
- // {{{
- $robotstxt = new Robotstxt (
- "# /robots.txt for http://www.fict.org/
+ Disallow: /",
+ "other"
+ );
+ // }}}
+ $this->assertSame(
+ $robotstxt->URLAllow("http://www.fict.org/~jim/jim.html"),
+ false
+ );
+ }
+ public function test_rfc_other_11()
+ {
+ // {{{
+ $robotstxt = new Robotstxt(
+ "# /robots.txt for http://www.fict.org/
# comments to webmaster@fict.org
User-agent: unhipbot
@@ -1312,10 +1477,13 @@ class RobotstxtTest extends \PHPUnit_Framework_TestCase
Allow: /org/
Allow: /serv
Allow: /~mak
- Disallow: /", "other"
- );
- // }}}
- $this->assertSame (
- $robotstxt->URLAllow ("http://www.fict.org/~mak/mak.html"), true);
- }
+ Disallow: /",
+ "other"
+ );
+ // }}}
+ $this->assertSame(
+ $robotstxt->URLAllow("http://www.fict.org/~mak/mak.html"),
+ true
+ );
+ }
}
diff --git a/Tests/RouteTest.php b/Tests/RouteTest.php
index 3fe226d..352e6d7 100644
--- a/Tests/RouteTest.php
+++ b/Tests/RouteTest.php
@@ -1,4 +1,5 @@
@@ -14,335 +15,335 @@ class RouteTest extends \PHPUnit_Framework_TestCase
{
/// RELATIVE ///
/** Entry null */
- public function test_baseURL_1_relative ()
- {
- $route = new Route ();
- $route->baseURL ();
- $this->expectOutputString("");
- }
+ public function test_baseURL_1_relative()
+ {
+ $route = new Route();
+ $route->baseURL();
+ $this->expectOutputString("");
+ }
/** Port 80 and HTTP without module */
- public function test_baseURL_2_relative ()
- {
- $_SERVER["SERVER_NAME"] = "localhost";
- $_SERVER["SERVER_PORT"] = "80";
- $_SERVER["SCRIPT_NAME"] = "/index.php";
- $route = new Route ();
- echo $route->baseURL ();
- $this->expectOutputString("/");
- }
+ public function test_baseURL_2_relative()
+ {
+ $_SERVER["SERVER_NAME"] = "localhost";
+ $_SERVER["SERVER_PORT"] = "80";
+ $_SERVER["SCRIPT_NAME"] = "/index.php";
+ $route = new Route();
+ echo $route->baseURL();
+ $this->expectOutputString("/");
+ }
/** Port 443 and HTTPS without module */
- public function test_baseURL_3_relative ()
- {
- unset ($_SERVER["HTTPS"]);
- $_SERVER["SERVER_NAME"] = "localhost";
- $_SERVER["SERVER_PORT"] = "443";
- $_SERVER["HTTPS"] = true;
- $_SERVER["SCRIPT_NAME"] = "/index.php";
- $route = new Route ();
- echo $route->baseURL ();
- $this->expectOutputString("/");
- }
+ public function test_baseURL_3_relative()
+ {
+ unset($_SERVER["HTTPS"]);
+ $_SERVER["SERVER_NAME"] = "localhost";
+ $_SERVER["SERVER_PORT"] = "443";
+ $_SERVER["HTTPS"] = true;
+ $_SERVER["SCRIPT_NAME"] = "/index.php";
+ $route = new Route();
+ echo $route->baseURL();
+ $this->expectOutputString("/");
+ }
/** Port 888 and HTTP without module */
- public function test_baseURL_4_relative ()
- {
- unset ($_SERVER["HTTPS"]);
- $_SERVER["SERVER_NAME"] = "localhost";
- $_SERVER["SERVER_PORT"] = "888";
- $_SERVER["SCRIPT_NAME"] = "/index.php";
- $route = new Route ();
- echo $route->baseURL ();
- $this->expectOutputString("/");
- }
+ public function test_baseURL_4_relative()
+ {
+ unset($_SERVER["HTTPS"]);
+ $_SERVER["SERVER_NAME"] = "localhost";
+ $_SERVER["SERVER_PORT"] = "888";
+ $_SERVER["SCRIPT_NAME"] = "/index.php";
+ $route = new Route();
+ echo $route->baseURL();
+ $this->expectOutputString("/");
+ }
/** Port 888 and HTTPS without module */
- public function test_baseURL_5_relative ()
- {
- $_SERVER["SERVER_NAME"] = "localhost";
- $_SERVER["SERVER_PORT"] = "888";
- $_SERVER["HTTPS"] = true;
- $_SERVER["SCRIPT_NAME"] = "/index.php";
- $route = new Route ();
- echo $route->baseURL ();
- $this->expectOutputString("/");
- }
+ public function test_baseURL_5_relative()
+ {
+ $_SERVER["SERVER_NAME"] = "localhost";
+ $_SERVER["SERVER_PORT"] = "888";
+ $_SERVER["HTTPS"] = true;
+ $_SERVER["SCRIPT_NAME"] = "/index.php";
+ $route = new Route();
+ echo $route->baseURL();
+ $this->expectOutputString("/");
+ }
/** Port 80 and HTTP with module */
- public function test_baseURL_2_module_relative ()
- {
- unset ($_SERVER["HTTPS"]);
- $_SERVER["SERVER_NAME"] = "localhost";
- $_SERVER["SERVER_PORT"] = "80";
- $_SERVER["SCRIPT_NAME"] = "/module/index.php";
- $route = new Route ();
- echo $route->baseURL ("module");
- $this->expectOutputString("/");
- }
+ public function test_baseURL_2_module_relative()
+ {
+ unset($_SERVER["HTTPS"]);
+ $_SERVER["SERVER_NAME"] = "localhost";
+ $_SERVER["SERVER_PORT"] = "80";
+ $_SERVER["SCRIPT_NAME"] = "/module/index.php";
+ $route = new Route();
+ echo $route->baseURL("module");
+ $this->expectOutputString("/");
+ }
/** Port 443 and HTTPS with module */
- public function test_baseURL_3_module_relative ()
- {
- $_SERVER["SERVER_NAME"] = "localhost";
- $_SERVER["SERVER_PORT"] = "443";
- $_SERVER["HTTPS"] = true;
- $_SERVER["SCRIPT_NAME"] = "/module/index.php";
- $route = new Route ();
- echo $route->baseURL ("module");
- $this->expectOutputString("/");
- }
+ public function test_baseURL_3_module_relative()
+ {
+ $_SERVER["SERVER_NAME"] = "localhost";
+ $_SERVER["SERVER_PORT"] = "443";
+ $_SERVER["HTTPS"] = true;
+ $_SERVER["SCRIPT_NAME"] = "/module/index.php";
+ $route = new Route();
+ echo $route->baseURL("module");
+ $this->expectOutputString("/");
+ }
/** Port 888 and HTTP with module */
- public function test_baseURL_4_module_relative ()
- {
- unset ($_SERVER["HTTPS"]);
- $_SERVER["SERVER_NAME"] = "localhost";
- $_SERVER["SERVER_PORT"] = "888";
- $_SERVER["SCRIPT_NAME"] = "/module/index.php";
- $route = new Route ();
- echo $route->baseURL ("module");
- $this->expectOutputString("/");
- }
+ public function test_baseURL_4_module_relative()
+ {
+ unset($_SERVER["HTTPS"]);
+ $_SERVER["SERVER_NAME"] = "localhost";
+ $_SERVER["SERVER_PORT"] = "888";
+ $_SERVER["SCRIPT_NAME"] = "/module/index.php";
+ $route = new Route();
+ echo $route->baseURL("module");
+ $this->expectOutputString("/");
+ }
/** Port 888 and HTTPS with module */
- public function test_baseURL_5_module_relative ()
- {
- $_SERVER["SERVER_NAME"] = "localhost";
- $_SERVER["SERVER_PORT"] = "888";
- $_SERVER["HTTPS"] = true;
- $_SERVER["SCRIPT_NAME"] = "/module/index.php";
- $route = new Route ();
- echo $route->baseURL ("module");
- $this->expectOutputString("/");
- }
+ public function test_baseURL_5_module_relative()
+ {
+ $_SERVER["SERVER_NAME"] = "localhost";
+ $_SERVER["SERVER_PORT"] = "888";
+ $_SERVER["HTTPS"] = true;
+ $_SERVER["SCRIPT_NAME"] = "/module/index.php";
+ $route = new Route();
+ echo $route->baseURL("module");
+ $this->expectOutputString("/");
+ }
/// ABSOLUTE ///
/** Entry null */
- public function test_baseURL_1_absolute ()
- {
- $route = new Route ();
- $route->baseURL (false, true);
- $this->expectOutputString("");
- }
+ public function test_baseURL_1_absolute()
+ {
+ $route = new Route();
+ $route->baseURL(false, true);
+ $this->expectOutputString("");
+ }
/** Port 80 and HTTP without module */
- public function test_baseURL_2_absolute ()
- {
- $_SERVER["SERVER_NAME"] = "localhost";
- $_SERVER["SERVER_PORT"] = "80";
- $_SERVER["SCRIPT_NAME"] = "/index.php";
- $route = new Route ();
- echo $route->baseURL (false, true);
- $this->expectOutputString("https://localhost:80/");
- }
+ public function test_baseURL_2_absolute()
+ {
+ $_SERVER["SERVER_NAME"] = "localhost";
+ $_SERVER["SERVER_PORT"] = "80";
+ $_SERVER["SCRIPT_NAME"] = "/index.php";
+ $route = new Route();
+ echo $route->baseURL(false, true);
+ $this->expectOutputString("https://localhost:80/");
+ }
/** Port 443 and HTTPS without module */
- public function test_baseURL_3_absolute ()
- {
- unset ($_SERVER["HTTPS"]);
- $_SERVER["SERVER_NAME"] = "localhost";
- $_SERVER["SERVER_PORT"] = "443";
- $_SERVER["HTTPS"] = true;
- $_SERVER["SCRIPT_NAME"] = "/index.php";
- $route = new Route ();
- echo $route->baseURL (false, true);
- $this->expectOutputString("https://localhost/");
- }
+ public function test_baseURL_3_absolute()
+ {
+ unset($_SERVER["HTTPS"]);
+ $_SERVER["SERVER_NAME"] = "localhost";
+ $_SERVER["SERVER_PORT"] = "443";
+ $_SERVER["HTTPS"] = true;
+ $_SERVER["SCRIPT_NAME"] = "/index.php";
+ $route = new Route();
+ echo $route->baseURL(false, true);
+ $this->expectOutputString("https://localhost/");
+ }
/** Port 888 and HTTP without module */
- public function test_baseURL_4_absolute ()
- {
- unset ($_SERVER["HTTPS"]);
- $_SERVER["SERVER_NAME"] = "localhost";
- $_SERVER["SERVER_PORT"] = "888";
- $_SERVER["SCRIPT_NAME"] = "/index.php";
- $route = new Route ();
- echo $route->baseURL (false, true);
- $this->expectOutputString("http://localhost:888/");
- }
+ public function test_baseURL_4_absolute()
+ {
+ unset($_SERVER["HTTPS"]);
+ $_SERVER["SERVER_NAME"] = "localhost";
+ $_SERVER["SERVER_PORT"] = "888";
+ $_SERVER["SCRIPT_NAME"] = "/index.php";
+ $route = new Route();
+ echo $route->baseURL(false, true);
+ $this->expectOutputString("http://localhost:888/");
+ }
/** Port 888 and HTTPS without module */
- public function test_baseURL_5_absolute ()
- {
- $_SERVER["SERVER_NAME"] = "localhost";
- $_SERVER["SERVER_PORT"] = "888";
- $_SERVER["HTTPS"] = true;
- $_SERVER["SCRIPT_NAME"] = "/index.php";
- $route = new Route ();
- echo $route->baseURL (false, true);
- $this->expectOutputString("https://localhost:888/");
- }
+ public function test_baseURL_5_absolute()
+ {
+ $_SERVER["SERVER_NAME"] = "localhost";
+ $_SERVER["SERVER_PORT"] = "888";
+ $_SERVER["HTTPS"] = true;
+ $_SERVER["SCRIPT_NAME"] = "/index.php";
+ $route = new Route();
+ echo $route->baseURL(false, true);
+ $this->expectOutputString("https://localhost:888/");
+ }
/** Port 80 and HTTP with module */
- public function test_baseURL_2_module_absolute ()
- {
- unset ($_SERVER["HTTPS"]);
- $_SERVER["SERVER_NAME"] = "localhost";
- $_SERVER["SERVER_PORT"] = "80";
- $_SERVER["SCRIPT_NAME"] = "/module/index.php";
- $route = new Route ();
- echo $route->baseURL ("module", true);
- $this->expectOutputString("http://localhost/");
- }
+ public function test_baseURL_2_module_absolute()
+ {
+ unset($_SERVER["HTTPS"]);
+ $_SERVER["SERVER_NAME"] = "localhost";
+ $_SERVER["SERVER_PORT"] = "80";
+ $_SERVER["SCRIPT_NAME"] = "/module/index.php";
+ $route = new Route();
+ echo $route->baseURL("module", true);
+ $this->expectOutputString("http://localhost/");
+ }
/** Port 443 and HTTPS with module */
- public function test_baseURL_3_module_absolute ()
- {
- $_SERVER["SERVER_NAME"] = "localhost";
- $_SERVER["SERVER_PORT"] = "443";
- $_SERVER["HTTPS"] = true;
- $_SERVER["SCRIPT_NAME"] = "/module/index.php";
- $route = new Route ();
- echo $route->baseURL ("module", true);
- $this->expectOutputString("https://localhost/");
- }
+ public function test_baseURL_3_module_absolute()
+ {
+ $_SERVER["SERVER_NAME"] = "localhost";
+ $_SERVER["SERVER_PORT"] = "443";
+ $_SERVER["HTTPS"] = true;
+ $_SERVER["SCRIPT_NAME"] = "/module/index.php";
+ $route = new Route();
+ echo $route->baseURL("module", true);
+ $this->expectOutputString("https://localhost/");
+ }
/** Port 888 and HTTP with module */
- public function test_baseURL_4_module_absolute ()
- {
- unset ($_SERVER["HTTPS"]);
- $_SERVER["SERVER_NAME"] = "localhost";
- $_SERVER["SERVER_PORT"] = "888";
- $_SERVER["SCRIPT_NAME"] = "/module/index.php";
- $route = new Route ();
- echo $route->baseURL ("module", true);
- $this->expectOutputString("http://localhost:888/");
- }
+ public function test_baseURL_4_module_absolute()
+ {
+ unset($_SERVER["HTTPS"]);
+ $_SERVER["SERVER_NAME"] = "localhost";
+ $_SERVER["SERVER_PORT"] = "888";
+ $_SERVER["SCRIPT_NAME"] = "/module/index.php";
+ $route = new Route();
+ echo $route->baseURL("module", true);
+ $this->expectOutputString("http://localhost:888/");
+ }
/** Port 888 and HTTPS with module */
- public function test_baseURL_5_module_absolute ()
- {
- $_SERVER["SERVER_NAME"] = "localhost";
- $_SERVER["SERVER_PORT"] = "888";
- $_SERVER["HTTPS"] = true;
- $_SERVER["SCRIPT_NAME"] = "/module/index.php";
- $route = new Route ();
- echo $route->baseURL ("module", true);
- $this->expectOutputString("https://localhost:888/");
- }
+ public function test_baseURL_5_module_absolute()
+ {
+ $_SERVER["SERVER_NAME"] = "localhost";
+ $_SERVER["SERVER_PORT"] = "888";
+ $_SERVER["HTTPS"] = true;
+ $_SERVER["SCRIPT_NAME"] = "/module/index.php";
+ $route = new Route();
+ echo $route->baseURL("module", true);
+ $this->expectOutputString("https://localhost:888/");
+ }
/// REQUESTURL ///
/** Port 80 and HTTP requestURL */
- public function test_requestURL_2_direct ()
- {
- unset ($_SERVER["HTTPS"]);
- $_SERVER["SERVER_NAME"] = "localhost";
- $_SERVER["SERVER_PORT"] = "80";
- $_SERVER["SCRIPT_NAME"] = "/index.php";
- $_SERVER["REQUEST_URI"] = "/index.php?url=bla";
- $route = new Route ();
- echo $route->requestURL ();
- $this->expectOutputString("index.php?url=bla");
- }
+ public function test_requestURL_2_direct()
+ {
+ unset($_SERVER["HTTPS"]);
+ $_SERVER["SERVER_NAME"] = "localhost";
+ $_SERVER["SERVER_PORT"] = "80";
+ $_SERVER["SCRIPT_NAME"] = "/index.php";
+ $_SERVER["REQUEST_URI"] = "/index.php?url=bla";
+ $route = new Route();
+ echo $route->requestURL();
+ $this->expectOutputString("index.php?url=bla");
+ }
/** Port 443 and HTTPS requestURL */
- public function test_requestURL_3_direct ()
- {
- $_SERVER["SERVER_NAME"] = "localhost";
- $_SERVER["SERVER_PORT"] = "443";
- $_SERVER["HTTPS"] = true;
- $_SERVER["SCRIPT_NAME"] = "/index.php";
- $_SERVER["REQUEST_URI"] = "/index.php?var=1";
- $route = new Route ();
- echo $route->requestURL ();
- $this->expectOutputString("index.php?var=1");
- }
+ public function test_requestURL_3_direct()
+ {
+ $_SERVER["SERVER_NAME"] = "localhost";
+ $_SERVER["SERVER_PORT"] = "443";
+ $_SERVER["HTTPS"] = true;
+ $_SERVER["SCRIPT_NAME"] = "/index.php";
+ $_SERVER["REQUEST_URI"] = "/index.php?var=1";
+ $route = new Route();
+ echo $route->requestURL();
+ $this->expectOutputString("index.php?var=1");
+ }
/** Port 888 and HTTP requestURL */
- public function test_requestURL_4_direct ()
- {
- unset ($_SERVER["HTTPS"]);
- $_SERVER["SERVER_NAME"] = "localhost";
- $_SERVER["SERVER_PORT"] = "888";
- $_SERVER["SCRIPT_NAME"] = "/index.php";
- $_SERVER["REQUEST_URI"] = "/index.php?var=1";
- $route = new Route ();
- echo $route->requestURL ();
- $this->expectOutputString("index.php?var=1");
- }
+ public function test_requestURL_4_direct()
+ {
+ unset($_SERVER["HTTPS"]);
+ $_SERVER["SERVER_NAME"] = "localhost";
+ $_SERVER["SERVER_PORT"] = "888";
+ $_SERVER["SCRIPT_NAME"] = "/index.php";
+ $_SERVER["REQUEST_URI"] = "/index.php?var=1";
+ $route = new Route();
+ echo $route->requestURL();
+ $this->expectOutputString("index.php?var=1");
+ }
/** Port 888 and HTTPS requestURL */
- public function test_requestURL_5_direct ()
- {
- $_SERVER["SERVER_NAME"] = "localhost";
- $_SERVER["SERVER_PORT"] = "888";
- $_SERVER["HTTPS"] = true;
- $_SERVER["SCRIPT_NAME"] = "/index.php";
- $_SERVER["REQUEST_URI"] = "/index.php?var=1";
- $route = new Route ();
- echo $route->requestURL ();
- $this->expectOutputString("index.php?var=1");
- }
+ public function test_requestURL_5_direct()
+ {
+ $_SERVER["SERVER_NAME"] = "localhost";
+ $_SERVER["SERVER_PORT"] = "888";
+ $_SERVER["HTTPS"] = true;
+ $_SERVER["SCRIPT_NAME"] = "/index.php";
+ $_SERVER["REQUEST_URI"] = "/index.php?var=1";
+ $route = new Route();
+ echo $route->requestURL();
+ $this->expectOutputString("index.php?var=1");
+ }
/** Port 80 and HTTP requestURL */
- public function test_requestURL_2_rewrite ()
- {
- unset ($_SERVER["HTTPS"]);
- $_SERVER["SERVER_NAME"] = "localhost";
- $_SERVER["SERVER_PORT"] = "80";
- $_SERVER["SCRIPT_NAME"] = "/index.php";
- $_SERVER["REQUEST_URI"] = "/bla";
- $route = new Route ();
- echo $route->requestURL ();
- $this->expectOutputString("bla");
- }
+ public function test_requestURL_2_rewrite()
+ {
+ unset($_SERVER["HTTPS"]);
+ $_SERVER["SERVER_NAME"] = "localhost";
+ $_SERVER["SERVER_PORT"] = "80";
+ $_SERVER["SCRIPT_NAME"] = "/index.php";
+ $_SERVER["REQUEST_URI"] = "/bla";
+ $route = new Route();
+ echo $route->requestURL();
+ $this->expectOutputString("bla");
+ }
/** Port 443 and HTTPS requestURL */
- public function test_requestURL_3_rewrite ()
- {
- $_SERVER["SERVER_NAME"] = "localhost";
- $_SERVER["SERVER_PORT"] = "443";
- $_SERVER["HTTPS"] = true;
- $_SERVER["SCRIPT_NAME"] = "/index.php";
- $_SERVER["REQUEST_URI"] = "/var=1";
- $route = new Route ();
- echo $route->requestURL ();
- $this->expectOutputString("var=1");
- }
+ public function test_requestURL_3_rewrite()
+ {
+ $_SERVER["SERVER_NAME"] = "localhost";
+ $_SERVER["SERVER_PORT"] = "443";
+ $_SERVER["HTTPS"] = true;
+ $_SERVER["SCRIPT_NAME"] = "/index.php";
+ $_SERVER["REQUEST_URI"] = "/var=1";
+ $route = new Route();
+ echo $route->requestURL();
+ $this->expectOutputString("var=1");
+ }
/** Port 888 and HTTP requestURL */
- public function test_requestURL_4_rewrite ()
- {
- unset ($_SERVER["HTTPS"]);
- $_SERVER["SERVER_NAME"] = "localhost";
- $_SERVER["SERVER_PORT"] = "888";
- $_SERVER["SCRIPT_NAME"] = "/index.php";
- $_SERVER["REQUEST_URI"] = "/var=1";
- $route = new Route ();
- echo $route->requestURL ();
- $this->expectOutputString("var=1");
- }
+ public function test_requestURL_4_rewrite()
+ {
+ unset($_SERVER["HTTPS"]);
+ $_SERVER["SERVER_NAME"] = "localhost";
+ $_SERVER["SERVER_PORT"] = "888";
+ $_SERVER["SCRIPT_NAME"] = "/index.php";
+ $_SERVER["REQUEST_URI"] = "/var=1";
+ $route = new Route();
+ echo $route->requestURL();
+ $this->expectOutputString("var=1");
+ }
/** Port 888 and HTTPS requestURL */
- public function test_requestURL_5_rewrite ()
- {
- $_SERVER["SERVER_NAME"] = "localhost";
- $_SERVER["SERVER_PORT"] = "888";
- $_SERVER["HTTPS"] = true;
- $_SERVER["SCRIPT_NAME"] = "/index.php";
- $_SERVER["REQUEST_URI"] = "/var=1";
- $route = new Route ();
- echo $route->requestURL ();
- $this->expectOutputString("var=1");
- }
+ public function test_requestURL_5_rewrite()
+ {
+ $_SERVER["SERVER_NAME"] = "localhost";
+ $_SERVER["SERVER_PORT"] = "888";
+ $_SERVER["HTTPS"] = true;
+ $_SERVER["SCRIPT_NAME"] = "/index.php";
+ $_SERVER["REQUEST_URI"] = "/var=1";
+ $route = new Route();
+ echo $route->requestURL();
+ $this->expectOutputString("var=1");
+ }
/** Ratelimiting in errors */
- public function test_errorRateLimit1 ()
- {
- $route = new Route ();
- $route->ratelimiter->storageDir = "/tmp/ratelimit-".time();
- $route->error (new \Exception ("test1", 500));
- $route->error (new \Exception ("test2", 500));
- $route->error (new \Exception ("test3", 500));
- $route->error (new \Exception ("test4", 500));
- $route->error (new \Exception ("test5", 500));
- $route->error (new \Exception ("test6", 500));
- $route->error (new \Exception ("test7", 500));
- $route->error (new \Exception ("test8", 500));
- $route->error (new \Exception ("test9", 500));
- $route->error (new \Exception ("test0", 500));
- $route->error (new \Exception ("test11", 500));
- $this->expectOutputRegex("#Too much error requests#");
- }
+ public function test_errorRateLimit1()
+ {
+ $route = new Route();
+ $route->ratelimiter->storageDir = "/tmp/ratelimit-" . time();
+ $route->error(new \Exception("test1", 500));
+ $route->error(new \Exception("test2", 500));
+ $route->error(new \Exception("test3", 500));
+ $route->error(new \Exception("test4", 500));
+ $route->error(new \Exception("test5", 500));
+ $route->error(new \Exception("test6", 500));
+ $route->error(new \Exception("test7", 500));
+ $route->error(new \Exception("test8", 500));
+ $route->error(new \Exception("test9", 500));
+ $route->error(new \Exception("test0", 500));
+ $route->error(new \Exception("test11", 500));
+ $this->expectOutputRegex("#Too much error requests#");
+ }
}
diff --git a/Tests/RssTest.php b/Tests/RssTest.php
index 753c678..919cc9f 100644
--- a/Tests/RssTest.php
+++ b/Tests/RssTest.php
@@ -1,4 +1,5 @@
@@ -12,31 +13,31 @@ use Domframework\Rss;
/** Test the RSS */
class RssTest extends \PHPUnit_Framework_TestCase
{
- public function test_empty0 ()
- {
- // Empty
- $this->expectException ("Exception", "No title is provided for this RSS");
- $rss = new Rss ();
- $res = $rss->asXML ();
- }
+ public function test_empty0()
+ {
+ // Empty
+ $this->expectException("Exception", "No title is provided for this RSS");
+ $rss = new Rss();
+ $res = $rss->asXML();
+ }
- public function test_functional1 ()
- {
- // Functionnal 1
- $rss = new Rss ();
- $rss->title ("Global Title")
- ->link ("http://localhost")
- ->language ("fr-fr")
- ->description ("The Super Global Description");
- $rss->addItem ()->title ("Item1 Title")
- ->link ("http://Item1Link")
- ->description ("Item1 Description");
- $rss->addItem ()->title ("Item2 Title")
- ->pubDate ("2017-04-13 12:25:30")
- ->link ("http://Item2Link")
- ->description ("Item2 Description");
- $res = $rss->asXML ();
- $this->assertSame ($res, "
+ public function test_functional1()
+ {
+ // Functionnal 1
+ $rss = new Rss();
+ $rss->title("Global Title")
+ ->link("http://localhost")
+ ->language("fr-fr")
+ ->description("The Super Global Description");
+ $rss->addItem()->title("Item1 Title")
+ ->link("http://Item1Link")
+ ->description("Item1 Description");
+ $rss->addItem()->title("Item2 Title")
+ ->pubDate("2017-04-13 12:25:30")
+ ->link("http://Item2Link")
+ ->description("Item2 Description");
+ $res = $rss->asXML();
+ $this->assertSame($res, "
Global Title
@@ -57,99 +58,109 @@ class RssTest extends \PHPUnit_Framework_TestCase
");
- }
+ }
- public function test_error1 ()
- {
- // Missing global description
- $this->expectException ("Exception",
- "No description is provided for this RSS");
- $rss = new Rss ();
- $rss->title ("Global Title")
- ->link ("http://localhost")
- ->language ("fr-fr");
- $res = $rss->asXML ();
- }
+ public function test_error1()
+ {
+ // Missing global description
+ $this->expectException(
+ "Exception",
+ "No description is provided for this RSS"
+ );
+ $rss = new Rss();
+ $rss->title("Global Title")
+ ->link("http://localhost")
+ ->language("fr-fr");
+ $res = $rss->asXML();
+ }
- public function test_error2 ()
- {
- // Missing global link
- $this->expectException ("Exception", "No link is provided for this RSS");
- $rss = new Rss ();
- $rss->title ("Global Title")
- ->language ("fr-fr")
- ->description ("The Super Global Description");
- $res = $rss->asXML ();
- }
+ public function test_error2()
+ {
+ // Missing global link
+ $this->expectException("Exception", "No link is provided for this RSS");
+ $rss = new Rss();
+ $rss->title("Global Title")
+ ->language("fr-fr")
+ ->description("The Super Global Description");
+ $res = $rss->asXML();
+ }
- public function test_error3 ()
- {
- // Missing global title
- $this->expectException ("Exception", "No title is provided for this RSS");
- $rss = new Rss ();
- $rss->link ("http://localhost")
- ->language ("fr-fr")
- ->description ("The Super Global Description");
- $res = $rss->asXML ();
- }
+ public function test_error3()
+ {
+ // Missing global title
+ $this->expectException("Exception", "No title is provided for this RSS");
+ $rss = new Rss();
+ $rss->link("http://localhost")
+ ->language("fr-fr")
+ ->description("The Super Global Description");
+ $res = $rss->asXML();
+ }
- public function test_error4 ()
- {
- // Invalid date provided
- $this->expectException ("Exception",
- "lastBuildDate provided to RSS is not a valid date");
- $rss = new Rss ();
- $rss->title ("Global Title")
- ->link ("http://localhost")
- ->lastBuildDate ("2017-04-33")
- ->language ("fr-fr")
- ->description ("The Super Global Description");
- $res = $rss->asXML ();
- }
+ public function test_error4()
+ {
+ // Invalid date provided
+ $this->expectException(
+ "Exception",
+ "lastBuildDate provided to RSS is not a valid date"
+ );
+ $rss = new Rss();
+ $rss->title("Global Title")
+ ->link("http://localhost")
+ ->lastBuildDate("2017-04-33")
+ ->language("fr-fr")
+ ->description("The Super Global Description");
+ $res = $rss->asXML();
+ }
- public function test_itemError1 ()
- {
- // Empty Item provided
- $this->expectException ("Exception",
- "No title nor description defined in the RSS item");
- $rss = new Rss ();
- $rss->title ("Global Title")
- ->link ("http://localhost")
- ->lastBuildDate ("2017-04-30 12:35:32")
- ->language ("fr-fr")
- ->description ("The Super Global Description");
- $rss->addItem ();
- $res = $rss->asXML ();
- }
+ public function test_itemError1()
+ {
+ // Empty Item provided
+ $this->expectException(
+ "Exception",
+ "No title nor description defined in the RSS item"
+ );
+ $rss = new Rss();
+ $rss->title("Global Title")
+ ->link("http://localhost")
+ ->lastBuildDate("2017-04-30 12:35:32")
+ ->language("fr-fr")
+ ->description("The Super Global Description");
+ $rss->addItem();
+ $res = $rss->asXML();
+ }
- public function test_itemError2 ()
- {
- // Item without Title and Description
- $this->expectException ("Exception",
- "No title nor description defined in the RSS item");
- $rss = new Rss ();
- $rss->title ("Global Title")
- ->link ("http://localhost")
- ->lastBuildDate ("2017-04-30 12:35:32")
- ->language ("fr-fr")
- ->description ("The Super Global Description");
- $rss->addItem ()->link ("http://localhost/link");
- $res = $rss->asXML ();
- }
+ public function test_itemError2()
+ {
+ // Item without Title and Description
+ $this->expectException(
+ "Exception",
+ "No title nor description defined in the RSS item"
+ );
+ $rss = new Rss();
+ $rss->title("Global Title")
+ ->link("http://localhost")
+ ->lastBuildDate("2017-04-30 12:35:32")
+ ->language("fr-fr")
+ ->description("The Super Global Description");
+ $rss->addItem()->link("http://localhost/link");
+ $res = $rss->asXML();
+ }
- public function test_itemError3 ()
- {
- // Item with invalid date
- $this->expectException ("Exception",
- "pubDate provided to RSS Item is not a valid date");
- $rss = new Rss ();
- $rss->title ("Global Title")
- ->link ("http://localhost")
- ->lastBuildDate ("2017-10-30 12:35:32")
- ->language ("fr-fr")
- ->description ("The Super Global Description");
- $rss->addItem ()->title ("Item title")
- ->pubDate ("2017-14-33 12:32:32");
- $res = $rss->asXML ();
- }
+ public function test_itemError3()
+ {
+ // Item with invalid date
+ $this->expectException(
+ "Exception",
+ "pubDate provided to RSS Item is not a valid date"
+ );
+ $rss = new Rss();
+ $rss->title("Global Title")
+ ->link("http://localhost")
+ ->lastBuildDate("2017-10-30 12:35:32")
+ ->language("fr-fr")
+ ->description("The Super Global Description");
+ $rss->addItem()->title("Item title")
+ ->pubDate("2017-14-33 12:32:32");
+ $res = $rss->asXML();
+ }
}
diff --git a/Tests/SitemapTest.php b/Tests/SitemapTest.php
index ed1e3da..0bdbfe9 100644
--- a/Tests/SitemapTest.php
+++ b/Tests/SitemapTest.php
@@ -1,4 +1,5 @@
@@ -14,46 +15,52 @@ use Domframework\Sitemap;
class SitemapTest extends \PHPUnit_Framework_TestCase
{
// Empty Sitemap
- public function test_EmptySitemap_1 ()
- {
- $sitemap = new Sitemap ();
- $res = $sitemap->analyze ("", "http://example.com");
- $this->assertSame ($res, ["urls" => [], "sitemaps" => []]);
- }
+ public function test_EmptySitemap_1()
+ {
+ $sitemap = new Sitemap();
+ $res = $sitemap->analyze("", "http://example.com");
+ $this->assertSame($res, ["urls" => [], "sitemaps" => []]);
+ }
// Empty Sitemap
- public function test_EmptySitemap_2 ()
- {
- $sitemap = new Sitemap ();
- $res = $sitemap->analyze (" ", "http://example.com");
- $this->assertSame ($res, ["urls" => [], "sitemaps" => []]);
- }
+ public function test_EmptySitemap_2()
+ {
+ $sitemap = new Sitemap();
+ $res = $sitemap->analyze(" ", "http://example.com");
+ $this->assertSame($res, ["urls" => [], "sitemaps" => []]);
+ }
// Textual Sitemap
- public function test_TextualSitemap_1 ()
- {
- $sitemap = new Sitemap ();
- $res = $sitemap->analyze ("http://example.com", "http://example.com");
- $this->assertSame ($res,
- ["urls" => ["http://example.com" => []],
- "sitemaps" => []]);
- }
- public function test_TextualSitemap_2 ()
- {
- $sitemap = new Sitemap ();
- $res = $sitemap->analyze ("http://example.com\nhttps://www.example.com\n\n",
- "http://example.com");
- $this->assertSame ($res,
- ["urls" => ["http://example.com" => [], "https://www.example.com" => []],
- "sitemaps" => []]);
- }
+ public function test_TextualSitemap_1()
+ {
+ $sitemap = new Sitemap();
+ $res = $sitemap->analyze("http://example.com", "http://example.com");
+ $this->assertSame(
+ $res,
+ ["urls" => ["http://example.com" => []],
+ "sitemaps" => []]
+ );
+ }
+ public function test_TextualSitemap_2()
+ {
+ $sitemap = new Sitemap();
+ $res = $sitemap->analyze(
+ "http://example.com\nhttps://www.example.com\n\n",
+ "http://example.com"
+ );
+ $this->assertSame(
+ $res,
+ ["urls" => ["http://example.com" => [], "https://www.example.com" => []],
+ "sitemaps" => []]
+ );
+ }
// XML Sitemap
- public function test_XMLSitemap_1 ()
- {
- $sitemap = new Sitemap ();
- $res = $sitemap->analyze (
-'
+ public function test_XMLSitemap_1()
+ {
+ $sitemap = new Sitemap();
+ $res = $sitemap->analyze(
+ '
@@ -64,21 +71,24 @@ class SitemapTest extends \PHPUnit_Framework_TestCase
0.8
',
-"http://example.com");
- $this->assertSame ($res,
- ["urls" => [
- "http://example.com/" => ["changefreq" => "daily",
+ "http://example.com"
+ );
+ $this->assertSame(
+ $res,
+ ["urls" => [
+ "http://example.com/" => ["changefreq" => "daily",
"priority" => 0.8,
"lastmod" => 1163808000]
- ],
- "sitemaps" => []]);
- }
+ ],
+ "sitemaps" => []]
+ );
+ }
- public function test_XMLSitemap_2 ()
- {
- $sitemap = new Sitemap ();
- $res = $sitemap->analyze (
-'
+ public function test_XMLSitemap_2()
+ {
+ $sitemap = new Sitemap();
+ $res = $sitemap->analyze(
+ '
http://www.example.com/sitemap1.xml.gz
@@ -89,14 +99,17 @@ class SitemapTest extends \PHPUnit_Framework_TestCase
2005-01-01
',
-"http://example.com");
- $this->assertSame ($res,
- ["urls" => [],
- "sitemaps" => [
- "http://www.example.com/sitemap1.xml.gz" => [
- "lastmod" => 1096654997,],
- "http://www.example.com/sitemap2.xml.gz" => [
- "lastmod" => 1104537600, ],
- ]]);
- }
+ "http://example.com"
+ );
+ $this->assertSame(
+ $res,
+ ["urls" => [],
+ "sitemaps" => [
+ "http://www.example.com/sitemap1.xml.gz" => [
+ "lastmod" => 1096654997,],
+ "http://www.example.com/sitemap2.xml.gz" => [
+ "lastmod" => 1104537600, ],
+ ]]
+ );
+ }
}
diff --git a/Tests/SpfcheckTest.php b/Tests/SpfcheckTest.php
index dd7910b..9d5d3c9 100644
--- a/Tests/SpfcheckTest.php
+++ b/Tests/SpfcheckTest.php
@@ -1,4 +1,5 @@
@@ -13,256 +14,302 @@ use Domframework\Spfcheck;
*/
class SpfcheckTest extends \PHPUnit_Framework_TestCase
{
- public function test_getRecords_NoSPF ()
- {
- $this->expectException ("Exception",
- "Can not find a valid SPF TXT entry in DNS for domain ".
- "'notfound.tester.fournier38.fr'", 403);
- $spfcheck = new Spfcheck ();
- $res = $spfcheck->getRecords ("notfound.tester.fournier38.fr");
- }
+ public function test_getRecords_NoSPF()
+ {
+ $this->expectException(
+ "Exception",
+ "Can not find a valid SPF TXT entry in DNS for domain " .
+ "'notfound.tester.fournier38.fr'",
+ 403
+ );
+ $spfcheck = new Spfcheck();
+ $res = $spfcheck->getRecords("notfound.tester.fournier38.fr");
+ }
- public function test_getRecords_SPFReject ()
- {
- $spfcheck = new Spfcheck ();
- $res = $spfcheck->getRecords ("reject.spf.tester.fournier38.fr");
- $this->assertSame ($res,
- array ("reject.spf.tester.fournier38.fr" =>
- array ("-all" => array ())));
- }
+ public function test_getRecords_SPFReject()
+ {
+ $spfcheck = new Spfcheck();
+ $res = $spfcheck->getRecords("reject.spf.tester.fournier38.fr");
+ $this->assertSame(
+ $res,
+ array ("reject.spf.tester.fournier38.fr" =>
+ array ("-all" => array ()))
+ );
+ }
- public function test_getRecords_Loop ()
- {
- $this->expectException ("Exception",
- "SPFCheck : Too much DNS requests (30 >= 30)", 500);
- $spfcheck = new Spfcheck ();
- $res = $spfcheck->getRecords ("loop.spf.tester.fournier38.fr");
- $this->assertSame ($res, array ());
- }
+ public function test_getRecords_Loop()
+ {
+ $this->expectException(
+ "Exception",
+ "SPFCheck : Too much DNS requests (30 >= 30)",
+ 500
+ );
+ $spfcheck = new Spfcheck();
+ $res = $spfcheck->getRecords("loop.spf.tester.fournier38.fr");
+ $this->assertSame($res, array ());
+ }
- public function test_getRecords_Include_emptyInclude ()
- {
- $spfcheck = new Spfcheck ();
- $res = $spfcheck->getRecords ("includeempty.spf.tester.fournier38.fr");
- $this->assertSame ($res,
- array ("includeempty.spf.tester.fournier38.fr" =>
- array ("include:" => array (), "-all" => array ())));
- }
+ public function test_getRecords_Include_emptyInclude()
+ {
+ $spfcheck = new Spfcheck();
+ $res = $spfcheck->getRecords("includeempty.spf.tester.fournier38.fr");
+ $this->assertSame(
+ $res,
+ array ("includeempty.spf.tester.fournier38.fr" =>
+ array ("include:" => array (), "-all" => array ()))
+ );
+ }
- public function test_getRecords_Redirect_emptyRedirect ()
- {
- $spfcheck = new Spfcheck ();
- $res = $spfcheck->getRecords ("redirectempty.spf.tester.fournier38.fr");
- $this->assertSame ($res,
- array ("redirectempty.spf.tester.fournier38.fr" =>
- array ("redirect=" => array (), "-all" => array ())));
- }
+ public function test_getRecords_Redirect_emptyRedirect()
+ {
+ $spfcheck = new Spfcheck();
+ $res = $spfcheck->getRecords("redirectempty.spf.tester.fournier38.fr");
+ $this->assertSame(
+ $res,
+ array ("redirectempty.spf.tester.fournier38.fr" =>
+ array ("redirect=" => array (), "-all" => array ()))
+ );
+ }
- public function test_getRecords_MX_emptyMX ()
- {
- $spfcheck = new Spfcheck ();
- $res = $spfcheck->getRecords ("mx.spf.tester.fournier38.fr");
- $this->assertSame ($res,
- array ("mx.spf.tester.fournier38.fr" =>
- array ("mx" => array (), "-all" => array ())));
- }
+ public function test_getRecords_MX_emptyMX()
+ {
+ $spfcheck = new Spfcheck();
+ $res = $spfcheck->getRecords("mx.spf.tester.fournier38.fr");
+ $this->assertSame(
+ $res,
+ array ("mx.spf.tester.fournier38.fr" =>
+ array ("mx" => array (), "-all" => array ()))
+ );
+ }
- public function test_getRecords_MX_validMX ()
- {
- $spfcheck = new Spfcheck ();
- $res = $spfcheck->getRecords ("mxvalid.spf.tester.fournier38.fr");
- $this->assertSame ($res,
- array ("mxvalid.spf.tester.fournier38.fr" => array (
- "mx:tester.fournier38.fr" => array (
- "2a01:e0a:2a7:9cd1::103",
- "2a01:e0a:392:ab60::206",
- "82.64.75.195",
- "82.66.67.64"),
- "-all" => array ())));
- }
+ public function test_getRecords_MX_validMX()
+ {
+ $spfcheck = new Spfcheck();
+ $res = $spfcheck->getRecords("mxvalid.spf.tester.fournier38.fr");
+ $this->assertSame(
+ $res,
+ array ("mxvalid.spf.tester.fournier38.fr" => array (
+ "mx:tester.fournier38.fr" => array (
+ "2a01:e0a:2a7:9cd1::103",
+ "2a01:e0a:392:ab60::206",
+ "82.64.75.195",
+ "82.66.67.64"),
+ "-all" => array ()))
+ );
+ }
- public function test_getRecords_A_emptyA ()
- {
- $spfcheck = new Spfcheck ();
- $res = $spfcheck->getRecords ("a.spf.tester.fournier38.fr");
- $this->assertSame ($res,
- array ("a.spf.tester.fournier38.fr" =>
- array ("a" => array (), "-all" => array ())));
- }
+ public function test_getRecords_A_emptyA()
+ {
+ $spfcheck = new Spfcheck();
+ $res = $spfcheck->getRecords("a.spf.tester.fournier38.fr");
+ $this->assertSame(
+ $res,
+ array ("a.spf.tester.fournier38.fr" =>
+ array ("a" => array (), "-all" => array ()))
+ );
+ }
- public function test_getRecords_A_validA ()
- {
- $spfcheck = new Spfcheck ();
- $res = $spfcheck->getRecords ("avalid.spf.tester.fournier38.fr");
- $this->assertSame ($res,
- array ("avalid.spf.tester.fournier38.fr" => array (
- "a:tester.fournier38.fr" => array (
- "2a01:e0a:2a7:9cd1::100",
- "82.64.75.195",),
- "-all" => array ())));
- }
+ public function test_getRecords_A_validA()
+ {
+ $spfcheck = new Spfcheck();
+ $res = $spfcheck->getRecords("avalid.spf.tester.fournier38.fr");
+ $this->assertSame(
+ $res,
+ array ("avalid.spf.tester.fournier38.fr" => array (
+ "a:tester.fournier38.fr" => array (
+ "2a01:e0a:2a7:9cd1::100",
+ "82.64.75.195",),
+ "-all" => array ()))
+ );
+ }
- public function test_getRecords_IP4_emptyIP4 ()
- {
- $spfcheck = new Spfcheck ();
- $res = $spfcheck->getRecords ("ip4empty.spf.tester.fournier38.fr");
- $this->assertSame ($res,
- array ("ip4empty.spf.tester.fournier38.fr" => array (
- "ip4:" => array (),
- "-all" => array ())));
- }
+ public function test_getRecords_IP4_emptyIP4()
+ {
+ $spfcheck = new Spfcheck();
+ $res = $spfcheck->getRecords("ip4empty.spf.tester.fournier38.fr");
+ $this->assertSame(
+ $res,
+ array ("ip4empty.spf.tester.fournier38.fr" => array (
+ "ip4:" => array (),
+ "-all" => array ()))
+ );
+ }
- public function test_getRecords_IP4_invalidIP4 ()
- {
- $spfcheck = new Spfcheck ();
- $res = $spfcheck->getRecords ("ip4invalid.spf.tester.fournier38.fr");
- $this->assertSame ($res,
- array ("ip4invalid.spf.tester.fournier38.fr" => array (
- "ip4:0::1" => array (),
- "-all" => array ())));
- }
+ public function test_getRecords_IP4_invalidIP4()
+ {
+ $spfcheck = new Spfcheck();
+ $res = $spfcheck->getRecords("ip4invalid.spf.tester.fournier38.fr");
+ $this->assertSame(
+ $res,
+ array ("ip4invalid.spf.tester.fournier38.fr" => array (
+ "ip4:0::1" => array (),
+ "-all" => array ()))
+ );
+ }
- public function test_getRecords_IP4_validIP4 ()
- {
- $spfcheck = new Spfcheck ();
- $res = $spfcheck->getRecords ("ip4valid.spf.tester.fournier38.fr");
- $this->assertSame ($res,
- array ("ip4valid.spf.tester.fournier38.fr" => array (
- "ip4:192.168.1.1" => array ("192.168.1.1"),
- "-all" => array ())));
- }
+ public function test_getRecords_IP4_validIP4()
+ {
+ $spfcheck = new Spfcheck();
+ $res = $spfcheck->getRecords("ip4valid.spf.tester.fournier38.fr");
+ $this->assertSame(
+ $res,
+ array ("ip4valid.spf.tester.fournier38.fr" => array (
+ "ip4:192.168.1.1" => array ("192.168.1.1"),
+ "-all" => array ()))
+ );
+ }
- public function test_getRecords_IP6_emptyIP6 ()
- {
- $spfcheck = new Spfcheck ();
- $res = $spfcheck->getRecords ("ip6empty.spf.tester.fournier38.fr");
- $this->assertSame ($res,
- array ("ip6empty.spf.tester.fournier38.fr" => array (
- "ip6:" => array (),
- "-all" => array ())));
- }
+ public function test_getRecords_IP6_emptyIP6()
+ {
+ $spfcheck = new Spfcheck();
+ $res = $spfcheck->getRecords("ip6empty.spf.tester.fournier38.fr");
+ $this->assertSame(
+ $res,
+ array ("ip6empty.spf.tester.fournier38.fr" => array (
+ "ip6:" => array (),
+ "-all" => array ()))
+ );
+ }
- public function test_getRecords_IP6_invalidIP6 ()
- {
- $spfcheck = new Spfcheck ();
- $res = $spfcheck->getRecords ("ip6invalid.spf.tester.fournier38.fr");
- $this->assertSame ($res,
- array ("ip6invalid.spf.tester.fournier38.fr" => array (
- "ip6:192.168.1.1" => array (),
- "-all" => array ())));
- }
+ public function test_getRecords_IP6_invalidIP6()
+ {
+ $spfcheck = new Spfcheck();
+ $res = $spfcheck->getRecords("ip6invalid.spf.tester.fournier38.fr");
+ $this->assertSame(
+ $res,
+ array ("ip6invalid.spf.tester.fournier38.fr" => array (
+ "ip6:192.168.1.1" => array (),
+ "-all" => array ()))
+ );
+ }
- public function test_getRecords_IP6_validIP6 ()
- {
- $spfcheck = new Spfcheck ();
- $res = $spfcheck->getRecords ("ip6valid.spf.tester.fournier38.fr");
- $this->assertSame ($res,
- array ("ip6valid.spf.tester.fournier38.fr" => array (
- "ip6:0::1" => array ("0::1"),
- "-all" => array ())));
- }
+ public function test_getRecords_IP6_validIP6()
+ {
+ $spfcheck = new Spfcheck();
+ $res = $spfcheck->getRecords("ip6valid.spf.tester.fournier38.fr");
+ $this->assertSame(
+ $res,
+ array ("ip6valid.spf.tester.fournier38.fr" => array (
+ "ip6:0::1" => array ("0::1"),
+ "-all" => array ()))
+ );
+ }
- public function test_getRecords_PTR ()
- {
- $spfcheck = new Spfcheck ();
- $res = $spfcheck->getRecords ("ptrvalid.spf.tester.fournier38.fr");
- $this->assertSame ($res,
- array ("ptrvalid.spf.tester.fournier38.fr" => array (
- "ptr" => array (),
- "-all" => array ())));
- }
+ public function test_getRecords_PTR()
+ {
+ $spfcheck = new Spfcheck();
+ $res = $spfcheck->getRecords("ptrvalid.spf.tester.fournier38.fr");
+ $this->assertSame(
+ $res,
+ array ("ptrvalid.spf.tester.fournier38.fr" => array (
+ "ptr" => array (),
+ "-all" => array ()))
+ );
+ }
- public function test_getRecords_All_Multiple ()
- {
- $spfcheck = new Spfcheck ();
- $res = $spfcheck->getRecords ("allmultiple.spf.tester.fournier38.fr");
- $this->assertSame ($res,
- array ("allmultiple.spf.tester.fournier38.fr" => array (
- "+all" => array (),
- "-all" => array ())));
- }
+ public function test_getRecords_All_Multiple()
+ {
+ $spfcheck = new Spfcheck();
+ $res = $spfcheck->getRecords("allmultiple.spf.tester.fournier38.fr");
+ $this->assertSame(
+ $res,
+ array ("allmultiple.spf.tester.fournier38.fr" => array (
+ "+all" => array (),
+ "-all" => array ()))
+ );
+ }
- public function test_getRecords_All_NotEnd ()
- {
- $spfcheck = new Spfcheck ();
- $res = $spfcheck->getRecords ("allnotend.spf.tester.fournier38.fr");
- $this->assertSame ($res,
- array ("allnotend.spf.tester.fournier38.fr" => array (
- "+all" => array (),
- "mx" => array ())));
- }
+ public function test_getRecords_All_NotEnd()
+ {
+ $spfcheck = new Spfcheck();
+ $res = $spfcheck->getRecords("allnotend.spf.tester.fournier38.fr");
+ $this->assertSame(
+ $res,
+ array ("allnotend.spf.tester.fournier38.fr" => array (
+ "+all" => array (),
+ "mx" => array ()))
+ );
+ }
- public function test_getRecords_All_NotSet ()
- {
- $spfcheck = new Spfcheck ();
- $res = $spfcheck->getRecords ("allnotset.spf.tester.fournier38.fr");
- $this->assertSame ($res,
- array ("allnotset.spf.tester.fournier38.fr" => array (
- "mx" => array ())));
- }
+ public function test_getRecords_All_NotSet()
+ {
+ $spfcheck = new Spfcheck();
+ $res = $spfcheck->getRecords("allnotset.spf.tester.fournier38.fr");
+ $this->assertSame(
+ $res,
+ array ("allnotset.spf.tester.fournier38.fr" => array (
+ "mx" => array ()))
+ );
+ }
- public function test_wideIPRange ()
- {
- $spfcheck = new Spfcheck ();
- $spfcheck->getRecords ("wide.spf.tester.fournier38.fr");
- $res = $spfcheck->getErrors ();
- $this->assertSame ($res,
- array ("wide.spf.tester.fournier38.fr" => array (
- "ip4:213.131.32.0/2" => "Invalid ip4 set for domain 'wide.spf.tester.fournier38.fr' : Mask '/2' too wide",
- "ip6:2001::/20" => "Invalid ip6 set for domain 'wide.spf.tester.fournier38.fr' : Mask '/20' too wide"
- )));
- }
+ public function test_wideIPRange()
+ {
+ $spfcheck = new Spfcheck();
+ $spfcheck->getRecords("wide.spf.tester.fournier38.fr");
+ $res = $spfcheck->getErrors();
+ $this->assertSame(
+ $res,
+ array ("wide.spf.tester.fournier38.fr" => array (
+ "ip4:213.131.32.0/2" => "Invalid ip4 set for domain 'wide.spf.tester.fournier38.fr' : Mask '/2' too wide",
+ "ip6:2001::/20" => "Invalid ip6 set for domain 'wide.spf.tester.fournier38.fr' : Mask '/20' too wide"
+ ))
+ );
+ }
- public function test_recordsWithPlus ()
- {
- $spfcheck = new Spfcheck ();
- $res = $spfcheck->getRecords ("plus.spf.tester.fournier38.fr");
- $this->assertSame ($res,
- array ("plus.spf.tester.fournier38.fr" => array (
- "+a" => array (),
- "+mx" => array (),
- "+ip4:178.33.236.5" => array ("178.33.236.5"),
- "-ip4:137.74.69.64" => array ("137.74.69.64"),
- "+ip4:51.254.45.81" => array ("51.254.45.81"),
- "-all" => array (),
- )));
- }
+ public function test_recordsWithPlus()
+ {
+ $spfcheck = new Spfcheck();
+ $res = $spfcheck->getRecords("plus.spf.tester.fournier38.fr");
+ $this->assertSame(
+ $res,
+ array ("plus.spf.tester.fournier38.fr" => array (
+ "+a" => array (),
+ "+mx" => array (),
+ "+ip4:178.33.236.5" => array ("178.33.236.5"),
+ "-ip4:137.74.69.64" => array ("137.74.69.64"),
+ "+ip4:51.254.45.81" => array ("51.254.45.81"),
+ "-all" => array (),
+ ))
+ );
+ }
- public function test_getRecords_Unknown ()
- {
- $spfcheck = new Spfcheck ();
- $res = $spfcheck->getRecords ("unknown.spf.tester.fournier38.fr");
- $this->assertSame ($res,
- array ("unknown.spf.tester.fournier38.fr" => array (
- "unknown" => array (),
- "-all" => array ())));
- }
+ public function test_getRecords_Unknown()
+ {
+ $spfcheck = new Spfcheck();
+ $res = $spfcheck->getRecords("unknown.spf.tester.fournier38.fr");
+ $this->assertSame(
+ $res,
+ array ("unknown.spf.tester.fournier38.fr" => array (
+ "unknown" => array (),
+ "-all" => array ()))
+ );
+ }
- public function test_ipCheckToSPF_OK_inA ()
- {
- $spfcheck = new Spfcheck ();
- $res = $spfcheck->ipCheckToSPF ("plus.spf.tester.fournier38.fr", "178.33.236.5");
- $this->assertSame ($res, "PASS");
- }
+ public function test_ipCheckToSPF_OK_inA()
+ {
+ $spfcheck = new Spfcheck();
+ $res = $spfcheck->ipCheckToSPF("plus.spf.tester.fournier38.fr", "178.33.236.5");
+ $this->assertSame($res, "PASS");
+ }
- public function test_ipCheckToSPF_FAIL_inALL ()
- {
- $spfcheck = new Spfcheck ();
- $res = $spfcheck->ipCheckToSPF ("plus.spf.tester.fournier38.fr", "1.3.6.5");
- $this->assertSame ($res, "FAIL");
- }
+ public function test_ipCheckToSPF_FAIL_inALL()
+ {
+ $spfcheck = new Spfcheck();
+ $res = $spfcheck->ipCheckToSPF("plus.spf.tester.fournier38.fr", "1.3.6.5");
+ $this->assertSame($res, "FAIL");
+ }
- public function test_ipCheckToSPF_OK_inALL ()
- {
- $spfcheck = new Spfcheck ();
- $res = $spfcheck->ipCheckToSPF ("plus.spf.tester.fournier38.fr", "1.3.6.5");
- $this->assertSame ($res, "FAIL");
- }
+ public function test_ipCheckToSPF_OK_inALL()
+ {
+ $spfcheck = new Spfcheck();
+ $res = $spfcheck->ipCheckToSPF("plus.spf.tester.fournier38.fr", "1.3.6.5");
+ $this->assertSame($res, "FAIL");
+ }
- public function test_ipCheckToSPF_FAIL_inIP4 ()
- {
- $spfcheck = new Spfcheck ();
- $res = $spfcheck->ipCheckToSPF ("plus.spf.tester.fournier38.fr", "137.74.69.64");
- $this->assertSame ($res, "FAIL");
- }
+ public function test_ipCheckToSPF_FAIL_inIP4()
+ {
+ $spfcheck = new Spfcheck();
+ $res = $spfcheck->ipCheckToSPF("plus.spf.tester.fournier38.fr", "137.74.69.64");
+ $this->assertSame($res, "FAIL");
+ }
}
diff --git a/Tests/SseTest.php b/Tests/SseTest.php
index 373a074..03da606 100644
--- a/Tests/SseTest.php
+++ b/Tests/SseTest.php
@@ -1,4 +1,5 @@
@@ -12,143 +13,156 @@ use Domframework\Sse;
/** Test the domframework Server-Sent Events part */
class SseTest extends \PHPUnit_Framework_TestCase
{
- public function test_loop_NOTDEFINED ()
- {
- $this->expectException ("Exception");
- $sse = new Sse ();
- $res = $sse->loop ();
- }
+ public function test_loop_NOTDEFINED()
+ {
+ $this->expectException("Exception");
+ $sse = new Sse();
+ $res = $sse->loop();
+ }
- public function test_loop_JUSTPING ()
- {
- $this->expectOutputString(str_repeat (": ping\n\n", 5));
- $sse = new Sse ();
- if (file_exists ("/tmp/dfwTestSSE1"))
- unlink ("/tmp/dfwTestSSE1");
- $sse->setBackendFiles ("/tmp/dfwTestSSE1")
+ public function test_loop_JUSTPING()
+ {
+ $this->expectOutputString(str_repeat(": ping\n\n", 5));
+ $sse = new Sse();
+ if (file_exists("/tmp/dfwTestSSE1")) {
+ unlink("/tmp/dfwTestSSE1");
+ }
+ $sse->setBackendFiles("/tmp/dfwTestSSE1")
->setPingTime(1);
- $sse->loop ();
- }
+ $sse->loop();
+ }
- public function test_loop_SKIP_START ()
- {
- $this->expectOutputString(str_repeat (": ping\n\n", 5));
- $sse = new Sse ();
- if (file_exists ("/tmp/dfwTestSSE1"))
- unlink ("/tmp/dfwTestSSE1");
- file_put_contents ("/tmp/dfwTestSSE1", "NOT SEEN");
- $sse->setBackendFiles ("/tmp/dfwTestSSE1")
+ public function test_loop_SKIP_START()
+ {
+ $this->expectOutputString(str_repeat(": ping\n\n", 5));
+ $sse = new Sse();
+ if (file_exists("/tmp/dfwTestSSE1")) {
+ unlink("/tmp/dfwTestSSE1");
+ }
+ file_put_contents("/tmp/dfwTestSSE1", "NOT SEEN");
+ $sse->setBackendFiles("/tmp/dfwTestSSE1")
->setPingTime(1);
- $sse->loop ();
- }
+ $sse->loop();
+ }
- public function test_loop_DATA ()
- {
- $this->expectOutputString(str_repeat (": ping\n\n", 4).
- "data: WILL BE SEEN\n\n: ping\n\n");
- if (file_exists ("/tmp/dfwTestSSE1"))
- unlink ("/tmp/dfwTestSSE1");
- $sse = new Sse ();
- pcntl_signal(SIGALRM, function () {
- file_put_contents ("/tmp/dfwTestSSE1", "WILL BE SEEN\n");
- }, false);
- pcntl_alarm(3);
- $sse->setBackendFiles ("/tmp/dfwTestSSE1")
+ public function test_loop_DATA()
+ {
+ $this->expectOutputString(str_repeat(": ping\n\n", 4) .
+ "data: WILL BE SEEN\n\n: ping\n\n");
+ if (file_exists("/tmp/dfwTestSSE1")) {
+ unlink("/tmp/dfwTestSSE1");
+ }
+ $sse = new Sse();
+ pcntl_signal(SIGALRM, function () {
+ file_put_contents("/tmp/dfwTestSSE1", "WILL BE SEEN\n");
+ }, false);
+ pcntl_alarm(3);
+ $sse->setBackendFiles("/tmp/dfwTestSSE1")
->setPingTime(1);
- $sse->loop ();
- }
+ $sse->loop();
+ }
- public function test_loop_EVENTS ()
- {
- $this->expectOutputString(str_repeat (": ping\n\n", 4).
- "event: event1\ndata: WILL BE SEEN 1\n\n".
- "event: event2\ndata: WILL BE SEEN 2\n\n".
- ": ping\n\n");
- if (file_exists ("/tmp/dfwTestSSE1"))
- unlink ("/tmp/dfwTestSSE1");
- if (file_exists ("/tmp/dfwTestSSE2"))
- unlink ("/tmp/dfwTestSSE2");
- $sse = new Sse ();
- pcntl_signal(SIGALRM, function () {
- file_put_contents ("/tmp/dfwTestSSE1", "WILL BE SEEN 1\n");
- file_put_contents ("/tmp/dfwTestSSE2", "WILL BE SEEN 2\n");
- }, false);
- pcntl_alarm(3);
- $sse->setBackendFiles (["event1" => "/tmp/dfwTestSSE1",
+ public function test_loop_EVENTS()
+ {
+ $this->expectOutputString(str_repeat(": ping\n\n", 4) .
+ "event: event1\ndata: WILL BE SEEN 1\n\n" .
+ "event: event2\ndata: WILL BE SEEN 2\n\n" .
+ ": ping\n\n");
+ if (file_exists("/tmp/dfwTestSSE1")) {
+ unlink("/tmp/dfwTestSSE1");
+ }
+ if (file_exists("/tmp/dfwTestSSE2")) {
+ unlink("/tmp/dfwTestSSE2");
+ }
+ $sse = new Sse();
+ pcntl_signal(SIGALRM, function () {
+ file_put_contents("/tmp/dfwTestSSE1", "WILL BE SEEN 1\n");
+ file_put_contents("/tmp/dfwTestSSE2", "WILL BE SEEN 2\n");
+ }, false);
+ pcntl_alarm(3);
+ $sse->setBackendFiles(["event1" => "/tmp/dfwTestSSE1",
"event2" => "/tmp/dfwTestSSE2"])
->setPingTime(1);
- $sse->loop ();
- }
-
- public function test_loop_HandlersEvent ()
- {
- $this->expectOutputString(str_repeat (": ping\n\n", 4).
- "event: event1\ndata: will be seen 1\n\n".
- "event: event2\ndata: WILL BE SEEN 2\n\n".
- ": ping\n\n");
- if (file_exists ("/tmp/dfwTestSSE1"))
- unlink ("/tmp/dfwTestSSE1");
- if (file_exists ("/tmp/dfwTestSSE2"))
- unlink ("/tmp/dfwTestSSE2");
- $sse = new Sse ();
- pcntl_signal(SIGALRM, function () {
- file_put_contents ("/tmp/dfwTestSSE1", "WILL BE SEEN 1\n");
- file_put_contents ("/tmp/dfwTestSSE2", "WILL BE SEEN 2\n");
- }, false);
- pcntl_alarm(3);
- function lowerHandlersEvent ($val) {
- return strtolower ($val);
+ $sse->loop();
}
- $sse->setBackendFiles (["event1" => "/tmp/dfwTestSSE1",
+
+ public function test_loop_HandlersEvent()
+ {
+ $this->expectOutputString(str_repeat(": ping\n\n", 4) .
+ "event: event1\ndata: will be seen 1\n\n" .
+ "event: event2\ndata: WILL BE SEEN 2\n\n" .
+ ": ping\n\n");
+ if (file_exists("/tmp/dfwTestSSE1")) {
+ unlink("/tmp/dfwTestSSE1");
+ }
+ if (file_exists("/tmp/dfwTestSSE2")) {
+ unlink("/tmp/dfwTestSSE2");
+ }
+ $sse = new Sse();
+ pcntl_signal(SIGALRM, function () {
+ file_put_contents("/tmp/dfwTestSSE1", "WILL BE SEEN 1\n");
+ file_put_contents("/tmp/dfwTestSSE2", "WILL BE SEEN 2\n");
+ }, false);
+ pcntl_alarm(3);
+ function lowerHandlersEvent($val)
+ {
+ return strtolower($val);
+ }
+ $sse->setBackendFiles(["event1" => "/tmp/dfwTestSSE1",
"event2" => "/tmp/dfwTestSSE2"])
- ->setHandlersEvent ([
- "event1" => __NAMESPACE__."\\lowerHandlersEvent"])
+ ->setHandlersEvent([
+ "event1" => __NAMESPACE__ . "\\lowerHandlersEvent"])
->setPingTime(1);
- $sse->loop ();
- }
-
- public function test_loop_HandlerDataonly ()
- {
- $this->expectOutputString(str_repeat (": ping\n\n", 4).
- "data: will be seen 1\n\n".
- ": ping\n\n");
- if (file_exists ("/tmp/dfwTestSSE1"))
- unlink ("/tmp/dfwTestSSE1");
- $sse = new Sse ();
- pcntl_signal(SIGALRM, function () {
- file_put_contents ("/tmp/dfwTestSSE1", "WILL BE SEEN 1\n");
- }, false);
- pcntl_alarm(3);
- function lowerHandlerDataonly ($val) {
- return strtolower ($val);
+ $sse->loop();
}
- $sse->setBackendFiles ("/tmp/dfwTestSSE1")
- ->setHandlerDataonly (__NAMESPACE__."\\lowerHandlerDataonly")
- ->setPingTime(1);
- $sse->loop ();
- }
- public function test_loop_HandlerDataonlyWithParams ()
- {
- $this->expectOutputString(str_repeat (": ping\n\n", 4).
- "data: PREwill be seen 1POST\n\n".
- ": ping\n\n");
- if (file_exists ("/tmp/dfwTestSSE1"))
- unlink ("/tmp/dfwTestSSE1");
- $sse = new Sse ();
- pcntl_signal(SIGALRM, function () {
- file_put_contents ("/tmp/dfwTestSSE1", "WILL BE SEEN 1\n");
- }, false);
- pcntl_alarm(3);
- function lowerHandlerDataonlyWithParams ($val, $param1, $param2) {
- return $param1.strtolower ($val).$param2;
- }
- $sse->setBackendFiles ("/tmp/dfwTestSSE1")
- ->setHandlerDataonly (
- __NAMESPACE__."\\lowerHandlerDataonlyWithParams", "PRE", "POST")
+ public function test_loop_HandlerDataonly()
+ {
+ $this->expectOutputString(str_repeat(": ping\n\n", 4) .
+ "data: will be seen 1\n\n" .
+ ": ping\n\n");
+ if (file_exists("/tmp/dfwTestSSE1")) {
+ unlink("/tmp/dfwTestSSE1");
+ }
+ $sse = new Sse();
+ pcntl_signal(SIGALRM, function () {
+ file_put_contents("/tmp/dfwTestSSE1", "WILL BE SEEN 1\n");
+ }, false);
+ pcntl_alarm(3);
+ function lowerHandlerDataonly($val)
+ {
+ return strtolower($val);
+ }
+ $sse->setBackendFiles("/tmp/dfwTestSSE1")
+ ->setHandlerDataonly(__NAMESPACE__ . "\\lowerHandlerDataonly")
->setPingTime(1);
- $sse->loop ();
- }
+ $sse->loop();
+ }
+
+ public function test_loop_HandlerDataonlyWithParams()
+ {
+ $this->expectOutputString(str_repeat(": ping\n\n", 4) .
+ "data: PREwill be seen 1POST\n\n" .
+ ": ping\n\n");
+ if (file_exists("/tmp/dfwTestSSE1")) {
+ unlink("/tmp/dfwTestSSE1");
+ }
+ $sse = new Sse();
+ pcntl_signal(SIGALRM, function () {
+ file_put_contents("/tmp/dfwTestSSE1", "WILL BE SEEN 1\n");
+ }, false);
+ pcntl_alarm(3);
+ function lowerHandlerDataonlyWithParams($val, $param1, $param2)
+ {
+ return $param1 . strtolower($val) . $param2;
+ }
+ $sse->setBackendFiles("/tmp/dfwTestSSE1")
+ ->setHandlerDataonly(
+ __NAMESPACE__ . "\\lowerHandlerDataonlyWithParams",
+ "PRE",
+ "POST"
+ )
+ ->setPingTime(1);
+ $sse->loop();
+ }
}
-
-
diff --git a/Tests/TcpclientTest.php b/Tests/TcpclientTest.php
index 5048cdb..12607f8 100644
--- a/Tests/TcpclientTest.php
+++ b/Tests/TcpclientTest.php
@@ -1,4 +1,5 @@
@@ -10,72 +11,76 @@ namespace Domframework\Tests;
use Domframework\Tcpclient;
/** Test the TCP client */
-class TcpclientTest extends \PHPUnit_Framework_TestCase
+class TcpclientTest extends \PHPUnit_Framework_TestCase
{
- public function test_GoogleIPv4 ()
- {
- $tcpclient = new Tcpclient ("www.google.fr", 80);
- $tcpclient->preferIPv4 (true);
- $tcpclient->connect ();
- $tcpclient->send ("GET / HTTP/1.1\r\n".
- "Host: www.google.fr\r\n".
- "User-Agent: DomFramework\r\n".
- "Accept: *"."/*\r\n".
- "\r\n");
- $res = "";
- while (($read = $tcpclient->read ()) !== "")
- $res .= $read."\r\n";
- $tcpclient->disconnect ();
- $this->assertSame (substr ($res, 0, 15), "HTTP/1.1 200 OK");
- }
+ public function test_GoogleIPv4()
+ {
+ $tcpclient = new Tcpclient("www.google.fr", 80);
+ $tcpclient->preferIPv4(true);
+ $tcpclient->connect();
+ $tcpclient->send("GET / HTTP/1.1\r\n" .
+ "Host: www.google.fr\r\n" .
+ "User-Agent: DomFramework\r\n" .
+ "Accept: *" . "/*\r\n" .
+ "\r\n");
+ $res = "";
+ while (($read = $tcpclient->read()) !== "") {
+ $res .= $read . "\r\n";
+ }
+ $tcpclient->disconnect();
+ $this->assertSame(substr($res, 0, 15), "HTTP/1.1 200 OK");
+ }
- public function test_GoogleIPv4orIpv6 ()
- {
- $tcpclient = new Tcpclient ("www.google.fr", 80);
- $tcpclient->connect ();
- $tcpclient->send ("GET / HTTP/1.1\r\n".
- "Host: www.google.fr\r\n".
- "User-Agent: DomFramework\r\n".
- "Accept: *"."/*\r\n".
- "\r\n");
- $res = "";
- while (($read = $tcpclient->read ()) !== "")
- $res .= $read."\r\n";
- $tcpclient->disconnect ();
- $this->assertSame (substr ($res, 0, 15), "HTTP/1.1 200 OK");
- }
+ public function test_GoogleIPv4orIpv6()
+ {
+ $tcpclient = new Tcpclient("www.google.fr", 80);
+ $tcpclient->connect();
+ $tcpclient->send("GET / HTTP/1.1\r\n" .
+ "Host: www.google.fr\r\n" .
+ "User-Agent: DomFramework\r\n" .
+ "Accept: *" . "/*\r\n" .
+ "\r\n");
+ $res = "";
+ while (($read = $tcpclient->read()) !== "") {
+ $res .= $read . "\r\n";
+ }
+ $tcpclient->disconnect();
+ $this->assertSame(substr($res, 0, 15), "HTTP/1.1 200 OK");
+ }
- public function test_GoogleSSL ()
- {
- $tcpclient = new Tcpclient ("www.google.fr", 443);
- $tcpclient->connect ();
- $tcpclient->cryptoEnable (true);
- $tcpclient->send ("GET / HTTP/1.1\r\n".
- "Host: www.google.fr\r\n".
- "User-Agent: DomFramework\r\n".
- "Accept: *"."/*\r\n".
- "\r\n");
- $res = "";
- while (($read = $tcpclient->read ()) !== "")
- $res .= $read."\r\n";
- $tcpclient->disconnect ();
- $this->assertSame (substr ($res, 0, 15), "HTTP/1.1 200 OK");
- }
+ public function test_GoogleSSL()
+ {
+ $tcpclient = new Tcpclient("www.google.fr", 443);
+ $tcpclient->connect();
+ $tcpclient->cryptoEnable(true);
+ $tcpclient->send("GET / HTTP/1.1\r\n" .
+ "Host: www.google.fr\r\n" .
+ "User-Agent: DomFramework\r\n" .
+ "Accept: *" . "/*\r\n" .
+ "\r\n");
+ $res = "";
+ while (($read = $tcpclient->read()) !== "") {
+ $res .= $read . "\r\n";
+ }
+ $tcpclient->disconnect();
+ $this->assertSame(substr($res, 0, 15), "HTTP/1.1 200 OK");
+ }
- public function test_GoogleSSLIPv6 ()
- {
- $tcpclient = new Tcpclient ("ipv6.google.com", 443);
- $tcpclient->connect ();
- $tcpclient->cryptoEnable (true);
- $tcpclient->send ("GET / HTTP/1.1\r\n".
- "Host: www.google.fr\r\n".
- "User-Agent: DomFramework\r\n".
- "Accept: *"."/*\r\n".
- "\r\n");
- $res = "";
- while (($read = $tcpclient->read ()) !== "")
- $res .= $read."\r\n";
- $tcpclient->disconnect ();
- $this->assertSame (substr ($res, 0, 15), "HTTP/1.1 200 OK");
- }
+ public function test_GoogleSSLIPv6()
+ {
+ $tcpclient = new Tcpclient("ipv6.google.com", 443);
+ $tcpclient->connect();
+ $tcpclient->cryptoEnable(true);
+ $tcpclient->send("GET / HTTP/1.1\r\n" .
+ "Host: www.google.fr\r\n" .
+ "User-Agent: DomFramework\r\n" .
+ "Accept: *" . "/*\r\n" .
+ "\r\n");
+ $res = "";
+ while (($read = $tcpclient->read()) !== "") {
+ $res .= $read . "\r\n";
+ }
+ $tcpclient->disconnect();
+ $this->assertSame(substr($res, 0, 15), "HTTP/1.1 200 OK");
+ }
}
diff --git a/Tests/UserssqlTest.php b/Tests/UserssqlTest.php
index 6999089..d11c19a 100644
--- a/Tests/UserssqlTest.php
+++ b/Tests/UserssqlTest.php
@@ -1,4 +1,5 @@
@@ -12,118 +13,122 @@ use Domframework\Userssql;
/** Test the Userssql.php file */
class UserssqlTest extends \PHPUnit_Framework_TestCase
{
- public function test_clean ()
- {
- @unlink ("/tmp/database.db");
- }
+ public function test_clean()
+ {
+ @unlink("/tmp/database.db");
+ }
- public function test_initStorage ()
- {
- $userssql = new Userssql ("sqlite:///tmp/database.db");
- $res = $userssql->initStorage ();
- $this->assertSame ($res, 0);
- }
+ public function test_initStorage()
+ {
+ $userssql = new Userssql("sqlite:///tmp/database.db");
+ $res = $userssql->initStorage();
+ $this->assertSame($res, 0);
+ }
- public function test_listusers1 ()
- {
- $userssql = new Userssql ("sqlite:///tmp/database.db");
- $res = $userssql->listusers ();
- $this->assertSame ($res, array ());
- }
+ public function test_listusers1()
+ {
+ $userssql = new Userssql("sqlite:///tmp/database.db");
+ $res = $userssql->listusers();
+ $this->assertSame($res, array ());
+ }
- public function test_adduser1 ()
- {
- $userssql = new Userssql ("sqlite:///tmp/database.db");
- $res = $userssql->adduser ("toto@toto.com", "Toto", "Toto2");
- $this->assertSame ($res, "toto@toto.com");
- }
+ public function test_adduser1()
+ {
+ $userssql = new Userssql("sqlite:///tmp/database.db");
+ $res = $userssql->adduser("toto@toto.com", "Toto", "Toto2");
+ $this->assertSame($res, "toto@toto.com");
+ }
- public function test_listusers2 ()
- {
- $userssql = new Userssql ("sqlite:///tmp/database.db");
- $res = $userssql->listusers ();
- $this->assertSame ($res, array (array ("email"=>"toto@toto.com",
- "firstname"=>"Toto",
- "lastname"=>"Toto2")));
- }
+ public function test_listusers2()
+ {
+ $userssql = new Userssql("sqlite:///tmp/database.db");
+ $res = $userssql->listusers();
+ $this->assertSame($res, array (array ("email" => "toto@toto.com",
+ "firstname" => "Toto",
+ "lastname" => "Toto2")));
+ }
- public function test_overwritepassword1 ()
- {
- $userssql = new Userssql ("sqlite:///tmp/database.db");
- $res = $userssql->overwritepassword ("toto@toto.com", "PassW0rd");
- $this->assertSame ($res, 1);
- }
+ public function test_overwritepassword1()
+ {
+ $userssql = new Userssql("sqlite:///tmp/database.db");
+ $res = $userssql->overwritepassword("toto@toto.com", "PassW0rd");
+ $this->assertSame($res, 1);
+ }
- public function test_checkValidPassword1 ()
- {
- $userssql = new Userssql ("sqlite:///tmp/database.db");
- $res = $userssql->checkValidPassword ("toto@toto.com", "PassW0rd");
- $this->assertSame ($res, true);
- }
+ public function test_checkValidPassword1()
+ {
+ $userssql = new Userssql("sqlite:///tmp/database.db");
+ $res = $userssql->checkValidPassword("toto@toto.com", "PassW0rd");
+ $this->assertSame($res, true);
+ }
- public function test_checkValidPassword2 ()
- {
- $userssql = new Userssql ("sqlite:///tmp/database.db");
- $res = $userssql->checkValidPassword ("toto@toto.com", "BAD PASSWD");
- $this->assertSame ($res, false);
- }
+ public function test_checkValidPassword2()
+ {
+ $userssql = new Userssql("sqlite:///tmp/database.db");
+ $res = $userssql->checkValidPassword("toto@toto.com", "BAD PASSWD");
+ $this->assertSame($res, false);
+ }
- public function test_changepassword1 ()
- {
- $userssql = new Userssql ("sqlite:///tmp/database.db");
- $res = $userssql->changepassword ("toto@toto.com", "PassW0rd", "NEW PASS!");
- $this->assertSame ($res, 1);
- }
+ public function test_changepassword1()
+ {
+ $userssql = new Userssql("sqlite:///tmp/database.db");
+ $res = $userssql->changepassword("toto@toto.com", "PassW0rd", "NEW PASS!");
+ $this->assertSame($res, 1);
+ }
- public function test_checkValidPassword3 ()
- {
- $userssql = new Userssql ("sqlite:///tmp/database.db");
- $res = $userssql->checkValidPassword ("toto@toto.com", "PassW0rd");
- $this->assertSame ($res, false);
- }
+ public function test_checkValidPassword3()
+ {
+ $userssql = new Userssql("sqlite:///tmp/database.db");
+ $res = $userssql->checkValidPassword("toto@toto.com", "PassW0rd");
+ $this->assertSame($res, false);
+ }
- public function test_checkValidPassword4 ()
- {
- $userssql = new Userssql ("sqlite:///tmp/database.db");
- $res = $userssql->checkValidPassword ("toto@toto.com", "NEW PASS!");
- $this->assertSame ($res, true);
- }
+ public function test_checkValidPassword4()
+ {
+ $userssql = new Userssql("sqlite:///tmp/database.db");
+ $res = $userssql->checkValidPassword("toto@toto.com", "NEW PASS!");
+ $this->assertSame($res, true);
+ }
- public function test_updateuser ()
- {
- $userssql = new Userssql ("sqlite:///tmp/database.db");
- $res = $userssql->updateuser ("toto@toto.com", "titi@titi.com", "titi",
- "titi2");
- $this->assertSame ($res, 1);
- }
+ public function test_updateuser()
+ {
+ $userssql = new Userssql("sqlite:///tmp/database.db");
+ $res = $userssql->updateuser(
+ "toto@toto.com",
+ "titi@titi.com",
+ "titi",
+ "titi2"
+ );
+ $this->assertSame($res, 1);
+ }
- public function test_listusers3 ()
- {
- $userssql = new Userssql ("sqlite:///tmp/database.db");
- $res = $userssql->listusers ();
- $this->assertSame ($res, array (array ("email"=>"titi@titi.com",
- "firstname"=>"titi",
- "lastname"=>"titi2")));
- }
+ public function test_listusers3()
+ {
+ $userssql = new Userssql("sqlite:///tmp/database.db");
+ $res = $userssql->listusers();
+ $this->assertSame($res, array (array ("email" => "titi@titi.com",
+ "firstname" => "titi",
+ "lastname" => "titi2")));
+ }
- public function test_checkValidPassword5 ()
- {
- $userssql = new Userssql ("sqlite:///tmp/database.db");
- $res = $userssql->checkValidPassword ("titi@titi.com", "NEW PASS!");
- $this->assertSame ($res, true);
- }
+ public function test_checkValidPassword5()
+ {
+ $userssql = new Userssql("sqlite:///tmp/database.db");
+ $res = $userssql->checkValidPassword("titi@titi.com", "NEW PASS!");
+ $this->assertSame($res, true);
+ }
- public function test_deluser ()
- {
- $userssql = new Userssql ("sqlite:///tmp/database.db");
- $res = $userssql->deluser ("titi@titi.com");
- $this->assertSame ($res, 1);
- }
+ public function test_deluser()
+ {
+ $userssql = new Userssql("sqlite:///tmp/database.db");
+ $res = $userssql->deluser("titi@titi.com");
+ $this->assertSame($res, 1);
+ }
- public function test_listusers4 ()
- {
- $userssql = new Userssql ("sqlite:///tmp/database.db");
- $res = $userssql->listusers ();
- $this->assertSame ($res, array ());
- }
+ public function test_listusers4()
+ {
+ $userssql = new Userssql("sqlite:///tmp/database.db");
+ $res = $userssql->listusers();
+ $this->assertSame($res, array ());
+ }
}
diff --git a/Tests/UuidTest.php b/Tests/UuidTest.php
index 1924fbe..4ac25b7 100644
--- a/Tests/UuidTest.php
+++ b/Tests/UuidTest.php
@@ -1,4 +1,5 @@
@@ -12,16 +13,16 @@ use Domframework\Uuid;
/** Test the Uuid.php file */
class UuidTest extends \PHPUnit_Framework_TestCase
{
- public function test_uuid1 ()
- {
- $res = Uuid::uuid4 ();
- $this->assertRegExp (36, strlen ($res));
- }
+ public function test_uuid1()
+ {
+ $res = Uuid::uuid4();
+ $this->assertRegExp(36, strlen($res));
+ }
- public function test_uuid2 ()
- {
- $res = Uuid::uuid4 ();
- $this->assertRegExp (true, strspn ("0123456789abcdef-", $res) ==
- strlen ($res));
- }
+ public function test_uuid2()
+ {
+ $res = Uuid::uuid4();
+ $this->assertRegExp(true, strspn("0123456789abcdef-", $res) ==
+ strlen($res));
+ }
}
diff --git a/Tests/VerifyTest.php b/Tests/VerifyTest.php
index f228823..2930ee7 100644
--- a/Tests/VerifyTest.php
+++ b/Tests/VerifyTest.php
@@ -1,4 +1,5 @@
@@ -15,99 +16,99 @@ class VerifyTest extends \PHPUnit_Framework_TestCase
///////////////
// DATES //
///////////////
- public function test_is_datetimeSQL1 ()
- {
- $verify = new Verify ();
- $res = $verify->is_datetimeSQL ("2017-04-13 22:55:17");
- $this->assertSame ($res, true);
- }
+ public function test_is_datetimeSQL1()
+ {
+ $verify = new Verify();
+ $res = $verify->is_datetimeSQL("2017-04-13 22:55:17");
+ $this->assertSame($res, true);
+ }
- public function test_is_datetimeSQL2 ()
- {
- $verify = new Verify ();
- $res = $verify->is_datetimeSQL ("2017-13-55 22:55:17");
- $this->assertSame ($res, false);
- }
+ public function test_is_datetimeSQL2()
+ {
+ $verify = new Verify();
+ $res = $verify->is_datetimeSQL("2017-13-55 22:55:17");
+ $this->assertSame($res, false);
+ }
- public function test_staticIs_datetimeSQL1 ()
- {
- $res = Verify::staticIs_datetimeSQL ("2017-04-13 22:55:17");
- $this->assertSame ($res, true);
- }
+ public function test_staticIs_datetimeSQL1()
+ {
+ $res = Verify::staticIs_datetimeSQL("2017-04-13 22:55:17");
+ $this->assertSame($res, true);
+ }
- public function test_staticIs_datetimeSQL2 ()
- {
- $res = Verify::staticIs_datetimeSQL ("2017-13-55 22:55:17");
- $this->assertSame ($res, false);
- }
- public function test_is_dateSQL1 ()
- {
- $verify = new Verify ();
- $res = $verify->is_dateSQL ("2017-04-13");
- $this->assertSame ($res, true);
- }
+ public function test_staticIs_datetimeSQL2()
+ {
+ $res = Verify::staticIs_datetimeSQL("2017-13-55 22:55:17");
+ $this->assertSame($res, false);
+ }
+ public function test_is_dateSQL1()
+ {
+ $verify = new Verify();
+ $res = $verify->is_dateSQL("2017-04-13");
+ $this->assertSame($res, true);
+ }
- public function test_is_dateSQL2 ()
- {
- $verify = new Verify ();
- $res = $verify->is_dateSQL ("2017-13-55");
- $this->assertSame ($res, false);
- }
+ public function test_is_dateSQL2()
+ {
+ $verify = new Verify();
+ $res = $verify->is_dateSQL("2017-13-55");
+ $this->assertSame($res, false);
+ }
- public function test_staticIs_dateSQL1 ()
- {
- $res = Verify::staticIs_dateSQL ("2017-04-13");
- $this->assertSame ($res, true);
- }
+ public function test_staticIs_dateSQL1()
+ {
+ $res = Verify::staticIs_dateSQL("2017-04-13");
+ $this->assertSame($res, true);
+ }
- public function test_staticIs_dateSQL2 ()
- {
- $res = Verify::staticIs_dateSQL ("2017-13-55");
- $this->assertSame ($res, false);
- }
+ public function test_staticIs_dateSQL2()
+ {
+ $res = Verify::staticIs_dateSQL("2017-13-55");
+ $this->assertSame($res, false);
+ }
/////////////////
// STRINGS //
/////////////////
- public function test_staticIsAllowedChars_1 ()
- {
- $res = Verify::staticIsAllowedChars ("éléphant", "abcd");
- $this->assertSame ($res, false);
- }
+ public function test_staticIsAllowedChars_1()
+ {
+ $res = Verify::staticIsAllowedChars("éléphant", "abcd");
+ $this->assertSame($res, false);
+ }
- public function test_staticIsAllowedChars_2 ()
- {
- $res = Verify::staticIsAllowedChars ("éléphant", "anhplté");
- $this->assertSame ($res, true);
- }
+ public function test_staticIsAllowedChars_2()
+ {
+ $res = Verify::staticIsAllowedChars("éléphant", "anhplté");
+ $this->assertSame($res, true);
+ }
/////////////////
// NUMBERS //
/////////////////
- public function test_staticIs_integer1 ()
- {
- $res = Verify::staticIs_integer ("2017-04-13 22:55:17");
- $this->assertSame ($res, false);
- }
+ public function test_staticIs_integer1()
+ {
+ $res = Verify::staticIs_integer("2017-04-13 22:55:17");
+ $this->assertSame($res, false);
+ }
- public function test_staticIs_integer2 ()
- {
- $res = Verify::staticIs_integer ("01234");
- $this->assertSame ($res, true);
- }
+ public function test_staticIs_integer2()
+ {
+ $res = Verify::staticIs_integer("01234");
+ $this->assertSame($res, true);
+ }
- public function test_staticIs_integer3 ()
- {
- $res = Verify::staticIs_integer ("0x1234");
- $this->assertSame ($res, false);
- }
+ public function test_staticIs_integer3()
+ {
+ $res = Verify::staticIs_integer("0x1234");
+ $this->assertSame($res, false);
+ }
- public function test_staticIs_integer4 ()
- {
- $res = Verify::staticIs_integer ("");
- $this->assertSame ($res, false);
- }
+ public function test_staticIs_integer4()
+ {
+ $res = Verify::staticIs_integer("");
+ $this->assertSame($res, false);
+ }
////////////////
// EMAILS //
@@ -116,71 +117,71 @@ class VerifyTest extends \PHPUnit_Framework_TestCase
/////////////
// URL //
/////////////
- public function test_is_url1 ()
- {
- $verify = new Verify ();
- $res = $verify->is_url ("invalid");
- $this->assertsame ($res, false);
- }
+ public function test_is_url1()
+ {
+ $verify = new Verify();
+ $res = $verify->is_url("invalid");
+ $this->assertsame($res, false);
+ }
- public function test_is_url2 ()
- {
- $verify = new Verify ();
- $res = $verify->is_url ("http://valid");
- $this->assertsame ($res, true);
- }
+ public function test_is_url2()
+ {
+ $verify = new Verify();
+ $res = $verify->is_url("http://valid");
+ $this->assertsame($res, true);
+ }
- public function test_staticIs_url1 ()
- {
- $res = Verify::staticIs_url ("invalid");
- $this->assertsame ($res, false);
- }
+ public function test_staticIs_url1()
+ {
+ $res = Verify::staticIs_url("invalid");
+ $this->assertsame($res, false);
+ }
- public function test_staticIs_url2 ()
- {
- $res = Verify::staticIs_url ("http://valid");
- $this->assertsame ($res, true);
- }
+ public function test_staticIs_url2()
+ {
+ $res = Verify::staticIs_url("http://valid");
+ $this->assertsame($res, true);
+ }
////////////////
// OTHERS //
////////////////
- public function test_is_UUID1 ()
- {
- $verify = new Verify ();
- $res = $verify->is_UUID ("ca39275f-9224-425f-ba94-efce2aa5b52c");
- $this->assertsame ($res, true);
- }
+ public function test_is_UUID1()
+ {
+ $verify = new Verify();
+ $res = $verify->is_UUID("ca39275f-9224-425f-ba94-efce2aa5b52c");
+ $this->assertsame($res, true);
+ }
- public function test_is_UUID2 ()
- {
- $verify = new Verify ();
- $res = $verify->is_UUID ("zz39275f-9224-425f-ba94-efce2aa5b52c");
- $this->assertsame ($res, false);
- }
+ public function test_is_UUID2()
+ {
+ $verify = new Verify();
+ $res = $verify->is_UUID("zz39275f-9224-425f-ba94-efce2aa5b52c");
+ $this->assertsame($res, false);
+ }
- public function test_is_UUID3 ()
- {
- $verify = new Verify ();
- $res = $verify->is_UUID ("2c");
- $this->assertsame ($res, false);
- }
+ public function test_is_UUID3()
+ {
+ $verify = new Verify();
+ $res = $verify->is_UUID("2c");
+ $this->assertsame($res, false);
+ }
- public function test_staticis_UUID1 ()
- {
- $res = Verify::staticis_UUID ("ca39275f-9224-425f-ba94-efce2aa5b52c");
- $this->assertsame ($res, true);
- }
+ public function test_staticis_UUID1()
+ {
+ $res = Verify::staticis_UUID("ca39275f-9224-425f-ba94-efce2aa5b52c");
+ $this->assertsame($res, true);
+ }
- public function test_staticis_UUID2 ()
- {
- $res = Verify::staticis_UUID ("zz39275f-9224-425f-ba94-efce2aa5b52c");
- $this->assertsame ($res, false);
- }
+ public function test_staticis_UUID2()
+ {
+ $res = Verify::staticis_UUID("zz39275f-9224-425f-ba94-efce2aa5b52c");
+ $this->assertsame($res, false);
+ }
- public function test_staticis_UUID3 ()
- {
- $res = Verify::staticis_UUID ("2c");
- $this->assertsame ($res, false);
- }
+ public function test_staticis_UUID3()
+ {
+ $res = Verify::staticis_UUID("2c");
+ $this->assertsame($res, false);
+ }
}
diff --git a/Tests/XdiffTest.php b/Tests/XdiffTest.php
index ff08caa..f572579 100644
--- a/Tests/XdiffTest.php
+++ b/Tests/XdiffTest.php
@@ -1,4 +1,5 @@
@@ -14,7 +15,7 @@ class xdiffTest extends \PHPUnit_Framework_TestCase
{
// Declaration of $string1 and $string2
// {{{
- private $string1 = "This part of the
+ private $string1 = "This part of the
document has stayed the
same from version to
version. It shouldn't
@@ -39,7 +40,7 @@ this paragraph needs to
be changed. Things can
be added after it.
";
- private $string2 = "This is an important
+ private $string2 = "This is an important
notice! It should
therefore be located at
the beginning of this
@@ -71,12 +72,12 @@ to this document.
";
// }}}
- public function test_diff_normal_1 ()
- {
- // Mode normal
- $xdiff = new Xdiff ();
- $res = $xdiff->diff ($this->string1, $this->string2);
- $this->assertSame ($res, "0a1,6
+ public function test_diff_normal_1()
+ {
+ // Mode normal
+ $xdiff = new Xdiff();
+ $res = $xdiff->diff($this->string1, $this->string2);
+ $this->assertSame($res, "0a1,6
> This is an important
> notice! It should
> therefore be located at
@@ -99,14 +100,14 @@ to this document.
> important new additions
> to this document.
");
- }
+ }
- public function test_diff_normal_2 ()
- {
- // Mode normal
- $xdiff = new Xdiff ();
- $res = $xdiff->diff ("NEWLINE\n".$this->string1, $this->string2);
- $this->assertSame ($res, "1c1,6
+ public function test_diff_normal_2()
+ {
+ // Mode normal
+ $xdiff = new Xdiff();
+ $res = $xdiff->diff("NEWLINE\n" . $this->string1, $this->string2);
+ $this->assertSame($res, "1c1,6
< NEWLINE
---
> This is an important
@@ -131,64 +132,64 @@ to this document.
> important new additions
> to this document.
");
- }
+ }
- public function test_diff_normal_3 ()
- {
- // Mode normal
- $xdiff = new Xdiff ();
- $res = $xdiff->diff ("NEWLINE\n", "\n");
- $this->assertSame ($res, "1c1
+ public function test_diff_normal_3()
+ {
+ // Mode normal
+ $xdiff = new Xdiff();
+ $res = $xdiff->diff("NEWLINE\n", "\n");
+ $this->assertSame($res, "1c1
< NEWLINE
---
>
");
- }
+ }
- public function test_diff_normal_4 ()
- {
- // Mode normal
- $xdiff = new Xdiff ();
- $res = $xdiff->diff ("\n", "NEWLINE\n");
- $this->assertSame ($res, "1c1
+ public function test_diff_normal_4()
+ {
+ // Mode normal
+ $xdiff = new Xdiff();
+ $res = $xdiff->diff("\n", "NEWLINE\n");
+ $this->assertSame($res, "1c1
<
---
> NEWLINE
");
- }
+ }
- public function test_diff_normal_5 ()
- {
- $xdiff = new Xdiff ();
- $res = $xdiff->diff ("\n", "\n");
- $this->assertSame ($res, "");
- }
+ public function test_diff_normal_5()
+ {
+ $xdiff = new Xdiff();
+ $res = $xdiff->diff("\n", "\n");
+ $this->assertSame($res, "");
+ }
- public function test_diff_normal_6 ()
- {
- $xdiff = new Xdiff ();
- $res = $xdiff->diff ("\n", "");
- $this->assertSame ($res, "1d0
+ public function test_diff_normal_6()
+ {
+ $xdiff = new Xdiff();
+ $res = $xdiff->diff("\n", "");
+ $this->assertSame($res, "1d0
< \n");
- }
+ }
- public function test_diff_normal_7 ()
- {
- $xdiff = new Xdiff ();
- $res = $xdiff->diff ("", "\n");
- $this->assertSame ($res, "0a1
+ public function test_diff_normal_7()
+ {
+ $xdiff = new Xdiff();
+ $res = $xdiff->diff("", "\n");
+ $this->assertSame($res, "0a1
> \n");
- }
+ }
- public function test_diff_unified_1 ()
- {
- // Mode unified
- $xdiff = new Xdiff ("unified");
- $res = $xdiff->diff ($this->string1, $this->string2);
- $date = date ("Y-m-d H:i:s.u00");
- // DST must answer +0200 in winter and +0100 in summer
- $dst = date ("O");
- $this->assertSame ($res, "--- Original ${date}0 $dst
+ public function test_diff_unified_1()
+ {
+ // Mode unified
+ $xdiff = new Xdiff("unified");
+ $res = $xdiff->diff($this->string1, $this->string2);
+ $date = date("Y-m-d H:i:s.u00");
+ // DST must answer +0200 in winter and +0100 in summer
+ $dst = date("O");
+ $this->assertSame($res, "--- Original ${date}0 $dst
+++ New ${date}1 $dst
@@ -0,0 +1,6 @@
+This is an important
@@ -212,15 +213,15 @@ to this document.
+important new additions
+to this document.
");
- }
+ }
- public function test_diff_unified_2 ()
- {
- // Mode unified
- $xdiff = new Xdiff ("unified");
- $res = $xdiff->diff ("NEWLINE\n".$this->string1, $this->string2);
- $this->assertSame ($res, "--- Original ".date ("Y-m-d H:i:s.u000 O")."
-+++ New ".date ("Y-m-d H:i:s.u001 O")."
+ public function test_diff_unified_2()
+ {
+ // Mode unified
+ $xdiff = new Xdiff("unified");
+ $res = $xdiff->diff("NEWLINE\n" . $this->string1, $this->string2);
+ $this->assertSame($res, "--- Original " . date("Y-m-d H:i:s.u000 O") . "
++++ New " . date("Y-m-d H:i:s.u001 O") . "
@@ -1 +1,6 @@
-NEWLINE
+This is an important
@@ -244,67 +245,67 @@ to this document.
+important new additions
+to this document.
");
- }
+ }
- public function test_diff_unified_3 ()
- {
- $xdiff = new Xdiff ("unified");
- $res = $xdiff->diff ("NEWLINE\n", "\n");
- $this->assertSame ($res, "--- Original ".date ("Y-m-d H:i:s.u000 O")."
-+++ New ".date ("Y-m-d H:i:s.u001 O")."
+ public function test_diff_unified_3()
+ {
+ $xdiff = new Xdiff("unified");
+ $res = $xdiff->diff("NEWLINE\n", "\n");
+ $this->assertSame($res, "--- Original " . date("Y-m-d H:i:s.u000 O") . "
++++ New " . date("Y-m-d H:i:s.u001 O") . "
@@ -1 +1 @@
-NEWLINE
+
");
- }
+ }
- public function test_diff_unified_4 ()
- {
- $xdiff = new Xdiff ("unified");
- $res = $xdiff->diff ("\n", "NEWLINE\n");
- $this->assertSame ($res, "--- Original ".date ("Y-m-d H:i:s.u000 O")."
-+++ New ".date ("Y-m-d H:i:s.u001 O")."
+ public function test_diff_unified_4()
+ {
+ $xdiff = new Xdiff("unified");
+ $res = $xdiff->diff("\n", "NEWLINE\n");
+ $this->assertSame($res, "--- Original " . date("Y-m-d H:i:s.u000 O") . "
++++ New " . date("Y-m-d H:i:s.u001 O") . "
@@ -1 +1 @@
-
+NEWLINE
");
- }
+ }
- public function test_diff_unified_5 ()
- {
- $xdiff = new Xdiff ("unified");
- $res = $xdiff->diff ("\n", "\n");
- $this->assertSame ($res, "");
- }
+ public function test_diff_unified_5()
+ {
+ $xdiff = new Xdiff("unified");
+ $res = $xdiff->diff("\n", "\n");
+ $this->assertSame($res, "");
+ }
- public function test_diff_unified_6 ()
- {
- $xdiff = new Xdiff ("unified");
- $res = $xdiff->diff ("\n", "");
- $this->assertSame ($res, "--- Original ".date ("Y-m-d H:i:s.u000 O")."
-+++ New ".date ("Y-m-d H:i:s.u001 O")."
+ public function test_diff_unified_6()
+ {
+ $xdiff = new Xdiff("unified");
+ $res = $xdiff->diff("\n", "");
+ $this->assertSame($res, "--- Original " . date("Y-m-d H:i:s.u000 O") . "
++++ New " . date("Y-m-d H:i:s.u001 O") . "
@@ -1 +0,0 @@
-\n");
- }
+ }
- public function test_diff_unified_7 ()
- {
- $xdiff = new Xdiff ("unified");
- $res = $xdiff->diff ("", "\n");
- $this->assertSame ($res, "--- Original ".date ("Y-m-d H:i:s.u000 O")."
-+++ New ".date ("Y-m-d H:i:s.u001 O")."
+ public function test_diff_unified_7()
+ {
+ $xdiff = new Xdiff("unified");
+ $res = $xdiff->diff("", "\n");
+ $this->assertSame($res, "--- Original " . date("Y-m-d H:i:s.u000 O") . "
++++ New " . date("Y-m-d H:i:s.u001 O") . "
@@ -0,0 +1 @@
+\n");
- }
+ }
- public function test_diffFile_unified_1 ()
- {
- file_put_contents ("/tmp/test_xdiff1", $this->string1);
- file_put_contents ("/tmp/test_xdiff2", $this->string2);
- $xdiff = new Xdiff ("unified");
- $res = $xdiff->diffFile ("/tmp/test_xdiff1", "/tmp/test_xdiff2");
- $this->assertSame ($res, "--- /tmp/test_xdiff1 ".date ("Y-m-d H:i:s.u000 O")."
-+++ /tmp/test_xdiff2 ".date ("Y-m-d H:i:s.u001 O")."
+ public function test_diffFile_unified_1()
+ {
+ file_put_contents("/tmp/test_xdiff1", $this->string1);
+ file_put_contents("/tmp/test_xdiff2", $this->string2);
+ $xdiff = new Xdiff("unified");
+ $res = $xdiff->diffFile("/tmp/test_xdiff1", "/tmp/test_xdiff2");
+ $this->assertSame($res, "--- /tmp/test_xdiff1 " . date("Y-m-d H:i:s.u000 O") . "
++++ /tmp/test_xdiff2 " . date("Y-m-d H:i:s.u001 O") . "
@@ -0,0 +1,6 @@
+This is an important
+notice! It should
@@ -327,31 +328,31 @@ to this document.
+important new additions
+to this document.
");
+ }
- }
+ public function test_diffFile_unified_2()
+ {
+ $xdiff = new Xdiff("unified");
+ $this->setExpectedException();
+ $res = $xdiff->diffFile("/tmp/test_xdiffNOTEXISTS", "/tmp/test_xdiff2");
+ }
- public function test_diffFile_unified_2 ()
- {
- $xdiff = new Xdiff ("unified");
- $this->setExpectedException ();
- $res = $xdiff->diffFile ("/tmp/test_xdiffNOTEXISTS", "/tmp/test_xdiff2");
- }
+ public function test_diffFile_unified_3()
+ {
+ $xdiff = new Xdiff("unified");
+ $this->setExpectedException();
+ $res = $xdiff->diffFile("/tmp/test_xdiff1", "/tmp/test_xdiffNOTEXISTS");
+ }
- public function test_diffFile_unified_3 ()
- {
- $xdiff = new Xdiff ("unified");
- $this->setExpectedException ();
- $res = $xdiff->diffFile ("/tmp/test_xdiff1", "/tmp/test_xdiffNOTEXISTS");
- }
-
- public function test_diffFile_sideBySide_1 ()
- {
- file_put_contents ("/tmp/test_xdiff1", $this->string1);
- file_put_contents ("/tmp/test_xdiff2", $this->string2);
- $xdiff = new Xdiff ("sideBySide");
- $res = $xdiff->diffFile ("/tmp/test_xdiff1", "/tmp/test_xdiff2");
- $this->assertSame ($res,
-" > This is an important
+ public function test_diffFile_sideBySide_1()
+ {
+ file_put_contents("/tmp/test_xdiff1", $this->string1);
+ file_put_contents("/tmp/test_xdiff2", $this->string2);
+ $xdiff = new Xdiff("sideBySide");
+ $res = $xdiff->diffFile("/tmp/test_xdiff1", "/tmp/test_xdiff2");
+ $this->assertSame(
+ $res,
+ " > This is an important
> notice! It should
> therefore be located at
> the beginning of this
@@ -385,6 +386,7 @@ be added after it. be added after it.
> This paragraph contains
> important new additions
> to this document.
-");
- }
+"
+ );
+ }
}
diff --git a/Tests/XmppclientTest.php b/Tests/XmppclientTest.php
index bc3eb2f..35f89dd 100644
--- a/Tests/XmppclientTest.php
+++ b/Tests/XmppclientTest.php
@@ -1,4 +1,5 @@
@@ -12,49 +13,71 @@ use Domframework\Xmppclient;
/** Test the domframework xmppclient part */
class xmppclientTest extends \PHPUnit_Framework_TestCase
{
- public function test_connection_BADNAME ()
- {
- $this->expectException ("Exception");
- $xmppclient = new Xmppclient ();
- $res = $xmppclient->connect ("NOTFOUND.fournier38.fr", 5222, "", "");
- }
+ public function test_connection_BADNAME()
+ {
+ $this->expectException("Exception");
+ $xmppclient = new Xmppclient();
+ $res = $xmppclient->connect("NOTFOUND.fournier38.fr", 5222, "", "");
+ }
- public function test_connection_authenticate_1 ()
- {
- $xmppclient = new Xmppclient ();
- $res = $xmppclient->connect ("xmpp.fournier38.fr", 5222,
- "testxmpp@xmpp.fournier38.fr", "LSqmBXDUZWxk");
- $this->assertSame (is_object ($res), true);
- }
+ public function test_connection_authenticate_1()
+ {
+ $xmppclient = new Xmppclient();
+ $res = $xmppclient->connect(
+ "xmpp.fournier38.fr",
+ 5222,
+ "testxmpp@xmpp.fournier38.fr",
+ "LSqmBXDUZWxk"
+ );
+ $this->assertSame(is_object($res), true);
+ }
- public function test_connection_disco_1 ()
- {
- $xmppclient = new Xmppclient ();
- $xmppclient->connect ("xmpp.fournier38.fr", 5222,
- "testxmpp@xmpp.fournier38.fr", "LSqmBXDUZWxk");
- $res = $xmppclient->discoveryService ();
- $this->assertSame (is_array ($res) && count ($res) > 5, true);
- }
+ public function test_connection_disco_1()
+ {
+ $xmppclient = new Xmppclient();
+ $xmppclient->connect(
+ "xmpp.fournier38.fr",
+ 5222,
+ "testxmpp@xmpp.fournier38.fr",
+ "LSqmBXDUZWxk"
+ );
+ $res = $xmppclient->discoveryService();
+ $this->assertSame(is_array($res) && count($res) > 5, true);
+ }
- public function test_connection_sendMessage_1 ()
- {
- $xmppclient = new Xmppclient ();
- $xmppclient->connect ("xmpp.fournier38.fr", 5222,
- "testxmpp@xmpp.fournier38.fr", "LSqmBXDUZWxk");
- $res = $xmppclient->sendMessagePrivate ("dominique@fournier38.fr",
- "DFW TEST XMPP : test_connection_sendMessage_1");
- $this->assertSame (is_object ($res), true);
- }
+ public function test_connection_sendMessage_1()
+ {
+ $xmppclient = new Xmppclient();
+ $xmppclient->connect(
+ "xmpp.fournier38.fr",
+ 5222,
+ "testxmpp@xmpp.fournier38.fr",
+ "LSqmBXDUZWxk"
+ );
+ $res = $xmppclient->sendMessagePrivate(
+ "dominique@fournier38.fr",
+ "DFW TEST XMPP : test_connection_sendMessage_1"
+ );
+ $this->assertSame(is_object($res), true);
+ }
- public function test_connection_sendMessage_2 ()
- {
- $xmppclient = new Xmppclient ();
- $xmppclient->connect ("xmpp.fournier38.fr", 5222,
- "testxmpp@xmpp.fournier38.fr", "LSqmBXDUZWxk");
- $res = $xmppclient->sendMessagePrivate ("dominique@fournier38.fr",
- "DFW TEST XMPP : test_connection_sendMessage_2 : MESSAGE 1");
- $res = $xmppclient->sendMessagePrivate ("dominique@fournier38.fr",
- "DFW TEST XMPP : test_connection_sendMessage_2 : MESSAGE 2");
- $this->assertSame (is_object ($res), true);
- }
+ public function test_connection_sendMessage_2()
+ {
+ $xmppclient = new Xmppclient();
+ $xmppclient->connect(
+ "xmpp.fournier38.fr",
+ 5222,
+ "testxmpp@xmpp.fournier38.fr",
+ "LSqmBXDUZWxk"
+ );
+ $res = $xmppclient->sendMessagePrivate(
+ "dominique@fournier38.fr",
+ "DFW TEST XMPP : test_connection_sendMessage_2 : MESSAGE 1"
+ );
+ $res = $xmppclient->sendMessagePrivate(
+ "dominique@fournier38.fr",
+ "DFW TEST XMPP : test_connection_sendMessage_2 : MESSAGE 2"
+ );
+ $this->assertSame(is_object($res), true);
+ }
}
diff --git a/Tests/configuration.php b/Tests/configuration.php
index 8276d1a..161c8d2 100644
--- a/Tests/configuration.php
+++ b/Tests/configuration.php
@@ -1,4 +1,5 @@
@@ -6,8 +7,9 @@
*/
namespace Domframework\Tests;
+
$conf = array (
- "database"=> array (
+ "database" => array (
"dsn" => "sqlite:/tmp/database.db",
"username" => null,
"password" => null,
diff --git a/src/Auth.php b/src/Auth.php
index a8fd138..be8d649 100644
--- a/src/Auth.php
+++ b/src/Auth.php
@@ -1,4 +1,5 @@
@@ -10,50 +11,50 @@ namespace Domframework;
/** User authentication (abstract class) */
class Auth
{
- /** The application name */
- public $appName = null;
+ /** The application name */
+ public $appName = null;
- /** Display the authentication page
- * The message is displayed to the user in case of error
- * The url is the caller url to go back if authentication is correct
- * @param string $baseURL The URL base to use for the links
- * @param string|null $message Message to display to the user
- * @param string|null $url URL to go back after successful authentication
- * @param mixed $alreadyAuth If the user is already authenticated, the value
- * will be displayed if the user is coming on the page.
- */
- public function pageHTML ($baseURL, $message="", $url="", $alreadyAuth=false)
- {
- $res = "";
- $res .= "\n";
- $res .= "\n";
- $res .= "\n";
- $res .= "".dgettext ("domframework", "Sign in")."\n";
- $res .= "\n";
+ $res .= "\n";
+ $res .= "" . dgettext("domframework", "Sign in") . "\n";
+ $res .= "appName !== null)
- $res .= "".$this->appName."
\n";
- $res .= " \n";
- $res .= " \n";
- $res .= " \n";
- }
- else
- {
- $res .= " \n";
- if (is_string ($alreadyAuth))
- {
- $res .= "".dgettext ("domframework", "With login:")."
\n";
- $res .= " $alreadyAuth
\n";
- }
- $res .= " ".
- dgettext ("domframework", "Logout")."\n";
- if ($url !== "")
- $res .= "".
- dgettext ("domframework", "Go back to the calling page").
+ $res .= "h1 { color: #bbb }\n";
+ $res .= "h2 { padding-top: 0px; padding-bottom: 30px;}\n";
+ $res .= " \n";
+ $res .= " \n";
+ $res .= " \n";
+ $res .= "\n";
+ if ($this->appName !== null) {
+ $res .= "
" . $this->appName . "
\n";
+ }
+ $res .= "
\n";
+ $res .= "
\n";
+ $res .= "
\n";
+ } else {
+ $res .= "
\n";
+ if (is_string($alreadyAuth)) {
+ $res .= "
" . dgettext("domframework", "With login:") . "
\n";
+ $res .= "
$alreadyAuth
\n";
+ }
+ $res .= "
" .
+ dgettext("domframework", "Logout") . "\n";
+ if ($url !== "") {
+ $res .= "" .
+ dgettext("domframework", "Go back to the calling page") .
"\n";
- $res .="
\n";
+ }
+ $res .= "\n";
+ }
+ if ($message !== "" && $message !== null) {
+ $res .= "
$message
\n";
+ }
+ $res .= " \n";
+ $res .= "
\n";
+ $res .= "\n";
+ $res .= "\n";
+ return $res;
}
- if ($message !== "" && $message !== null)
- $res .= " $message
\n";
- $res .= "