Passage en Namespace et tous les tests fonctionnels OK

This commit is contained in:
2021-05-10 11:48:15 +02:00
parent 536dd0d56b
commit eb30d8ef97
56 changed files with 1091 additions and 964 deletions
+11 -8
View File
@@ -7,12 +7,15 @@
namespace Domframework\Tests;
/** Test the authhtpasswd.php file */
class authhtpasswdTest extends \PHPUnit_Framework_TestCase
use Domframework\Authhtpasswd;
/** Test the Authhtpasswd.php file */
class AuthhtpasswdTest extends \PHPUnit_Framework_TestCase
{
public function test_clean ()
{
@unlink ("/tmp/htpasswd.file");
if (file_exists ("/tmp/htpasswd.file"))
unlink ("/tmp/htpasswd.file");
file_put_contents ("/tmp/htpasswd.file",
'toto@toto.com:$2y$05$dO7qyX4simzg3pMgWyqHgeAjFauXEyUdPdyrwDMVNj4fTuE24TGuq'
."\n".
@@ -23,7 +26,7 @@ class authhtpasswdTest extends \PHPUnit_Framework_TestCase
public function test_connect ()
{
$authhtpasswd = new authhtpasswd ();
$authhtpasswd = new Authhtpasswd ();
$authhtpasswd->htpasswdFile = "/tmp/htpasswd.file";
$res = $authhtpasswd->connect ();
$this->assertSame ($res, null);
@@ -31,7 +34,7 @@ class authhtpasswdTest extends \PHPUnit_Framework_TestCase
public function test_authentication1 ()
{
$authhtpasswd = new authhtpasswd ();
$authhtpasswd = new Authhtpasswd ();
$authhtpasswd->htpasswdFile = "/tmp/htpasswd.file";
$res = $authhtpasswd->authentication ("toto@toto.com", "toto123");
$this->assertSame ($res, true);
@@ -39,7 +42,7 @@ class authhtpasswdTest extends \PHPUnit_Framework_TestCase
public function test_authentication2 ()
{
$authhtpasswd = new authhtpasswd ();
$authhtpasswd = new Authhtpasswd ();
$authhtpasswd->htpasswdFile = "/tmp/htpasswd.file";
$this->setExpectedException ("Exception");
$res = $authhtpasswd->authentication ("UNKNOWN@toto.com", "toto123");
@@ -47,7 +50,7 @@ class authhtpasswdTest extends \PHPUnit_Framework_TestCase
public function test_authentication3 ()
{
$authhtpasswd = new authhtpasswd ();
$authhtpasswd = new Authhtpasswd ();
$authhtpasswd->htpasswdFile = "/tmp/htpasswd.file";
$this->setExpectedException ("Exception");
$res = $authhtpasswd->authentication ("toto@toto.com", "BAD PASSWD");
@@ -55,7 +58,7 @@ class authhtpasswdTest extends \PHPUnit_Framework_TestCase
public function test_authentication4 ()
{
$authhtpasswd = new authhtpasswd ();
$authhtpasswd = new Authhtpasswd ();
$authhtpasswd->htpasswdFile = "/tmp/htpasswd.file";
$res = $authhtpasswd->authentication ("titi@titi.com", "toto123");
$this->assertSame ($res, true);
+18 -16
View File
@@ -7,8 +7,10 @@
namespace Domframework\Tests;
/** Test the authjwt.php file */
class authjwtTest extends \PHPUnit_Framework_TestCase
use Domframework\Authjwt;
/** Test the Authjwt.php file */
class AuthjwtTest extends \PHPUnit_Framework_TestCase
{
public function __construct ()
{
@@ -29,7 +31,7 @@ class authjwtTest extends \PHPUnit_Framework_TestCase
public function testJWT1 ()
// {{{
{
$authjwt = new authjwt ();
$authjwt = new Authjwt ();
$authjwt->cacheDir = $this->cacheDir;
$authjwt->serverKey = $this->serverKey;
$authjwt->cipherKey = $this->cipherKey;
@@ -44,7 +46,7 @@ class authjwtTest extends \PHPUnit_Framework_TestCase
public function testAuthValid1 ()
// {{{
{
$authjwt = new authjwt ();
$authjwt = new Authjwt ();
$_SERVER["HTTP_AUTHENTICATION"] = "Bearer ".$this->token;
$authjwt->cacheDir = $this->cacheDir;
$authjwt->serverKey = $this->serverKey;
@@ -62,7 +64,7 @@ class authjwtTest extends \PHPUnit_Framework_TestCase
// {{{
{
$this->expectException ("Exception", "JWT Signature not readable", 403);
$authjwt = new authjwt ();
$authjwt = new Authjwt ();
$_SERVER["HTTP_AUTHENTICATION"] = "Bearer ".$this->token."NO";
$authjwt->cacheDir = $this->cacheDir;
$authjwt->serverKey = $this->serverKey;
@@ -78,7 +80,7 @@ class authjwtTest extends \PHPUnit_Framework_TestCase
// {{{
{
$this->expectException ("Exception", "JWT with Empty algorithm", 403);
$authjwt = new authjwt ();
$authjwt = new Authjwt ();
$_SERVER["HTTP_AUTHENTICATION"] = "Bearer "."NO".$this->token;
$authjwt->cacheDir = $this->cacheDir;
$authjwt->serverKey = $this->serverKey;
@@ -94,7 +96,7 @@ class authjwtTest extends \PHPUnit_Framework_TestCase
// {{{
{
$this->expectException ("Exception", "No Authentication available", 401);
$authjwt = new authjwt ();
$authjwt = new Authjwt ();
unset ($_SERVER["HTTP_AUTHENTICATION"]);
$authjwt->cacheDir = $this->cacheDir;
$authjwt->serverKey = $this->serverKey;
@@ -111,7 +113,7 @@ class authjwtTest extends \PHPUnit_Framework_TestCase
{
$this->expectException ("Exception", "No Bearer Authentication available",
401);
$authjwt = new authjwt ();
$authjwt = new Authjwt ();
$_SERVER["HTTP_AUTHENTICATION"] = "Bearer";
$authjwt->cacheDir = $this->cacheDir;
$authjwt->serverKey = $this->serverKey;
@@ -129,7 +131,7 @@ class authjwtTest extends \PHPUnit_Framework_TestCase
$this->expectException ("Exception",
"AuthJWT : No email available in auth", 403);
$auth = ["password" => "ToTo"];
$authjwt = new authjwt ();
$authjwt = new Authjwt ();
$authjwt->cacheDir = $this->cacheDir;
$authjwt->serverKey = $this->serverKey;
$authjwt->cipherKey = $this->cipherKey;
@@ -148,7 +150,7 @@ class authjwtTest extends \PHPUnit_Framework_TestCase
$this->expectException ("Exception",
"AuthJWT : can not create token for anonymous", 403);
$auth = ["email" => "anonymous"];
$authjwt = new authjwt ();
$authjwt = new Authjwt ();
$authjwt->cacheDir = $this->cacheDir;
$authjwt->serverKey = $this->serverKey;
$authjwt->cipherKey = $this->cipherKey;
@@ -164,7 +166,7 @@ class authjwtTest extends \PHPUnit_Framework_TestCase
public function testLogout1 ()
// {{{
{
$authjwt = new authjwt ();
$authjwt = new Authjwt ();
$authjwt->cacheDir = $this->cacheDir;
$authjwt->serverKey = $this->serverKey;
$authjwt->cipherKey = $this->cipherKey;
@@ -180,7 +182,7 @@ class authjwtTest extends \PHPUnit_Framework_TestCase
// {{{
{
$this->expectException ("Exception", "No Authentication available", 401);
$authjwt = new authjwt ();
$authjwt = new Authjwt ();
$authjwt->cacheDir = $this->cacheDir;
$authjwt->serverKey = $this->serverKey;
$authjwt->cipherKey = $this->cipherKey;
@@ -196,7 +198,7 @@ class authjwtTest extends \PHPUnit_Framework_TestCase
{
$this->expectException ("Exception", "No Bearer Authentication available",
401);
$authjwt = new authjwt ();
$authjwt = new Authjwt ();
$authjwt->cacheDir = $this->cacheDir;
$authjwt->serverKey = $this->serverKey;
$authjwt->cipherKey = $this->cipherKey;
@@ -211,7 +213,7 @@ class authjwtTest extends \PHPUnit_Framework_TestCase
public function testUnusedFunctions1 ()
// {{{
{
$authjwt = new authjwt ();
$authjwt = new Authjwt ();
$res = $authjwt->connect ();
$this->assertSame ($res, true);
}
@@ -224,7 +226,7 @@ class authjwtTest extends \PHPUnit_Framework_TestCase
{
$this->expectException ("Exception",
"The password can't be change for JWT users", 405);
$authjwt = new authjwt ();
$authjwt = new Authjwt ();
$res = $authjwt->changepassword ("unused", "unused");
}
// }}}
@@ -236,7 +238,7 @@ class authjwtTest extends \PHPUnit_Framework_TestCase
{
$this->expectException ("Exception",
"The password can't be overwrite for JWT users", 405);
$authjwt = new authjwt ();
$authjwt = new Authjwt ();
$res = $authjwt->overwritepassword ("unused", "unused");
}
// }}}
+10 -8
View File
@@ -7,20 +7,22 @@
namespace Domframework\Tests;
use Domframework\Authsympa;
/** Test the authentication on Sympa Service */
class authsympaTest extends \PHPUnit_Framework_TestCase
class AuthsympaTest extends \PHPUnit_Framework_TestCase
{
public function test_connect_1 ()
{
// Empty
$authsympa = new authsympa ();
$authsympa = new Authsympa ();
$this->expectException ();
$authsympa->connect ();
}
public function test_connect_2 ()
{
$authsympa = new authsympa ();
$authsympa = new Authsympa ();
$authsympa->wsdl = "https://listes.grenoble.cnrs.fr/sympa/wsdl";
$authsympa->connect ();
$res = $authsympa->getDetails ();
@@ -30,7 +32,7 @@ class authsympaTest extends \PHPUnit_Framework_TestCase
public function test_auth_1 ()
{
// Invalid password
$authsympa = new authsympa ();
$authsympa = new Authsympa ();
$authsympa->wsdl = "https://listes.grenoble.cnrs.fr/sympa/wsdl";
$authsympa->list = "listtest@listes.grenoble.cnrs.fr";
$authsympa->connect ();
@@ -41,7 +43,7 @@ class authsympaTest extends \PHPUnit_Framework_TestCase
public function test_auth_2 ()
{
// Unknown user
$authsympa = new authsympa ();
$authsympa = new Authsympa ();
$authsympa->wsdl = "https://listes.grenoble.cnrs.fr/sympa/wsdl";
$authsympa->list = "listtest@listes.grenoble.cnrs.fr";
$authsympa->connect ();
@@ -52,7 +54,7 @@ class authsympaTest extends \PHPUnit_Framework_TestCase
public function test_auth_3 ()
{
// OK !
$authsympa = new authsympa ();
$authsympa = new Authsympa ();
$authsympa->wsdl = "https://listes.grenoble.cnrs.fr/sympa/wsdl";
$authsympa->list = "listtest@listes.grenoble.cnrs.fr";
$authsympa->connect ();
@@ -63,7 +65,7 @@ class authsympaTest extends \PHPUnit_Framework_TestCase
public function test_auth_4 ()
{
// Unknown list
$authsympa = new authsympa ();
$authsympa = new Authsympa ();
$authsympa->wsdl = "https://listes.grenoble.cnrs.fr/sympa/wsdl";
$authsympa->list = "unknown@listes.grenoble.cnrs.fr";
$authsympa->connect ();
@@ -74,7 +76,7 @@ class authsympaTest extends \PHPUnit_Framework_TestCase
public function test_auth_5 ()
{
// User not in list
$authsympa = new authsympa ();
$authsympa = new Authsympa ();
$authsympa->wsdl = "https://listes.grenoble.cnrs.fr/sympa/wsdl";
$authsympa->list = "admins@listes.grenoble.cnrs.fr";
$authsympa->connect ();
+32 -29
View File
@@ -7,8 +7,10 @@
namespace Domframework\Tests;
/** Test the authzgroups.php file */
class authzgroupsTest extends \PHPUnit_Framework_TestCase
use Domframework\Authzgroups;
/** Test the Authzgroups.php file */
class AuthzgroupsTest extends \PHPUnit_Framework_TestCase
{
private $dbconfig = array (
"dsn" => "sqlite:/tmp/databaseAuthzGroups.db",
@@ -19,12 +21,13 @@ class authzgroupsTest extends \PHPUnit_Framework_TestCase
);
public function test_Initialization ()
{
@unlink ("/tmp/databaseAuthzGroups.db");
if (file_exists ("/tmp/databaseAuthzGroups.db"))
unlink ("/tmp/databaseAuthzGroups.db");
}
public function test_createTables1 ()
{
$authz = new authzgroups ();
$authz = new Authzgroups ();
$this->setExpectedException ("Exception");
$authz->createTables ();
}
@@ -33,7 +36,7 @@ class authzgroupsTest extends \PHPUnit_Framework_TestCase
{
// Must use the model to create the database structure as there is no
// creation of tables in controller
$authz = new authzgroups ();
$authz = new Authzgroups ();
$res = $authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
$this->dbconfig["password"],
$this->dbconfig["driver_options"]);
@@ -42,7 +45,7 @@ class authzgroupsTest extends \PHPUnit_Framework_TestCase
public function test_createTables2 ()
{
$authz = new authzgroups ();
$authz = new Authzgroups ();
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
$this->dbconfig["password"],
$this->dbconfig["driver_options"]);
@@ -55,7 +58,7 @@ class authzgroupsTest extends \PHPUnit_Framework_TestCase
////////////////
public function test_objectCreate1 ()
{
$authz = new authzgroups ();
$authz = new Authzgroups ();
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
$this->dbconfig["password"],
$this->dbconfig["driver_options"]);
@@ -65,7 +68,7 @@ class authzgroupsTest extends \PHPUnit_Framework_TestCase
public function test_objectUpdate1 ()
{
$authz = new authzgroups ();
$authz = new Authzgroups ();
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
$this->dbconfig["password"],
$this->dbconfig["driver_options"]);
@@ -75,7 +78,7 @@ class authzgroupsTest extends \PHPUnit_Framework_TestCase
public function test_objectDelete1 ()
{
$authz = new authzgroups ();
$authz = new Authzgroups ();
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
$this->dbconfig["password"],
$this->dbconfig["driver_options"]);
@@ -89,7 +92,7 @@ class authzgroupsTest extends \PHPUnit_Framework_TestCase
////////////////
public function test_groupCreate1 ()
{
$authz = new authzgroups ();
$authz = new Authzgroups ();
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
$this->dbconfig["password"],
$this->dbconfig["driver_options"]);
@@ -99,7 +102,7 @@ class authzgroupsTest extends \PHPUnit_Framework_TestCase
public function test_groupUpdate1 ()
{
$authz = new authzgroups ();
$authz = new Authzgroups ();
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
$this->dbconfig["password"],
$this->dbconfig["driver_options"]);
@@ -109,7 +112,7 @@ class authzgroupsTest extends \PHPUnit_Framework_TestCase
public function test_groupDelete1 ()
{
$authz = new authzgroups ();
$authz = new Authzgroups ();
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
$this->dbconfig["password"],
$this->dbconfig["driver_options"]);
@@ -123,7 +126,7 @@ class authzgroupsTest extends \PHPUnit_Framework_TestCase
/////////////////////
public function test_groupmemberCreate1 ()
{
$authz = new authzgroups ();
$authz = new Authzgroups ();
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
$this->dbconfig["password"],
$this->dbconfig["driver_options"]);
@@ -134,7 +137,7 @@ class authzgroupsTest extends \PHPUnit_Framework_TestCase
public function test_groupmemberCreate2 ()
{
$authz = new authzgroups ();
$authz = new Authzgroups ();
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
$this->dbconfig["password"],
$this->dbconfig["driver_options"]);
@@ -144,7 +147,7 @@ class authzgroupsTest extends \PHPUnit_Framework_TestCase
public function test_groupmemberDelete1 ()
{
$authz = new authzgroups ();
$authz = new Authzgroups ();
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
$this->dbconfig["password"],
$this->dbconfig["driver_options"]);
@@ -155,7 +158,7 @@ class authzgroupsTest extends \PHPUnit_Framework_TestCase
public function test_groupmemberReadGroup1 ()
{
$authz = new authzgroups ();
$authz = new Authzgroups ();
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
$this->dbconfig["password"],
$this->dbconfig["driver_options"]);
@@ -166,7 +169,7 @@ class authzgroupsTest extends \PHPUnit_Framework_TestCase
public function test_groupmemberReadGroup2 ()
{
$authz = new authzgroups ();
$authz = new Authzgroups ();
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
$this->dbconfig["password"],
$this->dbconfig["driver_options"]);
@@ -176,7 +179,7 @@ class authzgroupsTest extends \PHPUnit_Framework_TestCase
public function test_groupmemberReadUser1 ()
{
$authz = new authzgroups ();
$authz = new Authzgroups ();
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
$this->dbconfig["password"],
$this->dbconfig["driver_options"]);
@@ -189,7 +192,7 @@ class authzgroupsTest extends \PHPUnit_Framework_TestCase
////////////////
public function test_rightCreate1 ()
{
$authz = new authzgroups ();
$authz = new Authzgroups ();
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
$this->dbconfig["password"],
$this->dbconfig["driver_options"]);
@@ -199,7 +202,7 @@ class authzgroupsTest extends \PHPUnit_Framework_TestCase
public function test_rightUpdate1 ()
{
$authz = new authzgroups ();
$authz = new Authzgroups ();
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
$this->dbconfig["password"],
$this->dbconfig["driver_options"]);
@@ -209,7 +212,7 @@ class authzgroupsTest extends \PHPUnit_Framework_TestCase
public function test_rightDelete1 ()
{
$authz = new authzgroups ();
$authz = new Authzgroups ();
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
$this->dbconfig["password"],
$this->dbconfig["driver_options"]);
@@ -224,7 +227,7 @@ class authzgroupsTest extends \PHPUnit_Framework_TestCase
//////////////////////////////////////////////
public function test_deleteGroupmember2 ()
{
$authz = new authzgroups ();
$authz = new Authzgroups ();
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
$this->dbconfig["password"],
$this->dbconfig["driver_options"]);
@@ -234,7 +237,7 @@ class authzgroupsTest extends \PHPUnit_Framework_TestCase
public function test_deleteObject2 ()
{
$authz = new authzgroups ();
$authz = new Authzgroups ();
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
$this->dbconfig["password"],
$this->dbconfig["driver_options"]);
@@ -244,7 +247,7 @@ class authzgroupsTest extends \PHPUnit_Framework_TestCase
public function test_deleteGroup2 ()
{
$authz = new authzgroups ();
$authz = new Authzgroups ();
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
$this->dbconfig["password"],
$this->dbconfig["driver_options"]);
@@ -257,7 +260,7 @@ class authzgroupsTest extends \PHPUnit_Framework_TestCase
/////////////////////
public function test_userrightsget1 ()
{
$authz = new authzgroups ();
$authz = new Authzgroups ();
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
$this->dbconfig["password"],
$this->dbconfig["driver_options"]);
@@ -286,7 +289,7 @@ class authzgroupsTest extends \PHPUnit_Framework_TestCase
public function test_allow1 ()
{
$authz = new authzgroups ();
$authz = new Authzgroups ();
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
$this->dbconfig["password"],
$this->dbconfig["driver_options"]);
@@ -296,7 +299,7 @@ class authzgroupsTest extends \PHPUnit_Framework_TestCase
public function test_allow2 ()
{
$authz = new authzgroups ();
$authz = new Authzgroups ();
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
$this->dbconfig["password"],
$this->dbconfig["driver_options"]);
@@ -307,7 +310,7 @@ class authzgroupsTest extends \PHPUnit_Framework_TestCase
public function test_allow3 ()
{
$authz = new authzgroups ();
$authz = new Authzgroups ();
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
$this->dbconfig["password"],
$this->dbconfig["driver_options"]);
@@ -318,7 +321,7 @@ class authzgroupsTest extends \PHPUnit_Framework_TestCase
public function test_allow4 ()
{
$authz = new authzgroups ();
$authz = new Authzgroups ();
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
$this->dbconfig["password"],
$this->dbconfig["driver_options"]);
+32 -29
View File
@@ -7,8 +7,10 @@
namespace Domframework\Tests;
/** Test the authzgroupsoo.php file */
class authzgroupsooTest extends \PHPUnit_Framework_TestCase
use Domframework\Authzgroupsoo;
/** Test the Authzgroupsoo.php file */
class AuthzgroupsooTest extends \PHPUnit_Framework_TestCase
{
private $dbconfig = array (
"dsn" => "sqlite:/tmp/databaseAuthzGroupsoo.db",
@@ -19,12 +21,13 @@ class authzgroupsooTest extends \PHPUnit_Framework_TestCase
);
public function test_Initialization ()
{
@unlink ("/tmp/databaseAuthzGroupsoo.db");
if (file_exists ("/tmp/databaseAuthzGroupsoo.db"))
unlink ("/tmp/databaseAuthzGroupsoo.db");
}
public function test_createTables1 ()
{
$authz = new authzgroupsoo ();
$authz = new Authzgroupsoo ();
$this->setExpectedException ("Exception");
$authz->createTables ();
}
@@ -33,7 +36,7 @@ class authzgroupsooTest extends \PHPUnit_Framework_TestCase
{
// Must use the model to create the database structure as there is no
// creation of tables in controller
$authz = new authzgroupsoo ();
$authz = new Authzgroupsoo ();
$res = $authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
$this->dbconfig["password"],
$this->dbconfig["driver_options"]);
@@ -42,7 +45,7 @@ class authzgroupsooTest extends \PHPUnit_Framework_TestCase
public function test_createTables2 ()
{
$authz = new authzgroupsoo ();
$authz = new Authzgroupsoo ();
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
$this->dbconfig["password"],
$this->dbconfig["driver_options"]);
@@ -55,7 +58,7 @@ class authzgroupsooTest extends \PHPUnit_Framework_TestCase
////////////////
public function test_objectCreate1 ()
{
$authz = new authzgroupsoo ();
$authz = new Authzgroupsoo ();
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
$this->dbconfig["password"],
$this->dbconfig["driver_options"]);
@@ -65,7 +68,7 @@ class authzgroupsooTest extends \PHPUnit_Framework_TestCase
public function test_objectUpdate1 ()
{
$authz = new authzgroupsoo ();
$authz = new Authzgroupsoo ();
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
$this->dbconfig["password"],
$this->dbconfig["driver_options"]);
@@ -75,7 +78,7 @@ class authzgroupsooTest extends \PHPUnit_Framework_TestCase
public function test_objectDelete1 ()
{
$authz = new authzgroupsoo ();
$authz = new Authzgroupsoo ();
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
$this->dbconfig["password"],
$this->dbconfig["driver_options"]);
@@ -89,7 +92,7 @@ class authzgroupsooTest extends \PHPUnit_Framework_TestCase
////////////////
public function test_groupCreate1 ()
{
$authz = new authzgroupsoo ();
$authz = new Authzgroupsoo ();
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
$this->dbconfig["password"],
$this->dbconfig["driver_options"]);
@@ -99,7 +102,7 @@ class authzgroupsooTest extends \PHPUnit_Framework_TestCase
public function test_groupUpdate1 ()
{
$authz = new authzgroupsoo ();
$authz = new Authzgroupsoo ();
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
$this->dbconfig["password"],
$this->dbconfig["driver_options"]);
@@ -109,7 +112,7 @@ class authzgroupsooTest extends \PHPUnit_Framework_TestCase
public function test_groupDelete1 ()
{
$authz = new authzgroupsoo ();
$authz = new Authzgroupsoo ();
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
$this->dbconfig["password"],
$this->dbconfig["driver_options"]);
@@ -123,7 +126,7 @@ class authzgroupsooTest extends \PHPUnit_Framework_TestCase
/////////////////////
public function test_groupmemberCreate1 ()
{
$authz = new authzgroupsoo ();
$authz = new Authzgroupsoo ();
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
$this->dbconfig["password"],
$this->dbconfig["driver_options"]);
@@ -134,7 +137,7 @@ class authzgroupsooTest extends \PHPUnit_Framework_TestCase
public function test_groupmemberCreate2 ()
{
$authz = new authzgroupsoo ();
$authz = new Authzgroupsoo ();
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
$this->dbconfig["password"],
$this->dbconfig["driver_options"]);
@@ -144,7 +147,7 @@ class authzgroupsooTest extends \PHPUnit_Framework_TestCase
public function test_groupmemberDelete1 ()
{
$authz = new authzgroupsoo ();
$authz = new Authzgroupsoo ();
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
$this->dbconfig["password"],
$this->dbconfig["driver_options"]);
@@ -155,7 +158,7 @@ class authzgroupsooTest extends \PHPUnit_Framework_TestCase
public function test_groupmemberReadGroup1 ()
{
$authz = new authzgroupsoo ();
$authz = new Authzgroupsoo ();
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
$this->dbconfig["password"],
$this->dbconfig["driver_options"]);
@@ -166,7 +169,7 @@ class authzgroupsooTest extends \PHPUnit_Framework_TestCase
public function test_groupmemberReadGroup2 ()
{
$authz = new authzgroupsoo ();
$authz = new Authzgroupsoo ();
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
$this->dbconfig["password"],
$this->dbconfig["driver_options"]);
@@ -176,7 +179,7 @@ class authzgroupsooTest extends \PHPUnit_Framework_TestCase
public function test_groupmemberReadUser1 ()
{
$authz = new authzgroupsoo ();
$authz = new Authzgroupsoo ();
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
$this->dbconfig["password"],
$this->dbconfig["driver_options"]);
@@ -189,7 +192,7 @@ class authzgroupsooTest extends \PHPUnit_Framework_TestCase
////////////////
public function test_rightCreate1 ()
{
$authz = new authzgroupsoo ();
$authz = new Authzgroupsoo ();
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
$this->dbconfig["password"],
$this->dbconfig["driver_options"]);
@@ -199,7 +202,7 @@ class authzgroupsooTest extends \PHPUnit_Framework_TestCase
public function test_rightUpdate1 ()
{
$authz = new authzgroupsoo ();
$authz = new Authzgroupsoo ();
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
$this->dbconfig["password"],
$this->dbconfig["driver_options"]);
@@ -209,7 +212,7 @@ class authzgroupsooTest extends \PHPUnit_Framework_TestCase
public function test_rightDelete1 ()
{
$authz = new authzgroupsoo ();
$authz = new Authzgroupsoo ();
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
$this->dbconfig["password"],
$this->dbconfig["driver_options"]);
@@ -224,7 +227,7 @@ class authzgroupsooTest extends \PHPUnit_Framework_TestCase
//////////////////////////////////////////////
public function test_deleteGroupmember2 ()
{
$authz = new authzgroupsoo ();
$authz = new Authzgroupsoo ();
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
$this->dbconfig["password"],
$this->dbconfig["driver_options"]);
@@ -234,7 +237,7 @@ class authzgroupsooTest extends \PHPUnit_Framework_TestCase
public function test_deleteObject2 ()
{
$authz = new authzgroupsoo ();
$authz = new Authzgroupsoo ();
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
$this->dbconfig["password"],
$this->dbconfig["driver_options"]);
@@ -244,7 +247,7 @@ class authzgroupsooTest extends \PHPUnit_Framework_TestCase
public function test_deleteGroup2 ()
{
$authz = new authzgroupsoo ();
$authz = new Authzgroupsoo ();
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
$this->dbconfig["password"],
$this->dbconfig["driver_options"]);
@@ -257,7 +260,7 @@ class authzgroupsooTest extends \PHPUnit_Framework_TestCase
/////////////////////
public function test_userrightsget1 ()
{
$authz = new authzgroupsoo ();
$authz = new Authzgroupsoo ();
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
$this->dbconfig["password"],
$this->dbconfig["driver_options"]);
@@ -286,7 +289,7 @@ class authzgroupsooTest extends \PHPUnit_Framework_TestCase
public function test_allow1 ()
{
$authz = new authzgroupsoo ();
$authz = new Authzgroupsoo ();
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
$this->dbconfig["password"],
$this->dbconfig["driver_options"]);
@@ -296,7 +299,7 @@ class authzgroupsooTest extends \PHPUnit_Framework_TestCase
public function test_allow2 ()
{
$authz = new authzgroupsoo ();
$authz = new Authzgroupsoo ();
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
$this->dbconfig["password"],
$this->dbconfig["driver_options"]);
@@ -307,7 +310,7 @@ class authzgroupsooTest extends \PHPUnit_Framework_TestCase
public function test_allow3 ()
{
$authz = new authzgroupsoo ();
$authz = new Authzgroupsoo ();
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
$this->dbconfig["password"],
$this->dbconfig["driver_options"]);
@@ -318,7 +321,7 @@ class authzgroupsooTest extends \PHPUnit_Framework_TestCase
public function test_allow4 ()
{
$authz = new authzgroupsoo ();
$authz = new Authzgroupsoo ();
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
$this->dbconfig["password"],
$this->dbconfig["driver_options"]);
+11 -9
View File
@@ -7,8 +7,10 @@
namespace Domframework\Tests;
/** Test the cache.php file */
class cachefileTest extends \PHPUnit_Framework_TestCase
use Domframework\Cachefile;
/** Test the Cachefile.php file */
class CachefileTest extends \PHPUnit_Framework_TestCase
{
public function testInit ()
{
@@ -19,7 +21,7 @@ class cachefileTest extends \PHPUnit_Framework_TestCase
// Unknown cache file : return FALSE
public function testRead1 ()
{
$c = new cachefile ();
$c = new Cachefile ();
$c->directory = "/tmp/cache";
$res = $c->read ("id");
$this->assertFalse ($res);
@@ -28,7 +30,7 @@ class cachefileTest extends \PHPUnit_Framework_TestCase
// Write in cache file
public function testWrite1 ()
{
$c = new cachefile ();
$c = new Cachefile ();
$c->directory = "/tmp/cache";
$res = $c->write ("id","DATA_TO_STORE", 3);
$this->assertTrue ($res);
@@ -37,7 +39,7 @@ class cachefileTest extends \PHPUnit_Framework_TestCase
// Previous cache file : return DATA_TO_STORE
public function testRead2 ()
{
$c = new cachefile ();
$c = new Cachefile ();
$c->directory = "/tmp/cache";
$res = $c->read ("id");
$this->assertSame ("DATA_TO_STORE", $res);
@@ -52,7 +54,7 @@ class cachefileTest extends \PHPUnit_Framework_TestCase
// Previous cache file but expired : return false
public function testRead3 ()
{
$c = new cachefile ();
$c = new Cachefile ();
$c->directory = "/tmp/cache";
$res = $c->read ("id");
$this->assertFalse ($res);
@@ -61,7 +63,7 @@ class cachefileTest extends \PHPUnit_Framework_TestCase
// Write in cache file
public function testWrite2 ()
{
$c = new cachefile ();
$c = new Cachefile ();
$c->directory = "/tmp/cache";
$res = $c->write ("id","DATA_TO_STORE", 30);
$this->assertTrue ($res);
@@ -77,7 +79,7 @@ class cachefileTest extends \PHPUnit_Framework_TestCase
// This test takes 10s to wait the lock which will never be released
public function testRead4 ()
{
$c = new cachefile ();
$c = new Cachefile ();
$c->directory = "/tmp/cache";
$res = $c->read ("id");
$this->assertSame ("DATA_TO_STORE", $res);
@@ -85,7 +87,7 @@ class cachefileTest extends \PHPUnit_Framework_TestCase
public function testDel1 ()
{
$c = new cachefile ();
$c = new Cachefile ();
$c->directory = "/tmp/cache";
$res = $c->delete ("id");
}
+13 -11
View File
@@ -7,13 +7,15 @@
namespace Domframework\Tests;
use Domframework\Certificationauthority;
/** Test the certification Authority
*/
class certificationauthorityTest extends \PHPUnit_Framework_TestCase
class CertificationauthorityTest extends \PHPUnit_Framework_TestCase
{
public function test_createCA_1 ()
{
$certificationauthority = new certificationauthority ();
$certificationauthority = new Certificationauthority ();
$certificationauthority->createCA ("FR", "FOURNIER38", "CATEST");
$caCert = explode ("\n", $certificationauthority->caCert ());
$caKey = explode ("\n", $certificationauthority->caKey ());
@@ -24,7 +26,7 @@ class certificationauthorityTest extends \PHPUnit_Framework_TestCase
public function test_createCA_2 ()
{
$certificationauthority = new certificationauthority ();
$certificationauthority = new Certificationauthority ();
$certificationauthority->createCA ("FR", "FOURNIER38", "CATEST");
$caCert = $certificationauthority->caCert ();
file_put_contents ("/tmp/test_createCA_2", $caCert);
@@ -37,7 +39,7 @@ class certificationauthorityTest extends \PHPUnit_Framework_TestCase
public function test_createPK_1 ()
{
$certificationauthority = new certificationauthority ();
$certificationauthority = new Certificationauthority ();
$privateKey = $certificationauthority->createPrivateKey () -> privateKey ();
$privateKey = explode ("\n", $privateKey);
$this->assertSame ($privateKey[0], "-----BEGIN PRIVATE KEY-----");
@@ -45,7 +47,7 @@ class certificationauthorityTest extends \PHPUnit_Framework_TestCase
public function test_createCSR_1 ()
{
$certificationauthority = new certificationauthority ();
$certificationauthority = new Certificationauthority ();
$csr = $certificationauthority->createCSR ("FR", "FOURNIER38", "CSR");
$csr = explode ("\n", $csr);
$this->assertSame ($csr[0], "-----BEGIN CERTIFICATE REQUEST-----");
@@ -53,7 +55,7 @@ class certificationauthorityTest extends \PHPUnit_Framework_TestCase
public function test_signCSR_1 ()
{
$certificationauthority = new certificationauthority ();
$certificationauthority = new Certificationauthority ();
$certificationauthority->createCA ("FR", "FOURNIER38", "CATEST");
$caCert = $certificationauthority->caCert ();
$caKey = $certificationauthority->caKey ();
@@ -65,7 +67,7 @@ class certificationauthorityTest extends \PHPUnit_Framework_TestCase
public function test_signCSR_2 ()
{
$certificationauthority = new certificationauthority ();
$certificationauthority = new Certificationauthority ();
$certificationauthority->createCA ("FR", "FOURNIER38", "CATEST");
$caCert = $certificationauthority->caCert ();
$caKey = $certificationauthority->caKey ();
@@ -82,7 +84,7 @@ class certificationauthorityTest extends \PHPUnit_Framework_TestCase
public function test_signCSR_3 ()
{
// Check if generated cert X509v3 Extended Key Usage are valid
$certificationauthority = new certificationauthority ();
$certificationauthority = new Certificationauthority ();
$certificationauthority->createCA ("FR", "FOURNIER38", "CATEST");
$caCert = $certificationauthority->caCert ();
$caKey = $certificationauthority->caKey ();
@@ -100,7 +102,7 @@ class certificationauthorityTest extends \PHPUnit_Framework_TestCase
public function test_signCSR_4 ()
{
// Check if generated cert issuer name is valid
$certificationauthority = new certificationauthority ();
$certificationauthority = new Certificationauthority ();
$certificationauthority->createCA ("FR", "FOURNIER38", "CATEST");
$caCert = $certificationauthority->caCert ();
$caKey = $certificationauthority->caKey ();
@@ -117,7 +119,7 @@ class certificationauthorityTest extends \PHPUnit_Framework_TestCase
public function test_signCSR_5 ()
{
// Check if generated cert is not tagged CA
$certificationauthority = new certificationauthority ();
$certificationauthority = new Certificationauthority ();
$certificationauthority->createCA ("FR", "FOURNIER38", "CATEST");
$caCert = $certificationauthority->caCert ();
$caKey = $certificationauthority->caKey ();
@@ -134,7 +136,7 @@ class certificationauthorityTest extends \PHPUnit_Framework_TestCase
public function test_signCSR_6 ()
{
// Check if generated cert has Alternative Names
$certificationauthority = new certificationauthority ();
$certificationauthority = new Certificationauthority ();
$certificationauthority->createCA ("FR", "FOURNIER38", "CATEST");
$caCert = $certificationauthority->caCert ();
$caKey = $certificationauthority->caKey ();
+18 -16
View File
@@ -7,8 +7,10 @@
namespace Domframework\Tests;
/** Test the config.php file */
class configTest extends \PHPUnit_Framework_TestCase
use Domframework\Config;
/** Test the Config.php file */
class ConfigTest extends \PHPUnit_Framework_TestCase
{
public function test_ExternFile ()
@@ -19,14 +21,14 @@ class configTest extends \PHPUnit_Framework_TestCase
public function test_params1 ()
{
$c = new config ();
$c = new Config ();
$res = $c->params ();
$this->assertSame (array (), $res);
}
public function testGet1 ()
{
$c = new config ();
$c = new Config ();
$c->confFile = "/tmp/testconf.php";
$c->default = array (
"database"=>array (
@@ -46,7 +48,7 @@ class configTest extends \PHPUnit_Framework_TestCase
public function testSet1 ()
{
$c = new config ();
$c = new Config ();
$c->confFile = "/tmp/testconf.php";
$c->default = array (
"database"=>array (
@@ -58,7 +60,7 @@ class configTest extends \PHPUnit_Framework_TestCase
public function testGet2 ()
{
$c = new config ();
$c = new Config ();
$c->confFile = "/tmp/testconf.php";
$c->default = array (
"database"=>array (
@@ -73,7 +75,7 @@ class configTest extends \PHPUnit_Framework_TestCase
/** Can't create file */
public function testGet3 ()
{
$c = new config ();
$c = new Config ();
$c->confFile = "/tmp/1/2.3/dd/testconf.php";
$c->default = array (
"database"=>array (
@@ -86,7 +88,7 @@ class configTest extends \PHPUnit_Framework_TestCase
/** Can't read the file */
public function testGet4 ()
{
$c = new config ();
$c = new Config ();
$c->confFile = "/tmp/testconf.php";
chmod ("/tmp/testconf.php", 0222);
$c->default = array (
@@ -100,7 +102,7 @@ class configTest extends \PHPUnit_Framework_TestCase
/** File non exists and can not be created */
public function testSet2 ()
{
$c = new config ();
$c = new Config ();
$c->confFile = "/tmp/1/2.3/dd/testconf.php";
$c->default = array (
"database"=>array (
@@ -113,7 +115,7 @@ class configTest extends \PHPUnit_Framework_TestCase
/** Can't read the file */
public function testSet3 ()
{
$c = new config ();
$c = new Config ();
$c->confFile = "/tmp/testconf.php";
chmod ("/tmp/testconf.php", 0222);
$c->default = array (
@@ -127,7 +129,7 @@ class configTest extends \PHPUnit_Framework_TestCase
/** Can't write the file */
public function testSet4 ()
{
$c = new config ();
$c = new Config ();
$c->confFile = "/tmp/testconf.php";
chmod ("/tmp/testconf.php", 0444);
$c->default = array (
@@ -141,7 +143,7 @@ class configTest extends \PHPUnit_Framework_TestCase
/** Save TRUE/FALSE/NULL/String values */
public function testSet5 ()
{
$c = new config ();
$c = new Config ();
$c->confFile = "/tmp/testconf.php";
chmod ("/tmp/testconf.php", 0666);
$c->default = array (
@@ -158,7 +160,7 @@ class configTest extends \PHPUnit_Framework_TestCase
public function testGet6 ()
{
$c = new config ();
$c = new Config ();
$c->confFile = "/tmp/testconf.php";
chmod ("/tmp/testconf.php", 0666);
$c->default = array (
@@ -183,7 +185,7 @@ class configTest extends \PHPUnit_Framework_TestCase
public function testSet7 ()
{
$c = new config ();
$c = new Config ();
$c->confFile = "/tmp/testconf.php";
chmod ("/tmp/testconf.php", 0666);
$c->default = array (
@@ -207,7 +209,7 @@ class configTest extends \PHPUnit_Framework_TestCase
}
public function testGet7 ()
{
$c = new config ();
$c = new Config ();
$c->confFile = "/tmp/testconf.php";
chmod ("/tmp/testconf.php", 0666);
$c->default = array (
@@ -233,7 +235,7 @@ class configTest extends \PHPUnit_Framework_TestCase
public function testGet8 ()
{
$c = new config ();
$c = new Config ();
$c->confFile = "/tmp/testconf.php";
chmod ("/tmp/testconf.php", 0666);
$c->default = array (
+24 -22
View File
@@ -7,60 +7,62 @@
namespace Domframework\Tests;
use Domframework\Convert;
/** Test the Conversion of format */
class convertTest extends \PHPUnit_Framework_TestCase
class ConvertTest extends \PHPUnit_Framework_TestCase
{
public function test_convertDate1 ()
{
$res = \convert::convertDate ("2017-04-13", "Y-m-d", "d/m/Y");
$res = Convert::convertDate ("2017-04-13", "Y-m-d", "d/m/Y");
$this->assertSame ($res, "13/04/2017");
}
public function test_convertDate2 ()
{
$this->setExpectedException ("Exception");
$res = \convert::convertDate ("2017-13-33", "Y-m-d", "d/m/Y");
$res = Convert::convertDate ("2017-13-33", "Y-m-d", "d/m/Y");
}
public function test_convertDate3 ()
{
$res = \convert::convertDate ("2017-13-33", "Y-m-d", "d/m/Y", false);
$res = Convert::convertDate ("2017-13-33", "Y-m-d", "d/m/Y", false);
$this->assertSame ($res, "2017-13-33");
}
public function test_ucwords_1 ()
{
$res = \convert::ucwords (" test yuyu ");
$res = Convert::ucwords (" test yuyu ");
$this->assertSame ($res, " Test Yuyu ");
}
public function test_ucwords_2 ()
{
$res = \convert::ucwords ("");
$res = Convert::ucwords ("");
$this->assertSame ($res, "");
}
public function test_ucwords_3 ()
{
$res = \convert::ucwords ("test");
$res = Convert::ucwords ("test");
$this->assertSame ($res, "Test");
}
public function test_ucwords_4 ()
{
$res = \convert::ucwords ("TEST");
$res = Convert::ucwords ("TEST");
$this->assertSame ($res, "Test");
}
public function test_ucwords_5 ()
{
$res = \convert::ucwords ("édouard étienne");
$res = Convert::ucwords ("édouard étienne");
$this->assertSame ($res, "Édouard Étienne");
}
public function test_ucwords_6 ()
{
$res = \convert::ucwords ("édou-ard d'étienne", " -'");
$res = Convert::ucwords ("édou-ard d'étienne", " -'");
$this->assertSame ($res, "Édou-Ard D'Étienne");
}
@@ -72,7 +74,7 @@ class convertTest extends \PHPUnit_Framework_TestCase
$res = "";
for ($i = -8 ; $i <= 8 ; $i++)
{
$res .= \convert::humanSize (1.441234 * pow (1000, $i), 2, 1000)."\n";
$res .= Convert::humanSize (1.441234 * pow (1000, $i), 2, 1000)."\n";
}
$this->assertSame ($res, "1.44yB\n1.44zB\n1.44aB\n1.44fB\n1.44pB\n1.44nB\n".
"1.44uB\n1.44mB\n1.44B\n1.44kB\n1.44MB\n1.44GB\n1.44TB\n1.44PB\n1.44EB\n".
@@ -81,40 +83,40 @@ class convertTest extends \PHPUnit_Framework_TestCase
public function test_humanSize_2 ()
{
$res = \convert::humanSize (1441234);
$res = Convert::humanSize (1441234);
$this->assertSame ($res, "1.44MB");
}
public function test_humanSize_3 ()
{
$res = \convert::humanSize (10441234);
$res = Convert::humanSize (10441234);
$this->assertSame ($res, "10.44MB");
}
public function test_humanSize_4 ()
{
$res = \convert::humanSize (0.123, 0);
$res = Convert::humanSize (0.123, 0);
$this->assertSame ($res, "123mB");
}
public function test_humanSize_5 ()
{
$res = \convert::humanSize (0.12345, 2);
$res = Convert::humanSize (0.12345, 2);
$this->assertSame ($res, "123.45mB");
}
public function test_humanSize_6 ()
{
$res = \convert::humanSize (-0.12345, 2);
$res = Convert::humanSize (-0.12345, 2);
$this->assertSame ($res, "-123.45mB");
}
public function test_humanSize_7 ()
{
$res = \convert::humanSize (-12345, 2);
$res = Convert::humanSize (-12345, 2);
$this->assertSame ($res, "-12.35kB");
}
public function test_humanSize_8 ()
{
$res = \convert::humanSize (0, 2);
$res = Convert::humanSize (0, 2);
$this->assertSame ($res, "0.00B");
}
@@ -123,27 +125,27 @@ class convertTest extends \PHPUnit_Framework_TestCase
{
$this->expectException ("Exception",
"convert::humanSize value not numerical : string", 500);
$res = \convert::humanSize ("1441234");
$res = Convert::humanSize ("1441234");
}
public function test_humanSize_error2 ()
{
$this->expectException ("Exception",
"convert::humanSize decimal not integer : double", 500);
$res = \convert::humanSize (1441234, 0.1);
$res = Convert::humanSize (1441234, 0.1);
}
public function test_humanSize_error3 ()
{
$this->expectException ("Exception",
"convert::humanSize decimal value negative", 500);
$res = \convert::humanSize (1441234, -1);
$res = Convert::humanSize (1441234, -1);
}
public function test_humanSize_error4 ()
{
$this->expectException ("Exception",
"convert::humanSize power value !== 1000 and 1024 : 2000", 500);
$res = \convert::humanSize (1441234, 2, 2000);
$res = Convert::humanSize (1441234, 2, 2000);
}
}
+16 -14
View File
@@ -7,12 +7,14 @@
namespace Domframework\Tests;
/** Test the csrf.php file */
class csrfTest extends \PHPUnit_Framework_TestCase
use Domframework\Csrf;
/** Test the Csrf.php file */
class CsrfTest extends \PHPUnit_Framework_TestCase
{
public function test_csrf1 ()
{
$csrf = new csrf ();
$csrf = new Csrf ();
$res = $csrf->createToken ();
$GLOBALS["CSRFTEST-Token"] = $res;
$this->assertSame (30, strlen ($res));
@@ -20,7 +22,7 @@ class csrfTest extends \PHPUnit_Framework_TestCase
public function test_csrf2 ()
{
$csrf = new csrf ();
$csrf = new Csrf ();
$res = $csrf->createToken ();
$this->assertSame (
strspn ($res,
@@ -29,14 +31,14 @@ class csrfTest extends \PHPUnit_Framework_TestCase
public function test_csrf3 ()
{
$csrf = new csrf ();
$csrf = new Csrf ();
$this->setExpectedException ("Exception");
$res = $csrf->checkToken ("NOT VALID TOKEN");
}
public function test_csrf4 ()
{
$csrf = new csrf ();
$csrf = new Csrf ();
$token = $csrf->createToken ();
$res = $csrf->checkToken ($token);
$this->assertSame (true, $res);
@@ -44,7 +46,7 @@ class csrfTest extends \PHPUnit_Framework_TestCase
public function test_csrf5 ()
{
$csrf = new csrf ();
$csrf = new Csrf ();
$token = $csrf->createToken ();
$res = $csrf->extendToken ($token);
$this->assertSame (true, $res);
@@ -52,7 +54,7 @@ class csrfTest extends \PHPUnit_Framework_TestCase
public function test_csrf6 ()
{
$csrf = new csrf ();
$csrf = new Csrf ();
$token = $csrf->createToken ();
$res = $csrf->getToken ();
$this->assertSame ($token, $res);
@@ -60,16 +62,16 @@ class csrfTest extends \PHPUnit_Framework_TestCase
public function test_csrf7 ()
{
$csrf = new csrf ();
$csrf = new Csrf ();
$res = $csrf->getToken ();
$this->assertSame (30, strlen ($res));
}
public function test_csrf_multiple_1 ()
{
$csrf1 = new csrf ();
$csrf1 = new Csrf ();
$token1 = $csrf1->createToken ();
$csrf2 = new csrf ();
$csrf2 = new Csrf ();
$token2 = $csrf2->createToken ();
$this->assertSame (true,
$csrf2->checkToken ($token1) && $csrf2->checkToken ($token2));
@@ -77,16 +79,16 @@ class csrfTest extends \PHPUnit_Framework_TestCase
public function test_csrf_multiple_extend_2 ()
{
$csrf = new csrf ();
$csrf = new Csrf ();
$res = $csrf->extendToken ($GLOBALS["CSRFTEST-Token"]);
$this->assertSame (true, $res);
}
public function test_csrf_multiple_get ()
{
$csrf1 = new csrf ();
$csrf1 = new Csrf ();
$token1 = $csrf1->createToken ();
$csrf2 = new csrf ();
$csrf2 = new Csrf ();
$token2 = $csrf2->getToken ();
$this->assertSame ($token1, $token2);
}
+39 -37
View File
@@ -7,14 +7,16 @@
namespace Domframework\Tests;
/** Test the dbjson database */
class dbjsonTest extends \PHPUnit_Framework_TestCase
use Domframework\Dbjson;
/** Test the Dbjson database */
class DbjsonTest extends \PHPUnit_Framework_TestCase
{
public function test_insertOne1 ()
{
// Document #0
define ("dbfile", "/tmp/dbjson-".time());
$dbjson = new dbjson ("dbjson://".dbfile);
$dbjson = new Dbjson ("dbjson://".dbfile);
$res = $dbjson->insertOne ("collection",
array ("key1"=>"val1", "key2"=>"val2"));
$this->assertSame ($res, 1);
@@ -23,7 +25,7 @@ class dbjsonTest extends \PHPUnit_Framework_TestCase
public function test_insertOne2 ()
{
// Document #1
$dbjson = new dbjson ("dbjson://".dbfile);
$dbjson = new Dbjson ("dbjson://".dbfile);
$res = $dbjson->insertOne ("collection",
array ("key1"=>"val1", "key2"=>"val2"));
$this->assertSame ($res, 1);
@@ -33,7 +35,7 @@ class dbjsonTest extends \PHPUnit_Framework_TestCase
{
// Error : Invalid array provided (not array of array)
$this->setExpectedException ("Exception");
$dbjson = new dbjson ("dbjson://".dbfile);
$dbjson = new Dbjson ("dbjson://".dbfile);
$res = $dbjson->insertMany ("collection",
array ("key1"=>"val1", "key2"=>"val2"));
}
@@ -41,7 +43,7 @@ class dbjsonTest extends \PHPUnit_Framework_TestCase
public function test_insertMany2 ()
{
// Document #2 and #3
$dbjson = new dbjson ("dbjson://".dbfile);
$dbjson = new Dbjson ("dbjson://".dbfile);
$res = $dbjson->insertMany ("collection",
array (array ("key1"=>"val3", "key2"=>"val2"),
array ("key1"=>"val3", "key2"=>"val4")));
@@ -51,21 +53,21 @@ class dbjsonTest extends \PHPUnit_Framework_TestCase
public function test_filter1 ()
{
// Return all the keys (filter = array ())
$dbjson = new dbjson ("dbjson://".dbfile);
$dbjson = new Dbjson ("dbjson://".dbfile);
$res = $dbjson->filter ("collection", array ());
$this->assertSame (array_keys ($res), array (0,1,2,3));
}
public function test_filter2 ()
{
// Return the keys where filter = array ("key2"=>"val2"))
$dbjson = new dbjson ("dbjson://".dbfile);
$dbjson = new Dbjson ("dbjson://".dbfile);
$res = $dbjson->filter ("collection", array ("key2"=>"val2"));
$this->assertSame (array_keys ($res), array (0,1,2));
}
public function test_filter3 ()
{
// Return the keys where filter = array ("key1"=>"val3","key2"=>"val2"))
$dbjson = new dbjson ("dbjson://".dbfile);
$dbjson = new Dbjson ("dbjson://".dbfile);
$res = $dbjson->filter ("collection", array ("key1"=>"val3",
"key2"=>"val2"));
$this->assertSame (count ($res), 1);
@@ -74,7 +76,7 @@ class dbjsonTest extends \PHPUnit_Framework_TestCase
{
// Return the keys where filter = array ("key1"=>array ("val3", "=="),
// "key2"=>array ("val2", "=="))
$dbjson = new dbjson ("dbjson://".dbfile);
$dbjson = new Dbjson ("dbjson://".dbfile);
$res = $dbjson->filter ("collection",array ("key1"=>array ("val3", "=="),
"key2"=>array ("val2", "==")));
$this->assertSame (count ($res), 1);
@@ -83,7 +85,7 @@ class dbjsonTest extends \PHPUnit_Framework_TestCase
{
// Return the keys where filter = array ("key1"=>array ("val3", "<="),
// "key2"=>array ("val2", "=="))
$dbjson = new dbjson ("dbjson://".dbfile);
$dbjson = new Dbjson ("dbjson://".dbfile);
$res = $dbjson->filter ("collection", array ("key1"=>array ("val3", "<="),
"key2"=>array ("val2", "==")));
$this->assertSame (array_keys ($res), array (0,1,2));
@@ -92,7 +94,7 @@ class dbjsonTest extends \PHPUnit_Framework_TestCase
{
// Return the keys where filter = array ("key1"=>array ("val3", "<="),
// "key2"=>array ("val2", ">"))
$dbjson = new dbjson ("dbjson://".dbfile);
$dbjson = new Dbjson ("dbjson://".dbfile);
$res = $dbjson->filter ("collection", array ("key1"=>array ("val3", "<="),
"key2"=>array ("val2", ">")));
$this->assertSame (count ($res), 1);
@@ -100,7 +102,7 @@ class dbjsonTest extends \PHPUnit_Framework_TestCase
public function test_find1 ()
{
$dbjson = new dbjson ("dbjson://".dbfile);
$dbjson = new Dbjson ("dbjson://".dbfile);
$res = $dbjson->find ("collection", array ("key1"=>array ("val3", "<="),
"key2"=>array ("val2", ">")));
$res = array_values ($res);
@@ -111,7 +113,7 @@ class dbjsonTest extends \PHPUnit_Framework_TestCase
}
public function test_find2 ()
{
$dbjson = new dbjson ("dbjson://".dbfile);
$dbjson = new Dbjson ("dbjson://".dbfile);
$res = $dbjson->find ("collection", array ("key1"=>array ("val3", "<="),
"key2"=>array ("val2", ">")),
"*");
@@ -125,14 +127,14 @@ class dbjsonTest extends \PHPUnit_Framework_TestCase
{
// Exception : fields not an array
$this->setExpectedException ("Exception");
$dbjson = new dbjson ("dbjson://".dbfile);
$dbjson = new Dbjson ("dbjson://".dbfile);
$res = $dbjson->find ("collection", array ("key1"=>array ("val3", "<="),
"key2"=>array ("val2", ">")),
"key1");
}
public function test_find4 ()
{
$dbjson = new dbjson ("dbjson://".dbfile);
$dbjson = new Dbjson ("dbjson://".dbfile);
$res = $dbjson->find ("collection", array ("key1"=>array ("val3", "<="),
"key2"=>array ("val2", ">")),
array ("key1"));
@@ -143,7 +145,7 @@ class dbjsonTest extends \PHPUnit_Framework_TestCase
}
public function test_find5 ()
{
$dbjson = new dbjson ("dbjson://".dbfile);
$dbjson = new Dbjson ("dbjson://".dbfile);
$res = $dbjson->find ("collection", array ("key1"=>array ("val3", "<="),
"key2"=>array ("val2", ">")),
array ("key1", "key2"));
@@ -155,7 +157,7 @@ class dbjsonTest extends \PHPUnit_Framework_TestCase
}
public function test_find6 ()
{
$dbjson = new dbjson ("dbjson://".dbfile);
$dbjson = new Dbjson ("dbjson://".dbfile);
$res = $dbjson->find ("collection", array ("key1"=>array ("val3", "<="),
"key2"=>array ("val2", "==")),
array ("key1", "key2"));
@@ -173,7 +175,7 @@ class dbjsonTest extends \PHPUnit_Framework_TestCase
}
public function test_find7 ()
{
$dbjson = new dbjson ("dbjson://".dbfile);
$dbjson = new Dbjson ("dbjson://".dbfile);
$res = $dbjson->find ("collection", array ("key1"=>array ("val3", "<="),
"key2"=>array ("val2", "==")),
array ("key2"));
@@ -188,7 +190,7 @@ class dbjsonTest extends \PHPUnit_Framework_TestCase
}
public function test_find8 ()
{
$dbjson = new dbjson ("dbjson://".dbfile);
$dbjson = new Dbjson ("dbjson://".dbfile);
$res = $dbjson->find ("collection", array ("key1"=>array ("val3", "<="),
"key2"=>array ("val2", "==")),
array ("key2"), 1);
@@ -200,7 +202,7 @@ class dbjsonTest extends \PHPUnit_Framework_TestCase
public function test_deleteOne1 ()
{
$dbjson = new dbjson ("dbjson://".dbfile);
$dbjson = new Dbjson ("dbjson://".dbfile);
$res = $dbjson->deleteOne ("collection",
array ("key1"=>array ("val3", "<="),
"key2"=>array ("val2", "==")));
@@ -208,7 +210,7 @@ class dbjsonTest extends \PHPUnit_Framework_TestCase
}
public function test_find9 ()
{
$dbjson = new dbjson ("dbjson://".dbfile);
$dbjson = new Dbjson ("dbjson://".dbfile);
$res = $dbjson->find ("collection", array ("key1"=>array ("val3", "<="),
"key2"=>array ("val2", "==")),
array ("key2"));
@@ -222,7 +224,7 @@ class dbjsonTest extends \PHPUnit_Framework_TestCase
public function test_deleteMany1 ()
{
$dbjson = new dbjson ("dbjson://".dbfile);
$dbjson = new Dbjson ("dbjson://".dbfile);
$res = $dbjson->deleteMany ("collection",
array ("key1"=>array ("val3", "<="),
"key2"=>array ("val2", "==")));
@@ -230,7 +232,7 @@ class dbjsonTest extends \PHPUnit_Framework_TestCase
}
public function test_find10 ()
{
$dbjson = new dbjson ("dbjson://".dbfile);
$dbjson = new Dbjson ("dbjson://".dbfile);
$res = $dbjson->find ("collection", array ("key1"=>array ("val3", "<="),
"key2"=>array ("val2", "==")),
array ("key2"));
@@ -242,7 +244,7 @@ class dbjsonTest extends \PHPUnit_Framework_TestCase
public function test_find11 ()
{
$dbjson = new dbjson ("dbjson://".dbfile);
$dbjson = new Dbjson ("dbjson://".dbfile);
$res = array_values ($dbjson->find ("collection"));
// ["_id"] is random : skip the test
unset ($res[0]["_id"]);
@@ -251,13 +253,13 @@ class dbjsonTest extends \PHPUnit_Framework_TestCase
public function test_replace1 ()
{
$dbjson = new dbjson ("dbjson://".dbfile);
$dbjson = new Dbjson ("dbjson://".dbfile);
$res = $dbjson->replace ("collection", array (), array ("key2"=>"val5"));
$this->assertSame ($res, 1);
}
public function test_find12 ()
{
$dbjson = new dbjson ("dbjson://".dbfile);
$dbjson = new Dbjson ("dbjson://".dbfile);
$res = array_values ($dbjson->find ("collection"));
// ["_id"] is random : skip the test
unset ($res[0]["_id"]);
@@ -266,14 +268,14 @@ class dbjsonTest extends \PHPUnit_Framework_TestCase
public function test_update1 ()
{
$dbjson = new dbjson ("dbjson://".dbfile);
$dbjson = new Dbjson ("dbjson://".dbfile);
$res = $dbjson->update ("collection", array (), array ("key2"=>"val6",
"key5"=>"val5"));
$this->assertSame ($res, 1);
}
public function test_find13 ()
{
$dbjson = new dbjson ("dbjson://".dbfile);
$dbjson = new Dbjson ("dbjson://".dbfile);
$res = array_values ($dbjson->find ("collection"));
// ["_id"] is random : skip the test
unset ($res[0]["_id"]);
@@ -283,14 +285,14 @@ class dbjsonTest extends \PHPUnit_Framework_TestCase
public function test_insertOne3 ()
{
// Document #4
$dbjson = new dbjson ("dbjson://".dbfile);
$dbjson = new Dbjson ("dbjson://".dbfile);
$res = $dbjson->insertOne ("collection",
array ("key1"=>"val1", "key2"=>"val2"));
$this->assertSame ($res, 1);
}
public function test_find14 ()
{
$dbjson = new dbjson ("dbjson://".dbfile);
$dbjson = new Dbjson ("dbjson://".dbfile);
$res = array_values ($dbjson->find ("collection"));
// ["_id"] is random : skip the test
unset ($res[0]["_id"]);
@@ -303,14 +305,14 @@ class dbjsonTest extends \PHPUnit_Framework_TestCase
public function test_update2 ()
{
$dbjson = new dbjson ("dbjson://".dbfile);
$dbjson = new Dbjson ("dbjson://".dbfile);
$res = $dbjson->update ("collection", array (), array ("key2"=>"val7",
"key5"=>"val8"));
$this->assertSame ($res, 2);
}
public function test_find15 ()
{
$dbjson = new dbjson ("dbjson://".dbfile);
$dbjson = new Dbjson ("dbjson://".dbfile);
$res = array_values ($dbjson->find ("collection"));
// ["_id"] is random : skip the test
unset ($res[0]["_id"]);
@@ -324,7 +326,7 @@ class dbjsonTest extends \PHPUnit_Framework_TestCase
public function test_update3 ()
{
$dbjson = new dbjson ("dbjson://".dbfile);
$dbjson = new Dbjson ("dbjson://".dbfile);
$res = $dbjson->update ("collection", array (),
array ("key2"=>"val9",
"key5"=>"val7",
@@ -333,7 +335,7 @@ class dbjsonTest extends \PHPUnit_Framework_TestCase
}
public function test_find16 ()
{
$dbjson = new dbjson ("dbjson://".dbfile);
$dbjson = new Dbjson ("dbjson://".dbfile);
$res = array_values ($dbjson->find ("collection"));
// ["_id"] is random : skip the test
unset ($res[0]["_id"]);
@@ -346,8 +348,8 @@ class dbjsonTest extends \PHPUnit_Framework_TestCase
// Concurrency tests
public function test_concurrency1 ()
{
$dbjson1 = new dbjson ("dbjson://".dbfile);
$dbjson2 = new dbjson ("dbjson://".dbfile);
$dbjson1 = new Dbjson ("dbjson://".dbfile);
$dbjson2 = new Dbjson ("dbjson://".dbfile);
$dbjson1->insertOne ("collection",
array ("key1"=>"val1", "key2"=>"val2"));
$res = array_values ($dbjson2->find ("collection"));
+22 -20
View File
@@ -7,7 +7,9 @@
namespace Domframework\Tests;
class dblayerTest{ENGINE} extends PHPUnit_Framework_TestCase
use Domframework\Dblayer;
class DblayerTest{ENGINE} extends \PHPUnit_Framework_TestCase
{
// Test with column name 'group', 'object', 'where', 'with space'
// Test with table name 'group', 'object', 'where', 'with space'
@@ -42,7 +44,7 @@ class dblayerTest{ENGINE} extends PHPUnit_Framework_TestCase
public function test_dropTable ()
{
$dbconfig = $this->confs["{ENGINE}"];
$db = new dblayer ($dbconfig["dsn"], $dbconfig["username"],
$db = new Dblayer ($dbconfig["dsn"], $dbconfig["username"],
$dbconfig["password"], $dbconfig["driver_options"]);
foreach (array ("users", "grouped", "multiple", "multiple2", "users3",
"readOR") as
@@ -53,7 +55,7 @@ class dblayerTest{ENGINE} extends PHPUnit_Framework_TestCase
{
$res = $db->dropTable();
}
catch (Exception $e)
catch (\Exception $e)
{
}
}
@@ -67,7 +69,7 @@ class dblayerTest{ENGINE} extends PHPUnit_Framework_TestCase
{
// Create a table named grouped
$dbconfig = $this->confs["{ENGINE}"];
$db = new dblayer ($dbconfig["dsn"], $dbconfig["username"],
$db = new Dblayer ($dbconfig["dsn"], $dbconfig["username"],
$dbconfig["password"], $dbconfig["driver_options"]);
$db->table = "grouped";
$db->fields = array ("group"=>array ("varchar", "255", "not null"),
@@ -85,7 +87,7 @@ class dblayerTest{ENGINE} extends PHPUnit_Framework_TestCase
public function test_insert1 ()
{
$dbconfig = $this->confs["{ENGINE}"];
$db = new dblayer ($dbconfig["dsn"], $dbconfig["username"],
$db = new Dblayer ($dbconfig["dsn"], $dbconfig["username"],
$dbconfig["password"], $dbconfig["driver_options"]);
$db->table = "grouped";
$db->fields = array ("group"=>array ("varchar", "255", "not null"),
@@ -105,7 +107,7 @@ class dblayerTest{ENGINE} extends PHPUnit_Framework_TestCase
public function test_read1 ()
{
$dbconfig = $this->confs["{ENGINE}"];
$db = new dblayer ($dbconfig["dsn"], $dbconfig["username"],
$db = new Dblayer ($dbconfig["dsn"], $dbconfig["username"],
$dbconfig["password"], $dbconfig["driver_options"]);
$db->table = "grouped";
$db->fields = array ("group"=>array ("varchar", "255", "not null"),
@@ -126,7 +128,7 @@ class dblayerTest{ENGINE} extends PHPUnit_Framework_TestCase
public function test_update1 ()
{
$dbconfig = $this->confs["{ENGINE}"];
$db = new dblayer ($dbconfig["dsn"], $dbconfig["username"],
$db = new Dblayer ($dbconfig["dsn"], $dbconfig["username"],
$dbconfig["password"], $dbconfig["driver_options"]);
$db->table = "grouped";
$db->fields = array ("group"=>array ("varchar", "255", "not null"),
@@ -144,7 +146,7 @@ class dblayerTest{ENGINE} extends PHPUnit_Framework_TestCase
public function test_read2 ()
{
$dbconfig = $this->confs["{ENGINE}"];
$db = new dblayer ($dbconfig["dsn"], $dbconfig["username"],
$db = new Dblayer ($dbconfig["dsn"], $dbconfig["username"],
$dbconfig["password"], $dbconfig["driver_options"]);
$db->table = "grouped";
$db->fields = array ("group"=>array ("varchar", "255", "not null"),
@@ -165,7 +167,7 @@ class dblayerTest{ENGINE} extends PHPUnit_Framework_TestCase
public function test_update2 ()
{
$dbconfig = $this->confs["{ENGINE}"];
$db = new dblayer ($dbconfig["dsn"], $dbconfig["username"],
$db = new Dblayer ($dbconfig["dsn"], $dbconfig["username"],
$dbconfig["password"], $dbconfig["driver_options"]);
$db->table = "grouped";
$db->fields = array ("group"=>array ("varchar", "255", "not null"),
@@ -184,7 +186,7 @@ class dblayerTest{ENGINE} extends PHPUnit_Framework_TestCase
public function test_read3 ()
{
$dbconfig = $this->confs["{ENGINE}"];
$db = new dblayer ($dbconfig["dsn"], $dbconfig["username"],
$db = new Dblayer ($dbconfig["dsn"], $dbconfig["username"],
$dbconfig["password"], $dbconfig["driver_options"]);
$db->table = "grouped";
$db->fields = array ("group"=>array ("varchar", "255", "not null"),
@@ -205,7 +207,7 @@ class dblayerTest{ENGINE} extends PHPUnit_Framework_TestCase
public function test_update3 ()
{
$dbconfig = $this->confs["{ENGINE}"];
$db = new dblayer ($dbconfig["dsn"], $dbconfig["username"],
$db = new Dblayer ($dbconfig["dsn"], $dbconfig["username"],
$dbconfig["password"], $dbconfig["driver_options"]);
$db->table = "grouped";
$db->fields = array ("group"=>array ("varchar", "255", "not null"),
@@ -233,10 +235,10 @@ class dblayerTest{ENGINE} extends PHPUnit_Framework_TestCase
{
// Create a table named group
$dbconfig = $this->confs["{ENGINE}"];
$db = new dblayer ($dbconfig["dsn"], $dbconfig["username"],
$db = new Dblayer ($dbconfig["dsn"], $dbconfig["username"],
$dbconfig["password"], $dbconfig["driver_options"]);
$db->disconnect ();
$db = new dblayer ($dbconfig["dsn"], $dbconfig["username"],
$db = new Dblayer ($dbconfig["dsn"], $dbconfig["username"],
$dbconfig["password"], $dbconfig["driver_options"]);
$db->table = "users";
$db->fields = array ("user"=>array ("varchar", "255", "not null"),
@@ -254,7 +256,7 @@ class dblayerTest{ENGINE} extends PHPUnit_Framework_TestCase
public function test_insert2 ()
{
$dbconfig = $this->confs["{ENGINE}"];
$db = new dblayer ($dbconfig["dsn"], $dbconfig["username"],
$db = new Dblayer ($dbconfig["dsn"], $dbconfig["username"],
$dbconfig["password"], $dbconfig["driver_options"]);
$db->table = "users";
$db->fields = array ("user"=>array ("varchar", "255", "not null"),
@@ -279,7 +281,7 @@ class dblayerTest{ENGINE} extends PHPUnit_Framework_TestCase
public function test_insert3 ()
{
$dbconfig = $this->confs["{ENGINE}"];
$db = new dblayer ($dbconfig["dsn"], $dbconfig["username"],
$db = new Dblayer ($dbconfig["dsn"], $dbconfig["username"],
$dbconfig["password"], $dbconfig["driver_options"]);
$db->table = "users";
$db->fields = array ("user"=>array ("varchar", "255", "not null"),
@@ -302,7 +304,7 @@ class dblayerTest{ENGINE} extends PHPUnit_Framework_TestCase
public function test_insert4 ()
{
$dbconfig = $this->confs["{ENGINE}"];
$db = new dblayer ($dbconfig["dsn"], $dbconfig["username"],
$db = new Dblayer ($dbconfig["dsn"], $dbconfig["username"],
$dbconfig["password"], $dbconfig["driver_options"]);
$db->table = "users";
$db->fields = array ("user"=>array ("varchar", "255", "not null"),
@@ -329,7 +331,7 @@ class dblayerTest{ENGINE} extends PHPUnit_Framework_TestCase
// Create a table named group
$dbconfig = $this->confs["{ENGINE}"];
$db = new dblayer ($dbconfig["dsn"], $dbconfig["username"],
$db = new Dblayer ($dbconfig["dsn"], $dbconfig["username"],
$dbconfig["password"], $dbconfig["driver_options"]);
$db->table = "multiple";
$db->fields = array ("user"=>array ("varchar", "255", "not null"),
@@ -337,7 +339,7 @@ class dblayerTest{ENGINE} extends PHPUnit_Framework_TestCase
"where"=>array ("varchar", "255", "not null"),
"with space"=>array ("varchar", "255", "not null"));
$db->createTable ();
$db2 = new dblayer ($dbconfig["dsn"], $dbconfig["username"],
$db2 = new Dblayer ($dbconfig["dsn"], $dbconfig["username"],
$dbconfig["password"], $dbconfig["driver_options"]);
$db2->table = "multiple2";
$db2->fields = array ("user"=>array ("varchar", "255", "not null"),
@@ -356,7 +358,7 @@ class dblayerTest{ENGINE} extends PHPUnit_Framework_TestCase
{
// Create a table named group
$dbconfig = $this->confs["{ENGINE}"];
$db = new dblayer ($dbconfig["dsn"], $dbconfig["username"],
$db = new Dblayer ($dbconfig["dsn"], $dbconfig["username"],
$dbconfig["password"], $dbconfig["driver_options"]);
$db->table = "users3";
$db->fields = array ("user"=>array ("varchar", "255", "not null"),
@@ -372,7 +374,7 @@ class dblayerTest{ENGINE} extends PHPUnit_Framework_TestCase
public function test_readOR1 ()
{
$dbconfig = $this->confs["{ENGINE}"];
$db = new dblayer ($dbconfig["dsn"], $dbconfig["username"],
$db = new Dblayer ($dbconfig["dsn"], $dbconfig["username"],
$dbconfig["password"], $dbconfig["driver_options"]);
$db->table = "readOR";
$db->fields = array ("id"=>array ("integer"),
+32 -29
View File
@@ -7,7 +7,10 @@
namespace Domframework\Tests;
class dblayerauthzgroupsTest extends \PHPUnit_Framework_TestCase
use Domframework\Dblayerauthzgroups;
use Domframework\Authzgroups;
class DblayerauthzgroupsTest extends \PHPUnit_Framework_TestCase
{
public $confs = array (
"sqlite" => array (
@@ -27,7 +30,7 @@ class dblayerauthzgroupsTest extends \PHPUnit_Framework_TestCase
public function test_createTablesAuthzgroups ()
{
$dbconfig = $this->confs["sqlite"];
$a = new authzgroups ();
$a = new Authzgroups ();
$a->connect ($dbconfig["dsn"], $dbconfig["username"],
$dbconfig["password"], $dbconfig["driver_options"]);
$a->createTables ();
@@ -48,11 +51,11 @@ class dblayerauthzgroupsTest extends \PHPUnit_Framework_TestCase
public function test_createTable ()
{
$dbconfig = $this->confs["sqlite"];
$n = new dblayerauthzgroups ($dbconfig["dsn"], $dbconfig["username"],
$n = new Dblayerauthzgroups ($dbconfig["dsn"], $dbconfig["username"],
$dbconfig["password"],
$dbconfig["driver_options"]);
$n->disconnect ();
$n = new dblayerauthzgroups ($dbconfig["dsn"], $dbconfig["username"],
$n = new Dblayerauthzgroups ($dbconfig["dsn"], $dbconfig["username"],
$dbconfig["password"],
$dbconfig["driver_options"]);
$n->tableSet ("dns zones")
@@ -73,10 +76,10 @@ class dblayerauthzgroupsTest extends \PHPUnit_Framework_TestCase
public function test_insert1 ()
{
$dbconfig = $this->confs["sqlite"];
$a = new authzgroups ();
$a = new Authzgroups ();
$a->connect ($dbconfig["dsn"], $dbconfig["username"],
$dbconfig["password"], $dbconfig["driver_options"]);
$n = new dblayerauthzgroups ($dbconfig["dsn"], $dbconfig["username"],
$n = new Dblayerauthzgroups ($dbconfig["dsn"], $dbconfig["username"],
$dbconfig["password"],
$dbconfig["driver_options"]);
$n->tableSet ("dns zones")
@@ -105,7 +108,7 @@ class dblayerauthzgroupsTest extends \PHPUnit_Framework_TestCase
public function test_addAuthzgroups ()
{
$dbconfig = $this->confs["sqlite"];
$a = new authzgroups ();
$a = new Authzgroups ();
$a->connect ($dbconfig["dsn"], $dbconfig["username"],
$dbconfig["password"], $dbconfig["driver_options"]);
$res = $a->allow ("modTest", "user", "/article/base/poub/1");
@@ -115,10 +118,10 @@ class dblayerauthzgroupsTest extends \PHPUnit_Framework_TestCase
public function test_insert2 ()
{
$dbconfig = $this->confs["sqlite"];
$a = new authzgroups ();
$a = new Authzgroups ();
$a->connect ($dbconfig["dsn"], $dbconfig["username"],
$dbconfig["password"], $dbconfig["driver_options"]);
$n = new dblayerauthzgroups ($dbconfig["dsn"], $dbconfig["username"],
$n = new Dblayerauthzgroups ($dbconfig["dsn"], $dbconfig["username"],
$dbconfig["password"],
$dbconfig["driver_options"]);
$n->tableSet ("dns zones")
@@ -150,10 +153,10 @@ class dblayerauthzgroupsTest extends \PHPUnit_Framework_TestCase
public function test_read1 ()
{
$dbconfig = $this->confs["sqlite"];
$a = new authzgroups ();
$a = new Authzgroups ();
$a->connect ($dbconfig["dsn"], $dbconfig["username"],
$dbconfig["password"], $dbconfig["driver_options"]);
$n = new dblayerauthzgroups ($dbconfig["dsn"], $dbconfig["username"],
$n = new Dblayerauthzgroups ($dbconfig["dsn"], $dbconfig["username"],
$dbconfig["password"],
$dbconfig["driver_options"]);
$n->tableSet ("dns zones")
@@ -181,7 +184,7 @@ class dblayerauthzgroupsTest extends \PHPUnit_Framework_TestCase
public function test_rightDel ()
{
$dbconfig = $this->confs["sqlite"];
$a = new authzgroups ();
$a = new Authzgroups ();
$a->connect ($dbconfig["dsn"], $dbconfig["username"],
$dbconfig["password"], $dbconfig["driver_options"]);
$a->rightDel ("modTest", "group", "/article/base/poub/2");
@@ -194,10 +197,10 @@ class dblayerauthzgroupsTest extends \PHPUnit_Framework_TestCase
public function test_read2 ()
{
$dbconfig = $this->confs["sqlite"];
$a = new authzgroups ();
$a = new Authzgroups ();
$a->connect ($dbconfig["dsn"], $dbconfig["username"],
$dbconfig["password"], $dbconfig["driver_options"]);
$n = new dblayerauthzgroups ($dbconfig["dsn"], $dbconfig["username"],
$n = new Dblayerauthzgroups ($dbconfig["dsn"], $dbconfig["username"],
$dbconfig["password"],
$dbconfig["driver_options"]);
$n->tableSet ("dns zones")
@@ -225,10 +228,10 @@ class dblayerauthzgroupsTest extends \PHPUnit_Framework_TestCase
public function test_delEntry1 ()
{
$dbconfig = $this->confs["sqlite"];
$a = new authzgroups ();
$a = new Authzgroups ();
$a->connect ($dbconfig["dsn"], $dbconfig["username"],
$dbconfig["password"], $dbconfig["driver_options"]);
$n = new dblayerauthzgroups ($dbconfig["dsn"], $dbconfig["username"],
$n = new Dblayerauthzgroups ($dbconfig["dsn"], $dbconfig["username"],
$dbconfig["password"],
$dbconfig["driver_options"]);
$n->tableSet ("dns zones")
@@ -255,7 +258,7 @@ class dblayerauthzgroupsTest extends \PHPUnit_Framework_TestCase
public function test_rightRO ()
{
$dbconfig = $this->confs["sqlite"];
$a = new authzgroups ();
$a = new Authzgroups ();
$a->connect ($dbconfig["dsn"], $dbconfig["username"],
$dbconfig["password"], $dbconfig["driver_options"]);
$res = $a->rightUpdate ("modTest", "group", "/article/base/poub/1", "RO");
@@ -267,10 +270,10 @@ class dblayerauthzgroupsTest extends \PHPUnit_Framework_TestCase
public function test_updateEntry2 ()
{
$dbconfig = $this->confs["sqlite"];
$a = new authzgroups ();
$a = new Authzgroups ();
$a->connect ($dbconfig["dsn"], $dbconfig["username"],
$dbconfig["password"], $dbconfig["driver_options"]);
$n = new dblayerauthzgroups ($dbconfig["dsn"], $dbconfig["username"],
$n = new Dblayerauthzgroups ($dbconfig["dsn"], $dbconfig["username"],
$dbconfig["password"],
$dbconfig["driver_options"]);
$n->tableSet ("dns zones")
@@ -297,10 +300,10 @@ class dblayerauthzgroupsTest extends \PHPUnit_Framework_TestCase
public function test_delEntry2 ()
{
$dbconfig = $this->confs["sqlite"];
$a = new authzgroups ();
$a = new Authzgroups ();
$a->connect ($dbconfig["dsn"], $dbconfig["username"],
$dbconfig["password"], $dbconfig["driver_options"]);
$n = new dblayerauthzgroups ($dbconfig["dsn"], $dbconfig["username"],
$n = new Dblayerauthzgroups ($dbconfig["dsn"], $dbconfig["username"],
$dbconfig["password"],
$dbconfig["driver_options"]);
$n->tableSet ("dns zones")
@@ -327,7 +330,7 @@ class dblayerauthzgroupsTest extends \PHPUnit_Framework_TestCase
public function test_rightRW ()
{
$dbconfig = $this->confs["sqlite"];
$a = new authzgroups ();
$a = new Authzgroups ();
$a->connect ($dbconfig["dsn"], $dbconfig["username"],
$dbconfig["password"], $dbconfig["driver_options"]);
$res = $a->rightUpdate ("modTest", "group", "/article/base/poub/1", "RW");
@@ -339,10 +342,10 @@ class dblayerauthzgroupsTest extends \PHPUnit_Framework_TestCase
public function test_updateEntry3 ()
{
$dbconfig = $this->confs["sqlite"];
$a = new authzgroups ();
$a = new Authzgroups ();
$a->connect ($dbconfig["dsn"], $dbconfig["username"],
$dbconfig["password"], $dbconfig["driver_options"]);
$n = new dblayerauthzgroups ($dbconfig["dsn"], $dbconfig["username"],
$n = new Dblayerauthzgroups ($dbconfig["dsn"], $dbconfig["username"],
$dbconfig["password"],
$dbconfig["driver_options"]);
$n->tableSet ("dns zones")
@@ -369,10 +372,10 @@ class dblayerauthzgroupsTest extends \PHPUnit_Framework_TestCase
public function test_delEntry3 ()
{
$dbconfig = $this->confs["sqlite"];
$a = new authzgroups ();
$a = new Authzgroups ();
$a->connect ($dbconfig["dsn"], $dbconfig["username"],
$dbconfig["password"], $dbconfig["driver_options"]);
$n = new dblayerauthzgroups ($dbconfig["dsn"], $dbconfig["username"],
$n = new Dblayerauthzgroups ($dbconfig["dsn"], $dbconfig["username"],
$dbconfig["password"],
$dbconfig["driver_options"]);
$n->tableSet ("dns zones")
@@ -399,7 +402,7 @@ class dblayerauthzgroupsTest extends \PHPUnit_Framework_TestCase
public function test_delAuthzgroups ()
{
$dbconfig = $this->confs["sqlite"];
$a = new authzgroups ();
$a = new Authzgroups ();
$a->connect ($dbconfig["dsn"], $dbconfig["username"],
$dbconfig["password"], $dbconfig["driver_options"]);
$res = $a->objectRead ("modTest", "/article/base/poub/1");
@@ -411,10 +414,10 @@ class dblayerauthzgroupsTest extends \PHPUnit_Framework_TestCase
public function test_read3 ()
{
$dbconfig = $this->confs["sqlite"];
$a = new authzgroups ();
$a = new Authzgroups ();
$a->connect ($dbconfig["dsn"], $dbconfig["username"],
$dbconfig["password"], $dbconfig["driver_options"]);
$n = new dblayerauthzgroups ($dbconfig["dsn"], $dbconfig["username"],
$n = new Dblayerauthzgroups ($dbconfig["dsn"], $dbconfig["username"],
$dbconfig["password"],
$dbconfig["driver_options"]);
$n->tableSet ("dns zones")
+9 -7
View File
@@ -7,7 +7,9 @@
namespace Domframework\Tests;
class dblayerooTest{ENGINE} extends PHPUnit_Framework_TestCase
use Domframework\Dblayeroo;
class DblayerooTest{ENGINE} extends \PHPUnit_Framework_TestCase
{
// Test with column name 'group', 'object', 'where', 'with space'
// Test with table name 'group', 'object', 'where', 'with space'
@@ -41,7 +43,7 @@ class dblayerooTest{ENGINE} extends PHPUnit_Framework_TestCase
private function tbl1 ()
{
$dbconfig = $this->confs["{ENGINE}"];
$tbl1 = new dblayeroo ($dbconfig["dsn"], $dbconfig["username"],
$tbl1 = new Dblayeroo ($dbconfig["dsn"], $dbconfig["username"],
$dbconfig["password"], $dbconfig["driver_options"]);
$tbl1->table ("groupedoo");
$tbl1->fields (array ("group"=>array ("varchar(255)", "not null"),
@@ -57,7 +59,7 @@ class dblayerooTest{ENGINE} extends PHPUnit_Framework_TestCase
private function tbl2 ()
{
$dbconfig = $this->confs["{ENGINE}"];
$tbl2 = new dblayeroo ($dbconfig["dsn"], $dbconfig["username"],
$tbl2 = new Dblayeroo ($dbconfig["dsn"], $dbconfig["username"],
$dbconfig["password"], $dbconfig["driver_options"]);
$tbl2->table ("usersoo");
$tbl2->fields (array ("uid"=>array ("integer", "not null", "autoincrement"),
@@ -75,7 +77,7 @@ class dblayerooTest{ENGINE} extends PHPUnit_Framework_TestCase
private function tbl3 ()
{
$dbconfig = $this->confs["{ENGINE}"];
$tbl3 = new dblayeroo ($dbconfig["dsn"], $dbconfig["username"],
$tbl3 = new Dblayeroo ($dbconfig["dsn"], $dbconfig["username"],
$dbconfig["password"], $dbconfig["driver_options"]);
return $tbl3;
}
@@ -83,7 +85,7 @@ class dblayerooTest{ENGINE} extends PHPUnit_Framework_TestCase
private function tbl4 ()
{
$dbconfig = $this->confs["{ENGINE}"];
$tbl4 = new dblayeroo ($dbconfig["dsn"], $dbconfig["username"],
$tbl4 = new Dblayeroo ($dbconfig["dsn"], $dbconfig["username"],
$dbconfig["password"], $dbconfig["driver_options"]);
$tbl4->table ("rightsoo");
$tbl4->fields (array ("id"=>array ("integer", "not null", "autoincrement"),
@@ -100,7 +102,7 @@ class dblayerooTest{ENGINE} extends PHPUnit_Framework_TestCase
public function test_dropTable ()
{
$dbconfig = $this->confs["{ENGINE}"];
$db = new dblayeroo ($dbconfig["dsn"], $dbconfig["username"],
$db = new Dblayeroo ($dbconfig["dsn"], $dbconfig["username"],
$dbconfig["password"], $dbconfig["driver_options"]);
foreach (array ("rightsoo", "usersoo", "groupedoo",
"multipleoo", "multiple2oo", "users3oo",
@@ -112,7 +114,7 @@ class dblayerooTest{ENGINE} extends PHPUnit_Framework_TestCase
{
$res = $db->dropTable();
}
catch (Exception $e)
catch (\Exception $e)
{
}
}
+18 -14
View File
@@ -4,14 +4,18 @@
* @author Dominique Fournier <dominique@fournier38.fr>
*/
/** Test the encrypt.php file */
class encryptTest extends \PHPUnit_Framework_TestCase
namespace Domframework\Tests;
use Domframework\Encrypt;
/** Test the Encrypt.php file */
class EncryptTest extends \PHPUnit_Framework_TestCase
{
/** Check the length of the otken with cipher
*/
public function testEncrypt1 ()
{
$encrypt = new encrypt ();
$encrypt = new Encrypt ();
$res = $encrypt->encrypt ("TextToEncode",
"123456789012345678901234");
$this->assertSame (strlen ($res), 24);
@@ -21,7 +25,7 @@ class encryptTest extends \PHPUnit_Framework_TestCase
*/
public function testEncrypt2 ()
{
$encrypt = new encrypt ();
$encrypt = new Encrypt ();
$payload = "TextToEncode";
$ckey = "123456789012345678901234";
$token = $encrypt->encrypt ($payload, $ckey);
@@ -33,7 +37,7 @@ class encryptTest extends \PHPUnit_Framework_TestCase
*/
public function testEncrypt3 ()
{
$encrypt = new encrypt ();
$encrypt = new Encrypt ();
$payload = "TextToEncode";
$token = $encrypt->encrypt ($payload, "123456789012345678901234");
$res = strpos ($token, "Text");
@@ -47,7 +51,7 @@ class encryptTest extends \PHPUnit_Framework_TestCase
$this->expectException ("Exception",
"Invalid cipher provided to encrypt method : doesn't exists in OpenSSL",
500);
$encrypt = new encrypt ();
$encrypt = new Encrypt ();
$payload = "TextToEncode";
$token = $encrypt->encrypt ($payload, "123456789012345678901234", "TOTO");
}
@@ -59,7 +63,7 @@ class encryptTest extends \PHPUnit_Framework_TestCase
$this->expectException ("Exception",
"Invalid payload provided to encrypt method : Not a string",
500);
$encrypt = new encrypt ();
$encrypt = new Encrypt ();
$payload = array ("Invalid");
$token = $encrypt->encrypt ($payload, "123456789012345678901234");
}
@@ -71,7 +75,7 @@ class encryptTest extends \PHPUnit_Framework_TestCase
$this->expectException ("Exception",
"Invalid cipherKey provided to encrypt method : ".
"length different of 24 chars", 500);
$encrypt = new encrypt ();
$encrypt = new Encrypt ();
$payload = "Payload";
$token = $encrypt->encrypt ($payload, "124");
}
@@ -83,7 +87,7 @@ class encryptTest extends \PHPUnit_Framework_TestCase
$this->expectException ("Exception",
"Invalid cipherKey provided to decrypt method : ".
"length different of 24 chars", 500);
$encrypt = new encrypt ();
$encrypt = new Encrypt ();
$token = $encrypt->decrypt ("zfz", "124");
}
@@ -93,7 +97,7 @@ class encryptTest extends \PHPUnit_Framework_TestCase
{
$this->expectException ("Exception",
"Invalid ciphertext provided to decrypt method : empty string", 500);
$encrypt = new encrypt ();
$encrypt = new Encrypt ();
$token = $encrypt->decrypt ("", "124");
}
@@ -103,7 +107,7 @@ class encryptTest extends \PHPUnit_Framework_TestCase
{
$this->expectException ("Exception",
"Invalid ciphertext provided to decrypt method : not a string", 500);
$encrypt = new encrypt ();
$encrypt = new Encrypt ();
$token = $encrypt->decrypt (array (), "124");
}
@@ -113,7 +117,7 @@ class encryptTest extends \PHPUnit_Framework_TestCase
{
$this->expectException ("Exception",
"Invalid cipherkey provided to decrypt method : not a string", 500);
$encrypt = new encrypt ();
$encrypt = new Encrypt ();
$token = $encrypt->decrypt ("1224", array ());
}
@@ -123,7 +127,7 @@ class encryptTest extends \PHPUnit_Framework_TestCase
{
$this->expectException ("Exception",
"Invalid cipherMethod provided to decrypt method : not a string", 500);
$encrypt = new encrypt ();
$encrypt = new Encrypt ();
$token = $encrypt->decrypt ("1224", "1234", array ());
}
@@ -134,7 +138,7 @@ class encryptTest extends \PHPUnit_Framework_TestCase
$this->expectException ("Exception",
"Invalid cipherMethod provided to decrypt method : ".
"doesn't exists in OpenSSL", 500);
$encrypt = new encrypt ();
$encrypt = new Encrypt ();
$token = $encrypt->decrypt ("1224", "1234", "unknown");
}
}
+81 -68
View File
@@ -1,10 +1,16 @@
<?php
/** DomFramework
@package domframework
@author Dominique Fournier <dominique@fournier38.fr> */
/** DomFramework - Tests
* @package domframework
* @author Dominique Fournier <dominique@fournier38.fr>
* @license BSD
*/
/** Test the domframework file part */
class fileTest extends \PHPUnit_Framework_TestCase
namespace Domframework\Tests;
use Domframework\File;
/** Test the domframework File part */
class FileTest extends \PHPUnit_Framework_TestCase
{
public function testinit ()
{
@@ -13,56 +19,56 @@ class fileTest extends \PHPUnit_Framework_TestCase
public function testRealPath01 ()
{
$file = new file ();
$file = new File ();
$res = $file->realpath ("/tmp");
$this->assertSame($res, "/tmp");
}
public function testRealPath02 ()
{
$file = new file ();
$file = new File ();
$res = $file->realpath ("////tmp");
$this->assertSame($res, "/tmp");
}
public function testRealPath03 ()
{
$file = new file ();
$file = new File ();
$res = $file->realpath ("////tmp////");
$this->assertSame($res, "/tmp");
}
public function testRealPath04 ()
{
$file = new file ();
$file = new File ();
$res = $file->realpath (".////tmp////");
$this->assertSame($res, "./tmp");
}
public function testRealPath05 ()
{
$file = new file ();
$file = new File ();
$res = $file->realpath ("../../../../../tmp/file");
$this->assertSame($res, "/tmp/file");
}
public function testRealPath06 ()
{
$file = new file ();
$file = new File ();
$res = $file->realpath ("../../../../../tmp/file/../../../..");
$this->assertSame($res, "/");
}
public function testRealPath07 ()
{
$file = new file ();
$file = new File ();
$res = $file->realpath (".././././../tmp/file/../././..");
$this->assertSame($res, "/");
}
public function testRealPath11 ()
{
$file = new file ();
$file = new File ();
$file->chroot ("/tmp");
$res = $file->realpath ("/tmp2");
$this->assertSame($res, "/tmp/tmp2");
@@ -70,7 +76,7 @@ class fileTest extends \PHPUnit_Framework_TestCase
public function testRealPath12 ()
{
$file = new file ();
$file = new File ();
$file->chroot ("/tmp");
$res = $file->realpath ("////tmp2");
$this->assertSame($res, "/tmp/tmp2");
@@ -78,7 +84,7 @@ class fileTest extends \PHPUnit_Framework_TestCase
public function testRealPath13 ()
{
$file = new file ();
$file = new File ();
$file->chroot ("/tmp");
$res = $file->realpath ("////tmp2////");
$this->assertSame($res, "/tmp/tmp2");
@@ -86,7 +92,7 @@ class fileTest extends \PHPUnit_Framework_TestCase
public function testRealPath14 ()
{
$file = new file ();
$file = new File ();
$file->chroot ("/tmp");
$res = $file->realpath (".////tmp2////");
$this->assertSame($res, "/tmp/tmp2");
@@ -94,7 +100,7 @@ class fileTest extends \PHPUnit_Framework_TestCase
public function testRealPath15 ()
{
$file = new file ();
$file = new File ();
$file->chroot ("/tmp");
$res = $file->realpath ("../../../../../tmp2/file");
$this->assertSame($res, "/tmp/tmp2/file");
@@ -102,7 +108,7 @@ class fileTest extends \PHPUnit_Framework_TestCase
public function testRealPath16 ()
{
$file = new file ();
$file = new File ();
$file->chroot ("/tmp");
$res = $file->realpath ("../../../../../tmp2/file/../../../..");
$this->assertSame($res, "/tmp");
@@ -110,7 +116,7 @@ class fileTest extends \PHPUnit_Framework_TestCase
public function testRealPath17 ()
{
$file = new file ();
$file = new File ();
$file->chroot ("/tmp");
$res = $file->realpath (".././././../tmp2/file/../././..");
$this->assertSame($res, "/tmp");
@@ -119,14 +125,14 @@ class fileTest extends \PHPUnit_Framework_TestCase
public function testGetcwd1 ()
{
$file = new file ();
$file = new File ();
$res = $file->getcwd ();
$this->assertSame($res, ".");
}
public function testGetcwd2 ()
{
$file = new file ();
$file = new File ();
$file->chdir ("/tmp");
$res = $file->getcwd ();
$this->assertSame($res, "/tmp");
@@ -135,13 +141,13 @@ class fileTest extends \PHPUnit_Framework_TestCase
public function testGetcwd3 ()
{
$this->setExpectedException ("Exception", "Path '/NON EXISTS' not found");
$file = new file ();
$file = new File ();
$file->chdir ("/NON EXISTS");
$res = $file->getcwd ();
}
public function testGetcwd4 ()
{
$file = new file ();
$file = new File ();
$file->chdir ("/../../../tmp");
$res = $file->getcwd ();
$this->assertSame($res, "/tmp");
@@ -149,7 +155,7 @@ class fileTest extends \PHPUnit_Framework_TestCase
public function testGetcwd5 ()
{
$file = new file ();
$file = new File ();
$file->chdir ("../../../../../../tmp");
$res = $file->getcwd ();
$this->assertSame($res, "/tmp");
@@ -158,7 +164,7 @@ class fileTest extends \PHPUnit_Framework_TestCase
public function testGetcwd6 ()
{
$this->setExpectedException ("Exception", "Path './tmp' not found");
$file = new file ();
$file = new File ();
$file->chdir ("./tmp");
$res = $file->getcwd ();
}
@@ -167,7 +173,7 @@ class fileTest extends \PHPUnit_Framework_TestCase
{
$this->setExpectedException ("Exception",
"Path '/tmp/NON EXISTS' not found");
$file = new file ();
$file = new File ();
$file->chdir ("/tmp/NON EXISTS");
$res = $file->getcwd ();
}
@@ -176,7 +182,7 @@ class fileTest extends \PHPUnit_Framework_TestCase
{
$this->setExpectedException ("Exception",
"Parent Path '/NON EXISTS/' not found");
$file = new file ();
$file = new File ();
$file->chdir ("/NON EXISTS/tmp");
$res = $file->getcwd ();
}
@@ -184,13 +190,13 @@ class fileTest extends \PHPUnit_Framework_TestCase
public function testchroot1 ()
{
$this->setExpectedException ("Exception");
$file = new file ();
$file = new File ();
$res = $file->chroot ("non exists");
}
public function testchroot2 ()
{
$file = new file ();
$file = new File ();
$res = $file->chroot ("/tmp");
$this->assertSame($res, true);
}
@@ -198,7 +204,7 @@ class fileTest extends \PHPUnit_Framework_TestCase
// Without chroot
public function testMkdir1 ()
{
$file = new file ();
$file = new File ();
$res = $file->mkdir ("/tmp/testmkdir1-".time());
$this->assertSame($res, true);
}
@@ -206,7 +212,7 @@ class fileTest extends \PHPUnit_Framework_TestCase
// With chroot in tmp
public function testMkdir2 ()
{
$file = new file ();
$file = new File ();
$res = $file->chroot ("/tmp");
$res = $file->mkdir ("/testmkdir2-".time());
$this->assertSame($res, true);
@@ -215,7 +221,7 @@ class fileTest extends \PHPUnit_Framework_TestCase
// Without chroot and relative
public function testMkdir3 ()
{
$file = new file ();
$file = new File ();
$res = $file->mkdir ("/tmp/testmkdir3-".time());
$this->assertSame($res, true);
}
@@ -223,7 +229,7 @@ class fileTest extends \PHPUnit_Framework_TestCase
// With chroot in tmp and in relative
public function testMkdir4 ()
{
$file = new file ();
$file = new File ();
$res = $file->chroot ("/tmp");
$res = $file->mkdir ("testmkdir4-".time());
$this->assertSame($res, true);
@@ -232,8 +238,9 @@ class fileTest extends \PHPUnit_Framework_TestCase
// With chroot in tmp
public function testChdir1 ()
{
@rmdir ("/tmp/testDFFileDir");
$file = new file ();
if (file_exists ("/tmp/testDFFileDir"))
rmdir ("/tmp/testDFFileDir");
$file = new File ();
$file->chroot ("/tmp");
$file->mkdir ("/testDFFileDir");
$file->chdir ("/testDFFileDir");
@@ -244,8 +251,9 @@ class fileTest extends \PHPUnit_Framework_TestCase
// With chroot in tmp
public function testChdir2 ()
{
@rmdir ("/tmp/testDFFileDir");
$file = new file ();
if (file_exists ("/tmp/testDFFileDir"))
rmdir ("/tmp/testDFFileDir");
$file = new File ();
$file->chroot ("/tmp");
$file->mkdir ("/testDFFileDir");
$file->chroot ("/");
@@ -259,8 +267,9 @@ class fileTest extends \PHPUnit_Framework_TestCase
{
$this->setExpectedException ("Exception",
"Path '/tmp/testDFFileDir/NON EXISTS' not found");
@rmdir ("/tmp/testDFFileDir");
$file = new file ();
if (file_exists ("/tmp/testDFFileDir"))
rmdir ("/tmp/testDFFileDir");
$file = new File ();
$file->chroot ("/tmp");
$file->mkdir ("/testDFFileDir");
$file->chroot ("/testDFFileDir");
@@ -272,8 +281,9 @@ class fileTest extends \PHPUnit_Framework_TestCase
{
$this->setExpectedException ("Exception",
"Parent Path '/tmp/tmp/' not found");
@rmdir ("/tmp/testDFFileDir");
$file = new file ();
if (file_exists ("/tmp/testDFFileDir"))
rmdir ("/tmp/testDFFileDir");
$file = new File ();
$file->chroot ("/tmp");
$file->mkdir ("/testDFFileDir");
$file->chroot ("..");
@@ -284,8 +294,9 @@ class fileTest extends \PHPUnit_Framework_TestCase
{
$this->setExpectedException ("Exception",
"File '/tmp/testDFFileDir' is not a file");
@rmdir ("/tmp/testDFFileDir");
$file = new file ();
if (file_exists ("/tmp/testDFFileDir"))
rmdir ("/tmp/testDFFileDir");
$file = new File ();
$file->chroot ("/tmp");
$file->mkdir ("/testDFFileDir");
$res = $file->file_get_contents ("/testDFFileDir");
@@ -293,8 +304,9 @@ class fileTest extends \PHPUnit_Framework_TestCase
public function testFile_get_contents2 ()
{
@rmdir ("/tmp/testDFFileDir");
$file = new file ();
if (file_exists ("/tmp/testDFFileDir"))
rmdir ("/tmp/testDFFileDir");
$file = new File ();
$file->chroot ("/tmp");
$file->mkdir ("/testDFFileDir");
$file->touch ("/testDFFileDir/toto");
@@ -304,7 +316,7 @@ class fileTest extends \PHPUnit_Framework_TestCase
public function testFile_put_contents1 ()
{
$file = new file ();
$file = new File ();
$file->chroot ("/tmp");
$file->file_put_contents ("/testDFFileDir/toto", "content");
$res = $file->file_get_contents ("/testDFFileDir/toto");
@@ -315,13 +327,13 @@ class fileTest extends \PHPUnit_Framework_TestCase
{
$this->setExpectedException ("Exception",
"File '/tmp/testDFFileDir' is not a file");
$file = new file ();
$file = new File ();
$file->file_put_contents ("/tmp/testDFFileDir", "content");
}
public function testFile_put_contents3 ()
{
$file = new file ();
$file = new File ();
$file->chroot ("/tmp");
$res = $file->file_put_contents ("/testDFFileDir/toto", "content");
$this->assertSame($res, 7);
@@ -329,14 +341,14 @@ class fileTest extends \PHPUnit_Framework_TestCase
public function testscandir1 ()
{
$file = new file ();
$file = new File ();
$res = $file->scandir ("/tmp/testDFFileDir");
$this->assertSame ($res, array ("toto"));
}
public function testscandir2 ()
{
$file = new file ();
$file = new File ();
$file->chroot ("/tmp");
$res = $file->scandir ("/testDFFileDir");
$this->assertSame ($res, array ("toto"));
@@ -344,7 +356,7 @@ class fileTest extends \PHPUnit_Framework_TestCase
public function testscandir3 ()
{
$file = new file ();
$file = new File ();
$file->chroot ("/tmp");
$res = $file->scandir ("/testDFFileDir/");
$this->assertSame ($res, array ("toto"));
@@ -353,7 +365,7 @@ class fileTest extends \PHPUnit_Framework_TestCase
public function testrmdir1 ()
{
// Directory not empty and NOT recursive : return false
$file = new file ();
$file = new File ();
$res = $file->rmdir ("/tmp/testDFFileDir");
$this->assertSame ($res, false);
}
@@ -361,7 +373,7 @@ class fileTest extends \PHPUnit_Framework_TestCase
public function testrmdir2 ()
{
// Directory not empty and NOT recursive : return false
$file = new file ();
$file = new File ();
$file->chroot ("/tmp");
$res = $file->rmdir ("/testDFFileDir");
$this->assertSame ($res, false);
@@ -370,7 +382,7 @@ class fileTest extends \PHPUnit_Framework_TestCase
public function testrmdir3 ()
{
// Directory not empty and recursive : return true
$file = new file ();
$file = new File ();
$file->chroot ("/tmp");
$res = $file->rmdir ("/testDFFileDir", true);
$this->assertSame ($res, true);
@@ -378,8 +390,9 @@ class fileTest extends \PHPUnit_Framework_TestCase
public function testUnlink1 ()
{
@rmdir ("/tmp/testDFFileDir");
$file = new file ();
if (file_exists ("/tmp/testDFFileDir"))
rmdir ("/tmp/testDFFileDir");
$file = new File ();
$file->chroot ("/tmp");
$file->mkdir ("/testDFFileDir");
$file->touch ("/testDFFileDir/toto");
@@ -389,7 +402,7 @@ class fileTest extends \PHPUnit_Framework_TestCase
public function testIsDir1 ()
{
$file = new file ();
$file = new File ();
$file->chroot ("/tmp");
$res = $file->is_dir ("//testDFFileDir");
$this->assertSame ($res, true);
@@ -397,7 +410,7 @@ class fileTest extends \PHPUnit_Framework_TestCase
public function testIsDir2 ()
{
$file = new file ();
$file = new File ();
$file->chroot ("/tmp");
$file->touch ("/testDFFileDir/toto");
$res = $file->is_dir ("//testDFFileDir/toto");
@@ -406,7 +419,7 @@ class fileTest extends \PHPUnit_Framework_TestCase
public function testIsFile1 ()
{
$file = new file ();
$file = new File ();
$file->chroot ("/tmp");
$file->touch ("/testDFFileDir/toto");
$res = $file->is_file ("/testDFFileDir/toto");
@@ -415,7 +428,7 @@ class fileTest extends \PHPUnit_Framework_TestCase
public function testIsFile2 ()
{
$file = new file ();
$file = new File ();
$file->chroot ("/tmp");
$file->touch ("/testDFFileDir/toto");
$res = $file->is_file ("//testDFFileDir");
@@ -424,7 +437,7 @@ class fileTest extends \PHPUnit_Framework_TestCase
public function testMkdir5 ()
{
$file = new file ();
$file = new File ();
$file->chroot ("/tmp");
// The parent doesn't exists and not recursive mode : exception
$this->expectException ();
@@ -433,7 +446,7 @@ class fileTest extends \PHPUnit_Framework_TestCase
public function testMkdir6 ()
{
$file = new file ();
$file = new File ();
$file->chroot ("/tmp");
$res = $file->mkdir ("/testDFFileDir/tptp/titi/poo", 0777, true);
$this->assertSame ($res, true);
@@ -441,7 +454,7 @@ class fileTest extends \PHPUnit_Framework_TestCase
public function test_glob_1 ()
{
$file = new file ();
$file = new File ();
$file->chroot ("/tmp");
$res = $file->glob ("/testDFFileDir/*");
$this->assertSame ($res, array ("/testDFFileDir/toto",
@@ -450,7 +463,7 @@ class fileTest extends \PHPUnit_Framework_TestCase
public function test_glob_2 ()
{
$file = new file ();
$file = new File ();
$file->chroot ("/tmp");
$file->chdir ("/testDFFileDir");
$res = $file->glob ("*");
@@ -460,7 +473,7 @@ class fileTest extends \PHPUnit_Framework_TestCase
public function test_glob_3 ()
{
$file = new file ();
$file = new File ();
$file->chroot ("/tmp");
$file->chdir ("/testDFFileDir");
$res = $file->glob ("/testDFFileDir/*");
@@ -470,7 +483,7 @@ class fileTest extends \PHPUnit_Framework_TestCase
public function test_glob_4 ()
{
$file = new file ();
$file = new File ();
$res = $file->glob ("/tmp/testDFFileDir/*");
$this->assertSame ($res, array ("/tmp/testDFFileDir/toto",
"/tmp/testDFFileDir/tptp"));
@@ -478,7 +491,7 @@ class fileTest extends \PHPUnit_Framework_TestCase
public function test_glob_5 ()
{
$file = new file ();
$file = new File ();
$file->chdir ("/tmp/testDFFileDir");
$res = $file->glob ("*");
$this->assertSame ($res, array ("toto",
@@ -487,7 +500,7 @@ class fileTest extends \PHPUnit_Framework_TestCase
public function test_glob_6 ()
{
$file = new file ();
$file = new File ();
$file->chdir ("/tmp/testDFFileDir");
$res = $file->glob ("/tmp/testDFFileDir/*");
$this->assertSame ($res, array ("/tmp/testDFFileDir/toto",
+26 -17
View File
@@ -1,12 +1,21 @@
<?php
/** DomFramework - Tests
* @package domframework
* @author Dominique Fournier <dominique@fournier38.fr>
* @license BSD
*/
namespace Domframework\Tests;
use Domframework\Fts;
/** Test the FTS */
class ftsTest extends \PHPUnit_Framework_TestCase
class FtsTest extends \PHPUnit_Framework_TestCase
{
public function test_tokenizerSearch0 ()
{
// Empty
$fts = new fts ();
$fts = new Fts ();
$fts->search ("");
$res = $fts->getTokensMin ();
$this->assertSame ($res, array ("tokens"=>array (),
@@ -16,7 +25,7 @@ class ftsTest extends \PHPUnit_Framework_TestCase
public function test_tokenizerSearch1 ()
{
// Too small
$fts = new fts ();
$fts = new Fts ();
$fts->search ("X");
$res = $fts->getTokensMin ();
$this->assertSame ($res, array ("tokens"=>array (),
@@ -26,7 +35,7 @@ class ftsTest extends \PHPUnit_Framework_TestCase
public function test_tokenizerSearch2 ()
{
// One word
$fts = new fts ();
$fts = new Fts ();
$fts->search ("XYZ");
$res = $fts->getTokensMin ();
$this->assertSame ($res, array ("tokens"=>array ("XYZ"),
@@ -36,7 +45,7 @@ class ftsTest extends \PHPUnit_Framework_TestCase
public function test_tokenizerSearch3 ()
{
// Two word
$fts = new fts ();
$fts = new Fts ();
$fts->search ("XYZ 123");
$res = $fts->getTokensMin ();
$this->assertSame ($res, array ("tokens"=>array ("XYZ", "123"),
@@ -46,7 +55,7 @@ class ftsTest extends \PHPUnit_Framework_TestCase
public function test_tokenizerSearch4 ()
{
// Three word
$fts = new fts ();
$fts = new Fts ();
$fts->search ("XYZ 123 ABC");
$res = $fts->getTokensMin ();
$this->assertSame ($res, array ("tokens"=>array ("XYZ", "123", "ABC"),
@@ -56,7 +65,7 @@ class ftsTest extends \PHPUnit_Framework_TestCase
public function test_tokenizerSearch5 ()
{
// Three word
$fts = new fts ();
$fts = new Fts ();
$fts->search ("XYZ 123 ABC KLM");
$res = $fts->getTokensMin ();
$this->assertSame ($res, array ("tokens"=>array ("XYZ", "123",
@@ -67,7 +76,7 @@ class ftsTest extends \PHPUnit_Framework_TestCase
public function test_tokenizerSearch6 ()
{
// Three word
$fts = new fts ();
$fts = new Fts ();
$fts->search ("Louis-XYZ 123 -AéBCé KLM");
$res = $fts->getTokensMin ();
$this->assertSame ($res, array ("tokens"=>array ("Louis-XYZ", "123",
@@ -79,7 +88,7 @@ class ftsTest extends \PHPUnit_Framework_TestCase
public function test_tokenizerSentence0 ()
{
// Empty sentence
$fts = new fts ();
$fts = new Fts ();
$fts->search ("\"\"");
$res = $fts->getTokensMin ();
$this->assertSame ($res, array ("tokens"=>array (),
@@ -89,7 +98,7 @@ class ftsTest extends \PHPUnit_Framework_TestCase
public function test_tokenizerSentence1 ()
{
// One sentence only
$fts = new fts ();
$fts = new Fts ();
$fts->search ("\"XYZ 123\"");
$res = $fts->getTokensMin ();
$this->assertSame ($res, array ("tokens"=>array ("XYZ 123"),
@@ -99,7 +108,7 @@ class ftsTest extends \PHPUnit_Framework_TestCase
public function test_tokenizerSentence2 ()
{
// Two sentence
$fts = new fts ();
$fts = new Fts ();
$fts->search ("\"XYZ 123\" \"ABC KLM\"");
$res = $fts->getTokensMin ();
$this->assertSame ($res, array ("tokens"=>array ("XYZ 123", "ABC KLM"),
@@ -109,7 +118,7 @@ class ftsTest extends \PHPUnit_Framework_TestCase
public function test_tokenizerSentence3 ()
{
// Three sentence
$fts = new fts ();
$fts = new Fts ();
$fts->search ("\"XYZ 123\" -\"ABC KLM\" \"RPO YUI\"");
$res = $fts->getTokensMin ();
$this->assertSame ($res, array ("tokens"=>array ("XYZ 123", "ABC KLM",
@@ -120,7 +129,7 @@ class ftsTest extends \PHPUnit_Framework_TestCase
public function test_tokenizerMixed1 ()
{
// One word and one sentence, starting by word
$fts = new fts ();
$fts = new Fts ();
$fts->search ("XYZ \"ABC KLM\"");
$res = $fts->getTokensMin ();
$this->assertSame ($res, array ("tokens"=>array ("XYZ", "ABC KLM"),
@@ -130,7 +139,7 @@ class ftsTest extends \PHPUnit_Framework_TestCase
public function test_tokenizerMixed2 ()
{
// One word and one sentence, starting by sentence
$fts = new fts ();
$fts = new Fts ();
$fts->search ("\"ABC KLM\" XYZ");
$res = $fts->getTokensMin ();
$this->assertSame ($res, array ("tokens"=>array ("ABC KLM", "XYZ"),
@@ -140,7 +149,7 @@ class ftsTest extends \PHPUnit_Framework_TestCase
public function test_tokenizerMixed3 ()
{
// One word and two sentences, starting by sentence
$fts = new fts ();
$fts = new Fts ();
$fts->search ("\"ABC KLM\" XYZ \"RPO YUI\"");
$res = $fts->getTokensMin ();
$this->assertSame ($res, array ("tokens"=>array ("ABC KLM", "XYZ",
@@ -151,7 +160,7 @@ class ftsTest extends \PHPUnit_Framework_TestCase
public function test_tokenizerMixed4 ()
{
// Two words and two sentences, starting by sentence
$fts = new fts ();
$fts = new Fts ();
$fts->search ("\"ABC KLM\" XYZ \"RPO YUI\" 123");
$res = $fts->getTokensMin ();
$this->assertSame ($res, array ("tokens"=>array ("ABC KLM", "XYZ",
@@ -162,7 +171,7 @@ class ftsTest extends \PHPUnit_Framework_TestCase
public function test_tokenizerMixed5 ()
{
// Two words and two sentences, starting by a word
$fts = new fts ();
$fts = new Fts ();
$fts->search ("123 \"ABC KLM\" XYZ \"RPO YUI\"");
$res = $fts->getTokensMin ();
$this->assertSame ($res, array ("tokens"=>array ("123", "ABC KLM",
+20 -18
View File
@@ -7,27 +7,29 @@
namespace Domframework\Tests;
use Domframework\Getopts;
/** Test the GetOpts */
class getoptsTest extends \PHPUnit_Framework_TestCase
class GetoptsTest extends \PHPUnit_Framework_TestCase
{
public function test_empty1 ()
{
// Empty
$getopts = new getopts ();
$getopts = new Getopts ();
$res = $getopts->help ();
$this->assertSame ($res, "No option defined\n");
}
public function test_simu1 ()
{
$getopts = new getopts ();
$getopts = new Getopts ();
$res = $getopts->simulate ("sim\ ulate -h -d -d -f ii -o 1\ 2 -o \"2 2\" -o 3 -- -bla final");
$this->assertSame (is_object ($res), true);
}
public function test_add1 ()
{
$getopts = new getopts ();
$getopts = new Getopts ();
$getopts->simulate ("sim\ ulate -h -d -d -f ii -o 1\ 2 -o \"2 2\" -o 3 -- -bla final");
$res = $getopts->add ("Help", "?h", array ("help","help2"), "Help of the software");
$this->assertSame (is_object ($res), true);
@@ -35,7 +37,7 @@ class getoptsTest extends \PHPUnit_Framework_TestCase
public function test_add2 ()
{
$getopts = new getopts ();
$getopts = new Getopts ();
$getopts->simulate ("sim\ ulate -h -d -d -f ii -o 1\ 2 -o \"2 2\" -o 3 -- -bla final");
$getopts->add ("Help", "?h", array ("help","help2"), "Help of the software");
$res = $getopts->add ("Debug", "d", "debug", "Debug", "DebugLevel", 2);
@@ -45,7 +47,7 @@ class getoptsTest extends \PHPUnit_Framework_TestCase
public function test_scan1 ()
{
$this->expectException ("Exception", "Provided tokens are not known: -f,-o,-o,-o");
$getopts = new getopts ();
$getopts = new Getopts ();
$getopts->simulate ("sim\ ulate -h -d -d -f ii -o 1\ 2 -o \"2 2\" -o 3 -- -bla final");
$getopts->add ("Help", "?h", array ("help","help2"), "Help of the software");
$getopts->add ("Debug", "d", "debug", "Debug", "DebugLevel", 2);
@@ -55,7 +57,7 @@ class getoptsTest extends \PHPUnit_Framework_TestCase
public function test_getShort1 ()
{
// One unique value (-h -> true/false)
$getopts = new getopts ();
$getopts = new Getopts ();
$getopts->simulate ("sim\ ulate -h -d -d ");
$getopts->add ("Help", "?h", array ("help","help2"), "Help of the software");
$getopts->add ("Debug", "d", "debug", "Debug", "DebugLevel", 2);
@@ -66,7 +68,7 @@ class getoptsTest extends \PHPUnit_Framework_TestCase
public function test_getShort2 ()
{
// Multiple values, two set (-d -d)
$getopts = new getopts ();
$getopts = new Getopts ();
$getopts->simulate ("sim\ ulate -h -d -d ");
$getopts->add ("Help", "?h", array ("help","help2"), "Help of the software");
$getopts->add ("Debug", "d", "debug", "Debug", "DebugLevel", 2);
@@ -77,7 +79,7 @@ class getoptsTest extends \PHPUnit_Framework_TestCase
public function test_getShort3 ()
{
// Multiple values, one set (-d)
$getopts = new getopts ();
$getopts = new Getopts ();
$getopts->simulate ("sim\ ulate -h -d ");
$getopts->add ("Help", "?h", array ("help","help2"), "Help of the software");
$getopts->add ("Debug", "d", "debug", "Debug", "DebugLevel", 2);
@@ -88,7 +90,7 @@ class getoptsTest extends \PHPUnit_Framework_TestCase
public function test_getShort4 ()
{
// Multiple values, None set (-d)
$getopts = new getopts ();
$getopts = new Getopts ();
$getopts->simulate ("sim\ ulate -h ");
$getopts->add ("Help", "?h", array ("help","help2"), "Help of the software");
$getopts->add ("Debug", "d", "debug", "Debug", "DebugLevel", 2);
@@ -99,7 +101,7 @@ class getoptsTest extends \PHPUnit_Framework_TestCase
public function test_getLong1 ()
{
// One unique value (--help -> true/false)
$getopts = new getopts ();
$getopts = new Getopts ();
$getopts->simulate ("sim\ ulate --help -d -d ");
$getopts->add ("Help", "?h", array ("help","help2"), "Help of the software");
$getopts->add ("Debug", "d", "debug", "Debug", "DebugLevel", 2);
@@ -110,7 +112,7 @@ class getoptsTest extends \PHPUnit_Framework_TestCase
public function test_getLong2 ()
{
// Multiple values, two set (-debug --debug)
$getopts = new getopts ();
$getopts = new Getopts ();
$getopts->simulate ("sim\ ulate -h --debug --debug ");
$getopts->add ("Help", "?h", array ("help","help2"), "Help of the software");
$getopts->add ("Debug", "d", "debug", "Debug", "DebugLevel", 2);
@@ -121,7 +123,7 @@ class getoptsTest extends \PHPUnit_Framework_TestCase
public function test_getLong3 ()
{
// Multiple values, one set (-d)
$getopts = new getopts ();
$getopts = new Getopts ();
$getopts->simulate ("sim\ ulate --help -d ");
$getopts->add ("Help", "?h", array ("help","help2"), "Help of the software");
$getopts->add ("Debug", "d", "debug", "Debug", "DebugLevel", 2);
@@ -132,7 +134,7 @@ class getoptsTest extends \PHPUnit_Framework_TestCase
public function test_getLong4 ()
{
// Multiple values, None set (-d)
$getopts = new getopts ();
$getopts = new Getopts ();
$getopts->simulate ("sim\ ulate -h");
$getopts->add ("Help", "?h", array ("help","help2"), "Help of the software");
$getopts->add ("Debug", "d", "debug", "Debug", "DebugLevel", 2);
@@ -142,7 +144,7 @@ class getoptsTest extends \PHPUnit_Framework_TestCase
public function test_restOfLine1 ()
{
$getopts = new getopts ();
$getopts = new Getopts ();
$getopts->simulate ("sim\ ulate -h -d -d -- -bla final");
$getopts->add ("Help", "?h", array ("help","help2"), "Help of the software");
$getopts->add ("Debug", "d", "debug", "Debug", "DebugLevel", 2);
@@ -152,7 +154,7 @@ class getoptsTest extends \PHPUnit_Framework_TestCase
public function test_restOfLine2 ()
{
$getopts = new getopts ();
$getopts = new Getopts ();
$getopts->simulate ("sim\ ulate bla final");
$getopts->add ("Help", "?h", array ("help","help2"), "Help of the software");
$getopts->add ("Debug", "d", "debug", "Debug", "DebugLevel", 2);
@@ -162,7 +164,7 @@ class getoptsTest extends \PHPUnit_Framework_TestCase
public function test_restOfLine3 ()
{
$getopts = new getopts ();
$getopts = new Getopts ();
$getopts->simulate ("sim\ ulate -- -bla final");
$getopts->add ("Help", "?h", array ("help","help2"), "Help of the software");
$getopts->add ("Debug", "d", "debug", "Debug", "DebugLevel", 2);
@@ -172,7 +174,7 @@ class getoptsTest extends \PHPUnit_Framework_TestCase
public function test_programName1 ()
{
$getopts = new getopts ();
$getopts = new Getopts ();
$getopts->simulate ("sim\ ulate -h -d -d -- -bla final");
$getopts->add ("Help", "?h", array ("help","help2"), "Help of the software");
$getopts->add ("Debug", "d", "debug", "Debug", "DebugLevel", 2);
+8 -6
View File
@@ -7,14 +7,16 @@
namespace Domframework\Tests;
/** Test the http.php file */
class httpTest extends \PHPUnit_Framework_TestCase
use Domframework\Http;
/** Test the Http.php file */
class HttpTest extends \PHPUnit_Framework_TestCase
{
/** bestChoice : exact existing entry
*/
public function testBestChoice1 ()
{
$http = new http ();
$http = new Http ();
$res = $http->bestChoice (
"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
array ("application/xml"), "text/html");
@@ -26,7 +28,7 @@ class httpTest extends \PHPUnit_Framework_TestCase
*/
public function testBestChoice2 ()
{
$http = new http ();
$http = new Http ();
$res = $http->bestChoice (
"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
array ("text/plain"), "text/html");
@@ -37,7 +39,7 @@ class httpTest extends \PHPUnit_Framework_TestCase
*/
public function testBestChoice3 ()
{
$http = new http ();
$http = new Http ();
$res = $http->bestChoice (
"text/html,application/xhtml+xml,application/xml;q=0.9",
array ("text/plain"), "text/html");
@@ -49,7 +51,7 @@ class httpTest extends \PHPUnit_Framework_TestCase
*/
public function testBestChoice4 ()
{
$http = new http ();
$http = new Http ();
$res = $http->bestChoice (
"text/html,application/xhtml+xml,application/xml;q=0.9,",
array ("text/plain"), "text/html");
+28 -26
View File
@@ -7,19 +7,21 @@
namespace Domframework\Tests;
/** Test the outputjson.php file */
class inifileTest extends \PHPUnit_Framework_TestCase
use Domframework\Inifile;
/** Test the Inifile.php file */
class InifileTest extends \PHPUnit_Framework_TestCase
{
public function testsetString001 ()
{
$this->setExpectedException ("Exception");
$inifile = new inifile ();
$inifile = new Inifile ();
$res = $inifile->setString (1, TRUE);
}
public function testsetString002 ()
{
$inifile = new inifile ();
$inifile = new Inifile ();
$res = $inifile->setString (array (), TRUE);
$this->assertSame("", $res);
}
@@ -28,41 +30,41 @@ class inifileTest extends \PHPUnit_Framework_TestCase
public function testsetString103 ()
{
$this->setExpectedException ("Exception");
$inifile = new inifile ();
$inifile = new Inifile ();
$res = $inifile->setString (array ("section1"), TRUE);
}
public function testsetString104 ()
{
$inifile = new inifile ();
$inifile = new Inifile ();
$res = $inifile->setString (array ("section1"=>array ()), TRUE);
$this->assertSame("[section1]\n\n", $res);
}
public function testsetString105 ()
{
$inifile = new inifile ();
$inifile = new Inifile ();
$res = $inifile->setString (array ("section1"=>array (0)), TRUE);
$this->assertSame("[section1]\n0 = \"0\"\n\n", $res);
}
public function testsetString106 ()
{
$inifile = new inifile ();
$inifile = new Inifile ();
$res = $inifile->setString (array ("section1"=>array (0=>1)), TRUE);
$this->assertSame("[section1]\n0 = \"1\"\n\n", $res);
}
public function testsetString107 ()
{
$inifile = new inifile ();
$inifile = new Inifile ();
$res = $inifile->setString (array ("section1"=>array (0=>null)), TRUE);
$this->assertSame("[section1]\n0 = \"null\"\n\n", $res);
}
public function testsetString108 ()
{
$inifile = new inifile ();
$inifile = new Inifile ();
$res = $inifile->setString (array ("section1"=>array (0=>null, 1=>1)),
TRUE);
$this->assertSame("[section1]\n0 = \"null\"\n1 = \"1\"\n\n", $res);
@@ -70,7 +72,7 @@ class inifileTest extends \PHPUnit_Framework_TestCase
public function testsetString109 ()
{
$inifile = new inifile ();
$inifile = new Inifile ();
$res = $inifile->setString (array ("section1"=>array (0=>null,
1=>1, 2=>"str")),
TRUE);
@@ -80,7 +82,7 @@ class inifileTest extends \PHPUnit_Framework_TestCase
public function testsetString110 ()
{
$inifile = new inifile ();
$inifile = new Inifile ();
$res = $inifile->setString (array ("section1"=>array (0=>null,
1=>1, 2=>"str",
3=>array (1,2,3))),
@@ -92,7 +94,7 @@ class inifileTest extends \PHPUnit_Framework_TestCase
public function testsetString111 ()
{
$inifile = new inifile ();
$inifile = new Inifile ();
$res = $inifile->setString (array ("section1"=>array (0=>null,
1=>1, 2=>"str",
3=>array ())),
@@ -103,7 +105,7 @@ class inifileTest extends \PHPUnit_Framework_TestCase
public function testsetString112 ()
{
$inifile = new inifile ();
$inifile = new Inifile ();
$res = $inifile->setString (array ("section1"=>array (0=>null,
1=>1, 2=>"str",
"chain"=>array ("key"=>1,2))),
@@ -116,42 +118,42 @@ class inifileTest extends \PHPUnit_Framework_TestCase
//// TEST OF THE NOT SECTION PART ////
public function testsetString203 ()
{
$inifile = new inifile ();
$inifile = new Inifile ();
$res = $inifile->setString (array ("section1"), FALSE);
$this->assertSame("0 = \"section1\"\n\n", $res);
}
public function testsetString204 ()
{
$inifile = new inifile ();
$inifile = new Inifile ();
$res = $inifile->setString (array ("section1"=>array ()), FALSE);
$this->assertSame("\n", $res);
}
public function testsetString205 ()
{
$inifile = new inifile ();
$inifile = new Inifile ();
$res = $inifile->setString (array ("section1"=>array (0)), FALSE);
$this->assertSame("section1[0] = \"0\"\n\n", $res);
}
public function testsetString206 ()
{
$inifile = new inifile ();
$inifile = new Inifile ();
$res = $inifile->setString (array ("section1"=>array (0=>1)), FALSE);
$this->assertSame("section1[0] = \"1\"\n\n", $res);
}
public function testsetString207 ()
{
$inifile = new inifile ();
$inifile = new Inifile ();
$res = $inifile->setString (array ("section1"=>array (0=>null)), FALSE);
$this->assertSame("section1[0] = \"null\"\n\n", $res);
}
public function testsetString208 ()
{
$inifile = new inifile ();
$inifile = new Inifile ();
$res = $inifile->setString (array ("section1"=>array (0=>null, 1=>1)),
FALSE);
$this->assertSame("section1[0] = \"null\"\nsection1[1] = \"1\"\n\n",
@@ -160,7 +162,7 @@ class inifileTest extends \PHPUnit_Framework_TestCase
public function testsetString209 ()
{
$inifile = new inifile ();
$inifile = new Inifile ();
$res = $inifile->setString (array ("section1"=>array (0=>null,
1=>1, 2=>"str")),
FALSE);
@@ -172,7 +174,7 @@ class inifileTest extends \PHPUnit_Framework_TestCase
public function testsetString210 ()
{
$this->setExpectedException ("Exception");
$inifile = new inifile ();
$inifile = new Inifile ();
$res = $inifile->setString (array ("section1"=>array (0=>null,
1=>1, 2=>"str",
3=>array (1,2,3))),
@@ -182,7 +184,7 @@ class inifileTest extends \PHPUnit_Framework_TestCase
public function testsetString211 ()
{
$this->setExpectedException ("Exception");
$inifile = new inifile ();
$inifile = new Inifile ();
$res = $inifile->setString (array ("section1"=>array (0=>null,
1=>1, 2=>"str",
3=>array ())),
@@ -193,7 +195,7 @@ class inifileTest extends \PHPUnit_Framework_TestCase
//// LOOP TEST : CREATE AN INI STRING AND PARSE IT ////
public function testLoop406 ()
{
$inifile = new inifile ();
$inifile = new Inifile ();
$loop = $inifile->setString (array ("section1"=>array (0=>1)), FALSE);
var_dump ($loop);
$res = $inifile->getString ($loop, FALSE);
@@ -203,7 +205,7 @@ var_dump ($res);
public function testLoop407 ()
{
$inifile = new inifile ();
$inifile = new Inifile ();
$loop = $inifile->setString (array ("section1"=>array (0=>null)), FALSE);
$res = $inifile->getString ($loop, FALSE);
$this->assertSame(array ("section1"=>array (0=>null)), $res);
@@ -211,7 +213,7 @@ var_dump ($res);
public function testLoop408 ()
{
$inifile = new inifile ();
$inifile = new Inifile ();
$loop = $inifile->setString (array ("section1"=>array (0=>"toto")), FALSE);
var_dump ($loop);
$res = $inifile->getString ($loop, FALSE);
+93 -91
View File
@@ -7,235 +7,237 @@
namespace Domframework\Tests;
/** Test the ipaddresses.php file */
class ipaddressesTest extends \PHPUnit_Framework_TestCase
use Domframework\Ipaddresses;
/** Test the Ipaddresses.php file */
class IpaddressesTest extends \PHPUnit_Framework_TestCase
{
public function test_validIPAddress1 ()
{
$i = new ipaddresses ();
$i = new Ipaddresses ();
$res = $i->validIPAddress ("::");
$this->assertSame (true, $res);
}
public function test_validIPAddress2 ()
{
$i = new ipaddresses ();
$i = new Ipaddresses ();
$res = $i->validIPAddress ("1::");
$this->assertSame (true, $res);
}
public function test_validIPAddress3 ()
{
$i = new ipaddresses ();
$i = new Ipaddresses ();
$res = $i->validIPAddress ("::1");
$this->assertSame (true, $res);
}
public function test_validIPAddress4 ()
{
$i = new ipaddresses ();
$i = new Ipaddresses ();
$res = $i->validIPAddress ("2001::1");
$this->assertSame (true, $res);
}
public function test_validIPAddress5 ()
{
$i = new ipaddresses ();
$i = new Ipaddresses ();
$res = $i->validIPAddress ("1.2.3.4");
$this->assertSame (true, $res);
}
public function test_validIPAddress6 ()
{
$this->setExpectedException ("Exception");
$i = new ipaddresses ();
$i = new Ipaddresses ();
$res = $i->validIPAddress ("");
}
public function test_validIPAddress7 ()
{
$this->setExpectedException ("Exception");
$i = new ipaddresses ();
$i = new Ipaddresses ();
$res = $i->validIPAddress (array ());
}
public function test_validIPv4Address1 ()
{
$i = new ipaddresses ();
$i = new Ipaddresses ();
$res = $i->validIPv4Address ("::");
$this->assertSame (false, $res);
}
public function test_validIPv4Address2 ()
{
$i = new ipaddresses ();
$i = new Ipaddresses ();
$res = $i->validIPv4Address ("1.2.3.4");
$this->assertSame (true, $res);
}
public function test_validIPv6Address1 ()
{
$i = new ipaddresses ();
$i = new Ipaddresses ();
$res = $i->validIPv6Address ("1.2.3.4");
$this->assertSame (false, $res);
}
public function test_validIPv6Address2 ()
{
$i = new ipaddresses ();
$i = new Ipaddresses ();
$res = $i->validIPv6Address ("::");
$this->assertSame (true, $res);
}
public function test_validIPv6Address3 ()
{
$i = new ipaddresses ();
$i = new Ipaddresses ();
$res = $i->validIPv6Address ("1::");
$this->assertSame (true, $res);
}
public function test_validIPv6Address4 ()
{
$i = new ipaddresses ();
$i = new Ipaddresses ();
$res = $i->validIPv6Address ("::1");
$this->assertSame (true, $res);
}
public function test_validIPv6Address5 ()
{
$i = new ipaddresses ();
$i = new Ipaddresses ();
$res = $i->validIPv6Address ("1::1");
$this->assertSame (true, $res);
}
public function test_validIPv6Address6 ()
{
$i = new ipaddresses ();
$i = new Ipaddresses ();
$res = $i->validIPv6Address ("1:1:1");
$this->assertSame (false, $res);
}
public function test_validCIDR1 ()
{
$i = new ipaddresses ();
$i = new Ipaddresses ();
$res = $i->validCIDR (-1);
$this->assertSame (false, $res);
}
public function test_validCIDR2 ()
{
$i = new ipaddresses ();
$i = new Ipaddresses ();
$res = $i->validCIDR (129);
$this->assertSame (false, $res);
}
public function test_validCIDR3 ()
{
$i = new ipaddresses ();
$i = new Ipaddresses ();
$res = $i->validCIDR (128);
$this->assertSame (true, $res);
}
public function test_validCIDR4 ()
{
$i = new ipaddresses ();
$i = new Ipaddresses ();
$res = $i->validCIDR (0);
$this->assertSame (true, $res);
}
public function test_validIPv4CIDR1 ()
{
$i = new ipaddresses ();
$i = new Ipaddresses ();
$res = $i->validIPv4CIDR (-1);
$this->assertSame (false, $res);
}
public function test_validIPv4CIDR2 ()
{
$i = new ipaddresses ();
$i = new Ipaddresses ();
$res = $i->validIPv4CIDR (33);
$this->assertSame (false, $res);
}
public function test_validIPv4CIDR3 ()
{
$i = new ipaddresses ();
$i = new Ipaddresses ();
$res = $i->validIPv4CIDR (32);
$this->assertSame (true, $res);
}
public function test_validIPv4CIDR4 ()
{
$i = new ipaddresses ();
$i = new Ipaddresses ();
$res = $i->validIPv4CIDR (0);
$this->assertSame (true, $res);
}
public function test_validIPv6CIDR1 ()
{
$i = new ipaddresses ();
$i = new Ipaddresses ();
$res = $i->validIPv6CIDR (-1);
$this->assertSame (false, $res);
}
public function test_validIPv6CIDR2 ()
{
$i = new ipaddresses ();
$i = new Ipaddresses ();
$res = $i->validIPv6CIDR (129);
$this->assertSame (false, $res);
}
public function test_validIPv6CIDR3 ()
{
$i = new ipaddresses ();
$i = new Ipaddresses ();
$res = $i->validIPv6CIDR (128);
$this->assertSame (true, $res);
}
public function test_validIPv6CIDR4 ()
{
$i = new ipaddresses ();
$i = new Ipaddresses ();
$res = $i->validIPv6CIDR (0);
$this->assertSame (true, $res);
}
public function test_compressIP1 ()
{
$i = new ipaddresses ();
$i = new Ipaddresses ();
$res = $i->compressIP ("::");
$this->assertSame ("::", $res);
}
public function test_compressIP2 ()
{
$i = new ipaddresses ();
$i = new Ipaddresses ();
$res = $i->compressIP ("::1");
$this->assertSame ("::1", $res);
}
public function test_compressIP3 ()
{
$i = new ipaddresses ();
$i = new Ipaddresses ();
$res = $i->compressIP ("2::1");
$this->assertSame ("2::1", $res);
}
public function test_compressIP4 ()
{
$i = new ipaddresses ();
$i = new Ipaddresses ();
$res = $i->compressIP ("2::");
$this->assertSame ("2::", $res);
}
public function test_compressIP5 ()
{
$i = new ipaddresses ();
$i = new Ipaddresses ();
$res = $i->compressIP ("2:1:0:3::0:1");
$this->assertSame ("2:1:0:3::1", $res);
}
public function test_compressIP6 ()
{
$i = new ipaddresses ();
$i = new Ipaddresses ();
$res = $i->compressIP ("2:1:0:3:0000::1");
$this->assertSame ("2:1:0:3::1", $res);
}
public function test_uncompressIPv6a ()
{
$i = new ipaddresses ();
$i = new Ipaddresses ();
$res = $i->uncompressIPv6 ("1::1");
$this->assertSame ("1:0:0:0:0:0:0:1", $res);
}
public function test_uncompressIPv6b ()
{
$i = new ipaddresses ();
$i = new Ipaddresses ();
$res = $i->uncompressIPv6 ("1::");
$this->assertSame ("1:0:0:0:0:0:0:0", $res);
}
public function test_uncompressIPv6c ()
{
$i = new ipaddresses ();
$i = new Ipaddresses ();
$res = $i->uncompressIPv6 ("::");
$this->assertSame ("0:0:0:0:0:0:0:0", $res);
}
public function test_uncompressIPv6d ()
{
$i = new ipaddresses ();
$i = new Ipaddresses ();
$res = $i->uncompressIPv6 ("1.2.3.4");
$this->assertSame ("1.2.3.4", $res);
}
@@ -243,12 +245,12 @@ class ipaddressesTest extends \PHPUnit_Framework_TestCase
public function test_groupIPv6a ()
{
$this->setExpectedException ("Exception");
$i = new ipaddresses ();
$i = new Ipaddresses ();
$res = $i->groupIPv6 ("1.2.3.4");
}
public function test_groupIPv6b ()
{
$i = new ipaddresses ();
$i = new Ipaddresses ();
$res = $i->groupIPv6 ("0.1.2.3.4.5.6.7.8.9.a.b.c.d.e.f.".
"0.1.2.3.4.5.6.7.8.9.a.b.c.d.e.f");
$this->assertSame ("0123:4567:89ab:cdef:0123:4567:89ab:cdef", $res);
@@ -256,37 +258,37 @@ class ipaddressesTest extends \PHPUnit_Framework_TestCase
public function test_completeAddressWithZero1 ()
{
$i = new ipaddresses ();
$i = new Ipaddresses ();
$res = $i->completeAddressWithZero ("::");
$this->assertSame ("0000:0000:0000:0000:0000:0000:0000:0000", $res);
}
public function test_completeAddressWithZero2 ()
{
$i = new ipaddresses ();
$i = new Ipaddresses ();
$res = $i->completeAddressWithZero ("::1");
$this->assertSame ("0000:0000:0000:0000:0000:0000:0000:0001", $res);
}
public function test_completeAddressWithZero3 ()
{
$i = new ipaddresses ();
$i = new Ipaddresses ();
$res = $i->completeAddressWithZero ("1::");
$this->assertSame ("0001:0000:0000:0000:0000:0000:0000:0000", $res);
}
public function test_completeAddressWithZero4 ()
{
$i = new ipaddresses ();
$i = new Ipaddresses ();
$res = $i->completeAddressWithZero ("1::1");
$this->assertSame ("0001:0000:0000:0000:0000:0000:0000:0001", $res);
}
public function test_completeAddressWithZero5 ()
{
$i = new ipaddresses ();
$i = new Ipaddresses ();
$res = $i->completeAddressWithZero ("1:222::1");
$this->assertSame ("0001:0222:0000:0000:0000:0000:0000:0001", $res);
}
public function test_completeAddressWithZero6 ()
{
$i = new ipaddresses ();
$i = new Ipaddresses ();
$res = $i->completeAddressWithZero ("1.2.3.4");
$this->assertSame ("1.2.3.4", $res);
}
@@ -296,31 +298,31 @@ class ipaddressesTest extends \PHPUnit_Framework_TestCase
public function test_reverseIPAddress1 ()
{
$i = new ipaddresses ();
$i = new Ipaddresses ();
$res = $i->reverseIPAddress ("1.2.3.4");
$this->assertSame ("4.3.2.1", $res);
}
public function test_reverseIPAddress2 ()
{
$i = new ipaddresses ();
$i = new Ipaddresses ();
$res = $i->reverseIPAddress ("::");
$this->assertSame ("0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0", $res);
}
public function test_reverseIPAddress3 ()
{
$i = new ipaddresses ();
$i = new Ipaddresses ();
$res = $i->reverseIPAddress ("::1");
$this->assertSame ("1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0", $res);
}
public function test_reverseIPAddress4 ()
{
$i = new ipaddresses ();
$i = new Ipaddresses ();
$res = $i->reverseIPAddress ("2::1");
$this->assertSame ("1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.2.0.0.0", $res);
}
public function test_reverseIPAddress5 ()
{
$i = new ipaddresses ();
$i = new Ipaddresses ();
$res = $i->reverseIPAddress ("2::abcd:1");
$this->assertSame ("1.0.0.0.d.c.b.a.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.2.0.0.0", $res);
}
@@ -328,242 +330,242 @@ class ipaddressesTest extends \PHPUnit_Framework_TestCase
public function test_netmask2cidr1 ()
{
$this->setExpectedException ("Exception");
$i = new ipaddresses ();
$i = new Ipaddresses ();
$res = $i->netmask2cidr (0);
}
public function test_netmask2cidr2 ()
{
$i = new ipaddresses ();
$i = new Ipaddresses ();
$res = $i->netmask2cidr ("255.255.255.0");
$this->assertSame (24, $res);
}
public function test_netmask2cidr3 ()
{
$i = new ipaddresses ();
$i = new Ipaddresses ();
$res = $i->netmask2cidr ("255.255.255.255");
$this->assertSame (32, $res);
}
public function test_netmask2cidr4 ()
{
$i = new ipaddresses ();
$i = new Ipaddresses ();
$res = $i->netmask2cidr ("255.255.255.255");
$this->assertSame (32, $res);
}
public function test_netmask2cidr5 ()
{
$i = new ipaddresses ();
$i = new Ipaddresses ();
$res = $i->netmask2cidr ("255.0.0.0");
$this->assertSame (8, $res);
}
public function test_netmask2cidr6 ()
{
$i = new ipaddresses ();
$i = new Ipaddresses ();
$res = $i->netmask2cidr ("127.0.0.0");
$this->assertSame (false, $res);
}
public function test_netmask2cidr7 ()
{
$i = new ipaddresses ();
$i = new Ipaddresses ();
$res = $i->netmask2cidr ("63.0.0.0");
$this->assertSame (false, $res);
}
public function test_netmask2cidr8 ()
{
$i = new ipaddresses ();
$i = new Ipaddresses ();
$res = $i->netmask2cidr ("155.0.0.0");
$this->assertSame (false, $res);
}
public function test_netmask2cidr9 ()
{
$i = new ipaddresses ();
$i = new Ipaddresses ();
$res = $i->netmask2cidr ("0.0.0.255");
$this->assertSame (false, $res);
}
public function test_netmask2cidrWildcard_1 ()
{
$i = new ipaddresses ();
$i = new Ipaddresses ();
$res = $i->netmask2cidr ("255.255.255.0", false);
$this->assertSame (false, $res);
}
public function test_netmask2cidrWildcard_2 ()
{
$i = new ipaddresses ();
$i = new Ipaddresses ();
$res = $i->netmask2cidr ("0.0.0.0", false);
$this->assertSame (32, $res);
}
public function test_netmask2cidrWildcard_3 ()
{
$i = new ipaddresses ();
$i = new Ipaddresses ();
$res = $i->netmask2cidr ("255.255.255.255", false);
$this->assertSame (0, $res);
}
public function test_cidr2netmask_1 ()
{
$i = new ipaddresses ();
$i = new Ipaddresses ();
$res = $i->cidr2netmask (0, true);
$this->assertSame ("0.0.0.0", $res);
}
public function test_cidr2netmask_2 ()
{
$i = new ipaddresses ();
$i = new Ipaddresses ();
$res = $i->cidr2netmask (24, true);
$this->assertSame ("255.255.255.0", $res);
}
public function test_cidr2netmask_3 ()
{
$i = new ipaddresses ();
$i = new Ipaddresses ();
$res = $i->cidr2netmask (25, true);
$this->assertSame ("255.255.255.128", $res);
}
public function test_cidr2netmask_4 ()
{
$i = new ipaddresses ();
$i = new Ipaddresses ();
$res = $i->cidr2netmask (32, true);
$this->assertSame ("255.255.255.255", $res);
}
public function test_cidr2netmask_5 ()
{
$i = new ipaddresses ();
$i = new Ipaddresses ();
$res = $i->cidr2netmask (1, true);
$this->assertSame ("128.0.0.0", $res);
}
public function test_ipInNetwork1 ()
{
$i = new ipaddresses ();
$i = new Ipaddresses ();
$res = $i->ipInNetwork ("127.0.0.1", "127.1.0.0", 8);
$this->assertSame (true, $res);
}
public function test_ipInNetwork2 ()
{
$i = new ipaddresses ();
$i = new Ipaddresses ();
$res = $i->ipInNetwork ("192.168.1.1", "127.1.0.0", 8);
$this->assertSame (false, $res);
}
public function test_ipInNetwork3 ()
{
$i = new ipaddresses ();
$i = new Ipaddresses ();
$res = $i->ipInNetwork ("2001:660:530d:201::1", "2001:660:530d:201::", 64);
$this->assertSame (true, $res);
}
public function test_ipInNetwork4 ()
{
$i = new ipaddresses ();
$i = new Ipaddresses ();
$res = $i->ipInNetwork ("2001:660:530d:203::1", "2001:660:530d:201::", 64);
$this->assertSame (false, $res);
}
public function test_ipInNetwork5 ()
{
$i = new ipaddresses ();
$i = new Ipaddresses ();
$res = $i->ipInNetwork ("2001:660:530d:203::1", "2001::", 0);
$this->assertSame (true, $res);
}
public function test_ipInNetwork6 ()
{
$i = new ipaddresses ();
$i = new Ipaddresses ();
$res = $i->ipInNetwork ("192.168.1.1", "127.0.0.0", 0);
$this->assertSame (true, $res);
}
public function test_networkFirstIP1 ()
{
$i = new ipaddresses ();
$i = new Ipaddresses ();
$res = $i->networkFirstIP ("192.168.1.21", 24);
$this->assertSame ($res, "192.168.1.0");
}
public function test_networkFirstIP2 ()
{
$i = new ipaddresses ();
$i = new Ipaddresses ();
$res = $i->networkFirstIP ("192.168.1.21", 0);
$this->assertSame ($res, "0.0.0.0");
}
public function test_networkFirstIP3 ()
{
$i = new ipaddresses ();
$i = new Ipaddresses ();
$res = $i->networkFirstIP ("192.168.1.21", 32);
$this->assertSame ($res, "192.168.1.21");
}
public function test_networkFirstIP4 ()
{
$i = new ipaddresses ();
$i = new Ipaddresses ();
$res = $i->networkFirstIP ("192.168.1.21", 31);
$this->assertSame ($res, "192.168.1.20");
}
public function test_networkFirstIP5 ()
{
$i = new ipaddresses ();
$i = new Ipaddresses ();
$res = $i->networkFirstIP ("2001:660:530d:201::125", 64);
$this->assertSame ($res, "2001:660:530d:201::");
}
public function test_networkFirstIP6 ()
{
$i = new ipaddresses ();
$i = new Ipaddresses ();
$res = $i->networkFirstIP ("2001:660:530d:201::125", 0);
$this->assertSame ($res, "::");
}
public function test_networkFirstIP7 ()
{
$i = new ipaddresses ();
$i = new Ipaddresses ();
$res = $i->networkFirstIP ("2001:660:530d:201::125", 128);
$this->assertSame ($res, "2001:660:530d:201::125");
}
public function test_networkFirstIP8 ()
{
$i = new ipaddresses ();
$i = new Ipaddresses ();
$res = $i->networkFirstIP ("2001:660:530d:201::125", 127);
$this->assertSame ($res, "2001:660:530d:201::124");
}
public function test_networkLastIP1 ()
{
$i = new ipaddresses ();
$i = new Ipaddresses ();
$res = $i->networkLastIP ("192.168.1.21", 24);
$this->assertSame ($res, "192.168.1.255");
}
public function test_networkLastIP2 ()
{
$i = new ipaddresses ();
$i = new Ipaddresses ();
$res = $i->networkLastIP ("192.168.1.21", 0);
$this->assertSame ($res, "255.255.255.255");
}
public function test_networkLastIP3 ()
{
$i = new ipaddresses ();
$i = new Ipaddresses ();
$res = $i->networkLastIP ("192.168.1.21", 32);
$this->assertSame ($res, "192.168.1.21");
}
public function test_networkLastIP4 ()
{
$i = new ipaddresses ();
$i = new Ipaddresses ();
$res = $i->networkLastIP ("192.168.1.21", 31);
$this->assertSame ($res, "192.168.1.21");
}
public function test_networkLastIP5 ()
{
$i = new ipaddresses ();
$i = new Ipaddresses ();
$res = $i->networkLastIP ("2001:660:530d:201::125", 64);
$this->assertSame ($res, "2001:660:530d:201:ffff:ffff:ffff:ffff");
}
public function test_networkLastIP6 ()
{
$i = new ipaddresses ();
$i = new Ipaddresses ();
$res = $i->networkLastIP ("2001:660:530d:201::125", 0);
$this->assertSame ($res, "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff");
}
public function test_networkLastIP7 ()
{
$i = new ipaddresses ();
$i = new Ipaddresses ();
$res = $i->networkLastIP ("2001:660:530d:201::125", 128);
$this->assertSame ($res, "2001:660:530d:201::125");
}
public function test_networkLastIP8 ()
{
$i = new ipaddresses ();
$i = new Ipaddresses ();
$res = $i->networkLastIP ("2001:660:530d:201::125", 127);
$this->assertSame ($res, "2001:660:530d:201::125");
}
+19 -17
View File
@@ -7,19 +7,21 @@
namespace Domframework\Tests;
/** Test the jwt.php file */
class jwtTest extends \PHPUnit_Framework_TestCase
use Domframework\Jwt;
/** Test the Jwt.php file */
class JwtTest extends \PHPUnit_Framework_TestCase
{
public function test_createKey_1 ()
{
$jwt = new jwt ();
$jwt = new Jwt ();
$res = $jwt->createKey ();
$this->assertSame (40, strlen ($res));
}
public function test_sign_1 ()
{
$jwt = new jwt ();
$jwt = new Jwt ();
$res = $this->invokeMethod ($jwt, "sign", "TEXT TO SIGN", "KEY TO USE",
"HS384");
$this->assertSame (
@@ -29,7 +31,7 @@ class jwtTest extends \PHPUnit_Framework_TestCase
public function test_sign_2 ()
{
$jwt = new jwt ();
$jwt = new Jwt ();
$res = $this->invokeMethod ($jwt, "sign", "text to sign", "KEY TO USE",
"HS384");
$this->assertSame (
@@ -39,7 +41,7 @@ class jwtTest extends \PHPUnit_Framework_TestCase
public function test_sign_3 ()
{
$jwt = new jwt ();
$jwt = new Jwt ();
$res = $this->invokeMethod ($jwt, "sign", "text to sign", "key to use",
"HS384");
$this->assertSame (
@@ -49,7 +51,7 @@ class jwtTest extends \PHPUnit_Framework_TestCase
public function test_encode_1 ()
{
$jwt = new jwt ();
$jwt = new Jwt ();
$res = $jwt->encode (array ("payload" => "value"), "key to use", "HS384");
$this->assertSame (
"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzM4NCJ9.".
@@ -59,7 +61,7 @@ class jwtTest extends \PHPUnit_Framework_TestCase
public function test_decode_1 ()
{
$jwt = new jwt ();
$jwt = new Jwt ();
$res = $jwt->decode (
"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzM4NCJ9.".
"eyJwYXlsb2FkIjoidmFsdWUifQ.".
@@ -71,7 +73,7 @@ class jwtTest extends \PHPUnit_Framework_TestCase
public function test_decode_2 ()
{
$GLOBALS["hash_equals"] = false;
$jwt = new jwt ();
$jwt = new Jwt ();
$res = $jwt->decode (
"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzM4NCJ9.".
"eyJwYXlsb2FkIjoidmFsdWUifQ.".
@@ -82,7 +84,7 @@ class jwtTest extends \PHPUnit_Framework_TestCase
public function test_decode_3 ()
{
$jwt = new jwt ();
$jwt = new Jwt ();
$this->expectException ("Exception", "JWT with Empty algorithm");
$res = $jwt->decode (
"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUXXXXXJ9.".
@@ -93,7 +95,7 @@ class jwtTest extends \PHPUnit_Framework_TestCase
public function test_decode_4 ()
{
$jwt = new jwt ();
$jwt = new Jwt ();
$this->expectException ("Exception", "JWT Payload not readable");
$res = $jwt->decode (
"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzM4NCJ9.".
@@ -104,7 +106,7 @@ class jwtTest extends \PHPUnit_Framework_TestCase
public function test_decode_5 ()
{
$jwt = new jwt ();
$jwt = new Jwt ();
$this->expectException ("Exception",
"JWT Signature verification failed");
$res = $jwt->decode (
@@ -116,7 +118,7 @@ class jwtTest extends \PHPUnit_Framework_TestCase
public function test_decode_6 ()
{
$jwt = new jwt ();
$jwt = new Jwt ();
$this->expectException ("Exception",
"JWT Signature not readable");
$res = $jwt->decode (
@@ -128,7 +130,7 @@ class jwtTest extends \PHPUnit_Framework_TestCase
public function test_decode_7 ()
{
$jwt = new jwt ();
$jwt = new Jwt ();
$this->expectException ("Exception",
"Malformed JWT Token");
$res = $jwt->decode (
@@ -144,7 +146,7 @@ class jwtTest extends \PHPUnit_Framework_TestCase
*/
public function testEncrypt1 ()
{
$jwt = new jwt ();
$jwt = new Jwt ();
$key = $jwt->createKey ();
$res = $jwt->encode (
["email" => "toto@example.com", "password" => "ToTo"],
@@ -156,7 +158,7 @@ class jwtTest extends \PHPUnit_Framework_TestCase
*/
public function testEncrypyt2 ()
{
$jwt = new jwt ();
$jwt = new Jwt ();
$key = $jwt->createKey ();
$payload = (object)["email" => "toto@example.com", "password" => "ToTo"];
$token = $jwt->encode ($payload, $key, "HS256", "123456789012345678901234");
@@ -168,7 +170,7 @@ class jwtTest extends \PHPUnit_Framework_TestCase
*/
public function testEncrypt3 ()
{
$jwt = new jwt ();
$jwt = new Jwt ();
$key = $jwt->createKey ();
$payload = (object)["email" => "toto@example.com", "password" => "ToTo"];
$token = $jwt->encode ($payload, $key, "HS256", "123456789012345678901234");
+19 -17
View File
@@ -7,103 +7,105 @@
namespace Domframework\Tests;
/** Test the macaddresses.php file */
class macaddressesTest extends \PHPUnit_Framework_TestCase
use Domframework\Macaddresses;
/** Test the Macaddresses.php file */
class MacaddressesTest extends \PHPUnit_Framework_TestCase
{
public function test_isMACAddress_1 ()
{
$macaddresses = new macaddresses ();
$macaddresses = new Macaddresses ();
$res = $macaddresses->isMACAddress ("");
$this->assertSame (false, $res);
}
public function test_isMACAddress_2 ()
{
$macaddresses = new macaddresses ();
$macaddresses = new Macaddresses ();
$res = $macaddresses->isMACAddress ("INVALID");
$this->assertSame (false, $res);
}
public function test_isMACAddress_3 ()
{
$macaddresses = new macaddresses ();
$macaddresses = new Macaddresses ();
$res = $macaddresses->isMACAddress ("de:ad:be:af:aa:bb");
$this->assertSame (true, $res);
}
public function test_isMACAddress_4 ()
{
$macaddresses = new macaddresses ();
$macaddresses = new Macaddresses ();
$res = $macaddresses->isMACAddress ("de-ad-be-af-aa-bb");
$this->assertSame (true, $res);
}
public function test_isMACAddress_5 ()
{
$macaddresses = new macaddresses ();
$macaddresses = new Macaddresses ();
$res = $macaddresses->isMACAddress ("0005.313B.9080");
$this->assertSame (true, $res);
}
public function test_isMACAddress_6 ()
{
$macaddresses = new macaddresses ();
$macaddresses = new Macaddresses ();
$res = $macaddresses->isMACAddress ("0005313B9080");
$this->assertSame (true, $res);
}
public function test_isMACAddress_7 ()
{
$macaddresses = new macaddresses ();
$macaddresses = new Macaddresses ();
$res = $macaddresses->isMACAddress ("a0005313B9080a");
$this->assertSame (false, $res);
}
public function test_addSeparator_1 ()
{
$res = macaddresses::addSeparator ("0005313B9080");
$res = Macaddresses::addSeparator ("0005313B9080");
$this->assertSame ("00:05:31:3B:90:80", $res);
}
public function test_addSeparator_2 ()
{
$res = macaddresses::addSeparator ("0005313B9080", "-");
$res = Macaddresses::addSeparator ("0005313B9080", "-");
$this->assertSame ("00-05-31-3B-90-80", $res);
}
public function test_addSeparator_3 ()
{
$res = macaddresses::addSeparator ("0005313B9080", ".", 4);
$res = Macaddresses::addSeparator ("0005313B9080", ".", 4);
$this->assertSame ("0005.313B.9080", $res);
}
public function test_addSeparator_4 ()
{
$this->expectException ();
$res = macaddresses::addSeparator ("INVALID", ".", 4);
$res = Macaddresses::addSeparator ("INVALID", ".", 4);
}
public function test_removeSeparator_1 ()
{
$res = macaddresses::removeSeparator("de:ad:be:af:aa:bb");
$res = Macaddresses::removeSeparator("de:ad:be:af:aa:bb");
$this->assertSame ("deadbeafaabb", $res);
}
public function test_removeSeparator_2 ()
{
$res = macaddresses::removeSeparator("de-ad-be-af-aa-bb");
$res = Macaddresses::removeSeparator("de-ad-be-af-aa-bb");
$this->assertSame ("deadbeafaabb", $res);
}
public function test_removeSeparator_3 ()
{
$res = macaddresses::removeSeparator("dead.beaf.aabb");
$res = Macaddresses::removeSeparator("dead.beaf.aabb");
$this->assertSame ("deadbeafaabb", $res);
}
public function test_removeSeparator_4 ()
{
$res = macaddresses::removeSeparator("deadbeafaabb");
$res = Macaddresses::removeSeparator("deadbeafaabb");
$this->assertSame ("deadbeafaabb", $res);
}
}
+20 -18
View File
@@ -7,12 +7,14 @@
namespace Domframework\Tests;
/** Test the mail.php file */
class mailTest extends \PHPUnit_Framework_TestCase
use Domframework\Mail;
/** Test the Mail.php file */
class MailTest extends \PHPUnit_Framework_TestCase
{
public function test_setBodyText1 ()
{
$mail = new mail ();
$mail = new Mail ();
$mail->setBodyText ("TEST");
$res = $mail->getMail ();
$this->assertRegExp ("#TEST\n$#", $res);
@@ -20,7 +22,7 @@ class mailTest extends \PHPUnit_Framework_TestCase
public function test_setBodyHTML1 ()
{
$mail = new mail ();
$mail = new Mail ();
$mail->setBodyHTML ("TEST");
$res = $mail->getMail ();
$this->assertRegExp ("#^\r\nTEST\n$#m", $res);
@@ -28,7 +30,7 @@ class mailTest extends \PHPUnit_Framework_TestCase
public function test_setGetBodyText1 ()
{
$mail = new mail ();
$mail = new Mail ();
$mail->setBodyText ("TEST");
$res = $mail->getBodyText ();
$this->assertSame ("TEST\n", $res);
@@ -36,7 +38,7 @@ class mailTest extends \PHPUnit_Framework_TestCase
public function test_setGetBodyHtml1 ()
{
$mail = new mail ();
$mail = new Mail ();
$mail->setBodyHtml ("TEST");
$res = $mail->getBodyHtml ();
$this->assertSame ("TEST\n", $res);
@@ -44,7 +46,7 @@ class mailTest extends \PHPUnit_Framework_TestCase
public function test_setFrom1 ()
{
$mail = new mail ();
$mail = new Mail ();
$mail->setFrom ("test@example.com", "Test Exa1mple Com");
$res = $mail->getFrom ();
$this->assertSame ("Test Exa1mple Com <test@example.com>\r\n", $res);
@@ -52,7 +54,7 @@ class mailTest extends \PHPUnit_Framework_TestCase
public function test_addTo1 ()
{
$mail = new mail ();
$mail = new Mail ();
$mail->addTo ("test@example.com", "Test Exa1mple Com");
$res = $mail->getTo ();
$this->assertSame ("Test Exa1mple Com <test@example.com>\r\n", $res);
@@ -60,7 +62,7 @@ class mailTest extends \PHPUnit_Framework_TestCase
public function test_addTo2 ()
{
$mail = new mail ();
$mail = new Mail ();
$mail->addTo ("test@example.com", "Test Exa1mple Com");
$res = $mail->getMail ();
$this->assertRegexp ("#^To: Test Exa1mple Com <test@example.com>\r$#m", $res);
@@ -68,7 +70,7 @@ class mailTest extends \PHPUnit_Framework_TestCase
public function test_setDateTimestamp1 ()
{
$mail = new mail ();
$mail = new Mail ();
$time = time ();
$mail->setDateTimestamp ($time);
$res = $mail->getDateTimestamp ();
@@ -77,7 +79,7 @@ class mailTest extends \PHPUnit_Framework_TestCase
public function test_setDateTimestamp2 ()
{
$mail = new mail ();
$mail = new Mail ();
$time = time ();
$mail->setDateTimestamp ($time);
$res = $mail->getMail ();
@@ -86,7 +88,7 @@ class mailTest extends \PHPUnit_Framework_TestCase
public function test_convertPeopleToArray1 ()
{
$mail = new mail ();
$mail = new Mail ();
$res = $mail->convertPeopleToArray ("toto toto <toto@toto.com>");
$this->assertSame ($res, array (array ("name"=>"toto toto",
"mail"=>"toto@toto.com")));
@@ -94,7 +96,7 @@ class mailTest extends \PHPUnit_Framework_TestCase
public function test_convertPeopleToArray2 ()
{
$mail = new mail ();
$mail = new Mail ();
$res = $mail->convertPeopleToArray ("<toto@toto.com>");
$this->assertSame ($res, array (array ("name"=>"",
"mail"=>"toto@toto.com")));
@@ -102,7 +104,7 @@ class mailTest extends \PHPUnit_Framework_TestCase
public function test_convertPeopleToArray3 ()
{
$mail = new mail ();
$mail = new Mail ();
$res = $mail->convertPeopleToArray ("toto@toto.com,titi@titi.com");
$this->assertSame ($res, array (array ("name" => "",
"mail" => "toto@toto.com"),
@@ -112,7 +114,7 @@ class mailTest extends \PHPUnit_Framework_TestCase
public function test_convertPeopleToArray4 ()
{
$mail = new mail ();
$mail = new Mail ();
$res = $mail->convertPeopleToArray ("toto@toto.com");
$this->assertSame ($res, array (array ("name"=>"",
"mail"=>"toto@toto.com")));
@@ -120,7 +122,7 @@ class mailTest extends \PHPUnit_Framework_TestCase
public function test_convertPeopleToArray5 ()
{
$mail = new mail ();
$mail = new Mail ();
$res = $mail->convertPeopleToArray (" <toto@toto.com> , <titi@titi.com>");
$this->assertSame ($res, array (array ("name" => "",
"mail" => "toto@toto.com"),
@@ -130,7 +132,7 @@ class mailTest extends \PHPUnit_Framework_TestCase
public function test_convertPeopleToArray6 ()
{
$mail = new mail ();
$mail = new Mail ();
$res = $mail->convertPeopleToArray ("ToTo <toto@toto.com> , <titi@titi.com>");
$this->assertSame ($res, array (array ("name" => "ToTo",
"mail" => "toto@toto.com"),
@@ -142,7 +144,7 @@ class mailTest extends \PHPUnit_Framework_TestCase
*/
public function testHeadersToJSON1 ()
{
$mail = new mail ();
$mail = new Mail ();
$mail->readMail ( // {{{
"Return-Path: <dominique.fournier@grenoble.cnrs.fr>
Delivered-To: dominique@fournier38.fr
+47 -45
View File
@@ -7,21 +7,23 @@
namespace Domframework\Tests;
/** Test the outputjson.php file */
class markdownTest extends \PHPUnit_Framework_TestCase
use Domframework\Markdown;
/** Test the Markdown.php file */
class MarkdownTest extends \PHPUnit_Framework_TestCase
{
// TitleSeText
public function testTitleSeText1 ()
{
$this->expectOutputString("<h1>test</h1>");
$md = new markdown ();
$md = new Markdown ();
printf ($md->html ("test\n====\n"), TRUE);
}
public function testTitleSeText2 ()
{
$this->expectOutputString("<h2>test</h2>");
$md = new markdown ();
$md = new Markdown ();
printf ($md->html ("test\n----\n"), TRUE);
}
@@ -29,42 +31,42 @@ class markdownTest extends \PHPUnit_Framework_TestCase
public function testTitleSharp1 ()
{
$this->expectOutputString("<h1>test</h1>");
$md = new markdown ();
$md = new Markdown ();
printf ($md->html ("# test #"));
}
public function testTitleSharp2 ()
{
$this->expectOutputString("<h2>test</h2>");
$md = new markdown ();
$md = new Markdown ();
printf ($md->html ("## test ##"));
}
public function testTitleSharp3 ()
{
$this->expectOutputString("<h3>test</h3>");
$md = new markdown ();
$md = new Markdown ();
printf ($md->html ("### test ###"));
}
public function testTitleSharp4 ()
{
$this->expectOutputString("<h4>test</h4>");
$md = new markdown ();
$md = new Markdown ();
printf ($md->html ("#### test ####"));
}
public function testTitleSharp5 ()
{
$this->expectOutputString("<h5>test</h5>");
$md = new markdown ();
$md = new Markdown ();
printf ($md->html ("##### test #####"));
}
public function testTitleSharp6 ()
{
$this->expectOutputString("<h6>test</h6>");
$md = new markdown ();
$md = new Markdown ();
printf ($md->html ("###### test #######"));
}
@@ -72,42 +74,42 @@ class markdownTest extends \PHPUnit_Framework_TestCase
public function testSeparator1 ()
{
$this->expectOutputString("<hr/>");
$md = new markdown ();
$md = new Markdown ();
printf ($md->html ("---\n"), TRUE);
}
public function testSeparator2 ()
{
$this->expectOutputString("<hr/>");
$md = new markdown ();
$md = new Markdown ();
printf ($md->html ("___\n"), TRUE);
}
public function testSeparator3 ()
{
$this->expectOutputString("<hr/>");
$md = new markdown ();
$md = new Markdown ();
printf ($md->html ("***\n"), TRUE);
}
public function testSeparator4 ()
{
$this->expectOutputString("<hr/>");
$md = new markdown ();
$md = new Markdown ();
printf ($md->html ("- - -\n"), TRUE);
}
public function testSeparator5 ()
{
$this->expectOutputString("<hr/>");
$md = new markdown ();
$md = new Markdown ();
printf ($md->html ("_ _ _\n"), TRUE);
}
public function testSeparator6 ()
{
$this->expectOutputString("<hr/>");
$md = new markdown ();
$md = new Markdown ();
printf ($md->html ("* * *\n"), TRUE);
}
@@ -115,7 +117,7 @@ class markdownTest extends \PHPUnit_Framework_TestCase
public function testSimpleText ()
{
$this->expectOutputString("<p>text</p>");
$md = new markdown ();
$md = new Markdown ();
printf ($md->html ("text"), TRUE);
}
@@ -123,42 +125,42 @@ class markdownTest extends \PHPUnit_Framework_TestCase
public function testEmphasisStrong1 ()
{
$this->expectOutputString("<p><strong>text</strong></p>");
$md = new markdown ();
$md = new Markdown ();
printf ($md->html ("__text__"));
}
public function testEmphasisStrong2 ()
{
$this->expectOutputString("<p><strong>text</strong></p>");
$md = new markdown ();
$md = new Markdown ();
printf ($md->html ("**text**"));
}
public function testEmphasisEM1 ()
{
$this->expectOutputString("<p><em>text</em></p>");
$md = new markdown ();
$md = new Markdown ();
printf ($md->html ("_text_"));
}
public function testEmphasisEM2 ()
{
$this->expectOutputString("<p><em>file1.php</em> or <em>file2.php</em></p>");
$md = new markdown ();
$md = new Markdown ();
printf ($md->html ("_file1.php_ or _file2.php_"));
}
public function testEmphasisEM3 ()
{
$this->expectOutputString("<p><em>text</em></p>");
$md = new markdown ();
$md = new Markdown ();
printf ($md->html ("*text*"));
}
public function testEmphasisEM4 ()
{
$this->expectOutputString("<p><em>text</em> or <em>text2</em></p>");
$md = new markdown ();
$md = new Markdown ();
printf ($md->html ("*text* or *text2*"));
}
@@ -170,7 +172,7 @@ class markdownTest extends \PHPUnit_Framework_TestCase
<li>Case2</li>
<li>Case3</li>
</ul>");
$md = new markdown ();
$md = new Markdown ();
printf ($md->html ("* Case1\n* Case2\n* Case3"), TRUE);
}
@@ -181,7 +183,7 @@ class markdownTest extends \PHPUnit_Framework_TestCase
<li>Case2</li>
<li>Case3</li>
</ul>");
$md = new markdown ();
$md = new Markdown ();
printf ($md->html ("- Case1\n- Case2\n- Case3"), TRUE);
}
@@ -192,7 +194,7 @@ class markdownTest extends \PHPUnit_Framework_TestCase
<li>Case2</li>
<li>Case3</li>
</ul>");
$md = new markdown ();
$md = new Markdown ();
printf ($md->html ("+ Case1\n+ Case2\n+ Case3"), TRUE);
}
@@ -202,7 +204,7 @@ class markdownTest extends \PHPUnit_Framework_TestCase
<li>line1 end</li>
<li>line2 end</li>
</ul>");
$md = new markdown ();
$md = new Markdown ();
printf ($md->html ("* line1
end
* line2
@@ -221,7 +223,7 @@ end"));
</li>
<li>line3</li>
</ul>");
$md = new markdown ();
$md = new Markdown ();
printf ($md->html ("* line1
* line2
* NEW lineA
@@ -237,7 +239,7 @@ end"));
<li>Case2</li>
<li>Case3</li>
</ol>");
$md = new markdown ();
$md = new Markdown ();
printf ($md->html ("1. Case1\n2. Case2\n3. Case3"), TRUE);
}
@@ -247,7 +249,7 @@ end"));
$this->expectOutputString("<pre><code>test
indent
base</code></pre>");
$md = new markdown ();
$md = new Markdown ();
printf ($md->html (" test
indent
base"));
@@ -257,7 +259,7 @@ base</code></pre>");
public function testInlineCode1 ()
{
$this->expectOutputString("<p><code>code</code></p>");
$md = new markdown ();
$md = new Markdown ();
printf ($md->html ("`code`"));
}
@@ -266,7 +268,7 @@ base</code></pre>");
{
$this->expectOutputString(
"<p><a href='http://example.com'>http://example.com</a></p>");
$md = new markdown ();
$md = new Markdown ();
printf ($md->html ("<http://example.com>"));
}
@@ -274,7 +276,7 @@ base</code></pre>");
{
$this->expectOutputString(
"<p><a href='https://example.com'>https://example.com</a></p>");
$md = new markdown ();
$md = new Markdown ();
printf ($md->html ("<https://example.com>"));
}
@@ -282,7 +284,7 @@ base</code></pre>");
{
$this->expectOutputString(
"<p><a href='mailto:test@example.com'>test@example.com</a></p>");
$md = new markdown ();
$md = new Markdown ();
printf ($md->html ("<test@example.com>"));
}
@@ -290,7 +292,7 @@ base</code></pre>");
{
$this->expectOutputString(
"<p><a href='mailto:test_with_underscore@example.com'>test_with_underscore@example.com</a></p>");
$md = new markdown ();
$md = new Markdown ();
printf ($md->html ("<test_with_underscore@example.com>"));
}
@@ -298,7 +300,7 @@ base</code></pre>");
public function testChain1 ()
{
$this->expectOutputString("<h1>t1</h1><h2>t2</h2>");
$md = new markdown ();
$md = new Markdown ();
printf ($md->html ("# t1\n## t2"));
}
@@ -306,7 +308,7 @@ base</code></pre>");
{
$this->expectOutputString("<pre><code>
* OK</code></pre>");
$md = new markdown ();
$md = new Markdown ();
printf ($md->html (" \n * OK"));
}
@@ -314,7 +316,7 @@ base</code></pre>");
{
$this->expectOutputString("<pre><code>
* * * * * www-data OK</code></pre>");
$md = new markdown ();
$md = new Markdown ();
printf ($md->html (" \n * * * * * www-data OK"));
}
@@ -322,7 +324,7 @@ base</code></pre>");
{
$this->expectOutputString("<p>To write</p>
<pre><code>* * * * * www-data OK</code></pre>");
$md = new markdown ();
$md = new Markdown ();
printf ($md->html ("To write
* * * * * www-data OK"));
@@ -335,7 +337,7 @@ base</code></pre>");
<li>line1</li>
<li>line2 end</li>
</ul>");
$md = new markdown ();
$md = new Markdown ();
printf ($md->html ("Hi
* line1
* line2
@@ -345,21 +347,21 @@ end"));
public function testCarriageReturn1 ()
{
$this->expectOutputString("<p>line1 line2</p>");
$md = new markdown ();
$md = new Markdown ();
printf ($md->html ("line1\nline2\n"));
}
public function testCarriageReturn2 ()
{
$this->expectOutputString("<p>line1<br/>line2</p>");
$md = new markdown ();
$md = new Markdown ();
printf ($md->html ("line1 \nline2\n"));
}
public function testCarriageReturn3 ()
{
$this->expectOutputString("<p>line1 line2 line3.</p>");
$md = new markdown ();
$md = new Markdown ();
printf ($md->html ("line1
line2
line3."));
@@ -368,14 +370,14 @@ line3."));
public function testHTMLSpecialChars1 ()
{
$this->expectOutputString("<p>toto&amp;titi</p>");
$md = new markdown ();
$md = new Markdown ();
printf ($md->html ("toto&titi"));
}
public function testHTMLSpecialChars2 ()
{
$this->expectOutputString("<p>toto&eacute;titi</p>");
$md = new markdown ();
$md = new Markdown ();
printf ($md->html ("totoétiti"));
}
}
+20 -18
View File
@@ -7,8 +7,10 @@
namespace Domframework\Tests;
/** Test the outputdl.php file */
class outputdlTest extends \PHPUnit_Framework_TestCase
use Domframework\Outputdl;
/** Test the Outputdl.php file */
class OutputdlTest extends \PHPUnit_Framework_TestCase
{
public function test_outputdl_init ()
{
@@ -25,7 +27,7 @@ class outputdlTest extends \PHPUnit_Framework_TestCase
public function test_outputdl_1 ()
{
// Check the full download content
$outputdl = new outputdl ();
$outputdl = new Outputdl ();
$this->expectOutputString (str_repeat (
"1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\n",
1000));
@@ -35,7 +37,7 @@ class outputdlTest extends \PHPUnit_Framework_TestCase
public function test_outputdl_Announce_1 ()
{
// Check the announce of Resume mode Enabled
$outputdl = new outputdl ();
$outputdl = new Outputdl ();
$outputdl->downloadFile ("/tmp/testDFWoutputDL");
$res = $outputdl->headers ();
$this->assertSame (in_array ("Accept-Ranges: bytes", $res), true);
@@ -44,7 +46,7 @@ class outputdlTest extends \PHPUnit_Framework_TestCase
public function test_outputdl_Announce_2 ()
{
// Check the announce of Resume mode Disabled
$outputdl = new outputdl ();
$outputdl = new Outputdl ();
$outputdl->resumeAllow (false);
$outputdl->downloadFile ("/tmp/testDFWoutputDL");
$res = $outputdl->headers ();
@@ -54,7 +56,7 @@ class outputdlTest extends \PHPUnit_Framework_TestCase
public function test_outputdl_Partial_1 ()
{
// Check the content get with provided range
$outputdl = new outputdl ();
$outputdl = new Outputdl ();
$_SERVER["HTTP_RANGE"] = "bytes=3-9";
$this->expectOutputString ("4567890");
$outputdl->downloadFile ("/tmp/testDFWoutputDL");
@@ -64,7 +66,7 @@ class outputdlTest extends \PHPUnit_Framework_TestCase
public function test_outputdl_Partial_2 ()
{
// Check the content get with provided range
$outputdl = new outputdl ();
$outputdl = new Outputdl ();
$_SERVER["HTTP_RANGE"] = "bytes=3-";
$this->expectOutputString (substr (str_repeat (
"1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\n",
@@ -76,7 +78,7 @@ class outputdlTest extends \PHPUnit_Framework_TestCase
public function test_outputdl_Partial_3 ()
{
// Check the content get with provided range
$outputdl = new outputdl ();
$outputdl = new Outputdl ();
$_SERVER["HTTP_RANGE"] = "bytes=0-";
$this->expectOutputString (str_repeat (
"1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\n",
@@ -88,7 +90,7 @@ class outputdlTest extends \PHPUnit_Framework_TestCase
public function test_outputdl_Partial_4 ()
{
// Check the content get with provided range
$outputdl = new outputdl ();
$outputdl = new Outputdl ();
$_SERVER["HTTP_RANGE"] = "bytes=-5";
$this->expectOutputString ("wxyz\n");
$outputdl->downloadFile ("/tmp/testDFWoutputDL");
@@ -98,7 +100,7 @@ class outputdlTest extends \PHPUnit_Framework_TestCase
public function test_outputdl_Partial_5 ()
{
// Check the content get with provided range
$outputdl = new outputdl ();
$outputdl = new Outputdl ();
$_SERVER["HTTP_RANGE"] = "bytes=0-3,6-9";
$this->expectOutputString ("--Qm91bmRhcnk=\r
Content-Range: bytes 0-3/63000\r
@@ -120,7 +122,7 @@ Content-Type: application/octet-stream\r
{
// Check the invalid provided range
unset ($_SERVER["HTTP_RANGE"]);
$outputdl = new outputdl ();
$outputdl = new Outputdl ();
$_SERVER["HTTP_RANGE"] = "bytes=99999-";
$this->expectException ("Exception", "Invalid range provided", 416);
$outputdl->downloadFile ("/tmp/testDFWoutputDL");
@@ -130,7 +132,7 @@ Content-Type: application/octet-stream\r
{
// Check the invalid provided range
unset ($_SERVER["HTTP_RANGE"]);
$outputdl = new outputdl ();
$outputdl = new Outputdl ();
$_SERVER["HTTP_RANGE"] = "bytes=9-3";
$this->expectException ("Exception", "Invalid range provided", 416);
$outputdl->downloadFile ("/tmp/testDFWoutputDL");
@@ -140,7 +142,7 @@ Content-Type: application/octet-stream\r
{
// Check the invalid provided range
unset ($_SERVER["HTTP_RANGE"]);
$outputdl = new outputdl ();
$outputdl = new Outputdl ();
$_SERVER["HTTP_RANGE"] = "bytes=9-999999";
$this->expectException ("Exception", "Invalid range provided", 416);
$outputdl->downloadFile ("/tmp/testDFWoutputDL");
@@ -150,7 +152,7 @@ Content-Type: application/octet-stream\r
{
// Check the invalid provided range
unset ($_SERVER["HTTP_RANGE"]);
$outputdl = new outputdl ();
$outputdl = new Outputdl ();
$_SERVER["HTTP_RANGE"] = "bytes=-";
$this->expectException ("Exception", "Invalid range provided", 416);
$outputdl->downloadFile ("/tmp/testDFWoutputDL");
@@ -160,7 +162,7 @@ Content-Type: application/octet-stream\r
{
// Check the base comparison : OK
unset ($_SERVER["HTTP_RANGE"]);
$outputdl = new outputdl ();
$outputdl = new Outputdl ();
$outputdl->base ("/tmp");
$this->expectOutputString (str_repeat (
"1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\n",
@@ -172,7 +174,7 @@ Content-Type: application/octet-stream\r
{
// Check the base comparison : BAD
unset ($_SERVER["HTTP_RANGE"]);
$outputdl = new outputdl ();
$outputdl = new Outputdl ();
$outputdl->base ("/tmp");
$this->expectException ("Exception",
"Invalid file to download : out of base", 406);
@@ -183,7 +185,7 @@ Content-Type: application/octet-stream\r
{
// Check the base comparison : BAD Symlink
unset ($_SERVER["HTTP_RANGE"]);
$outputdl = new outputdl ();
$outputdl = new Outputdl ();
$outputdl->base ("/tmp");
$this->expectException ("Exception",
"Invalid file to download : not a file", 406);
@@ -194,7 +196,7 @@ Content-Type: application/octet-stream\r
{
// Check the base comparison : Non existing
unset ($_SERVER["HTTP_RANGE"]);
$outputdl = new outputdl ();
$outputdl = new Outputdl ();
$outputdl->base ("/tmp");
$this->expectException ("Exception",
"Invalid file to download : file doesn't exists", 404);
+9 -7
View File
@@ -7,28 +7,30 @@
namespace Domframework\Tests;
/** Test the outputhtml.php file */
class outputhtmlTest extends \PHPUnit_Framework_TestCase
use Domframework\Outputhtml;
/** Test the Outputhtml.php file */
class OutputhtmlTest extends \PHPUnit_Framework_TestCase
{
/** Entry null */
public function testlayout1 ()
{
$this->expectOutputRegex ("#<body>\s+</body>#");
$output = new outputhtml ();
$output = new Outputhtml ();
$res = $output->out ("");
}
public function testlayout2 ()
{
$this->expectOutputRegex("#data#");
$output = new outputhtml ();
$output = new Outputhtml ();
$res = $output->out ("data");
}
public function testlayout3 ()
{
$this->expectOutputRegex("#data#");
$output = new outputhtml ();
$output = new Outputhtml ();
$res = $output->out ("data", "title");
}
@@ -39,7 +41,7 @@ class outputhtmlTest extends \PHPUnit_Framework_TestCase
Text
"." "."
</body></html>\n");
$output = new outputhtml ();
$output = new Outputhtml ();
$output->out ("data", "title", FALSE, FALSE, "Tests/layout.html" );
}
@@ -50,7 +52,7 @@ class outputhtmlTest extends \PHPUnit_Framework_TestCase
Text
VARIABLE
</body></html>\n");
$output = new outputhtml ();
$output = new Outputhtml ();
$variable = array ("var"=>"VARIABLE");
$output->out ("data", "title", FALSE, FALSE, "Tests/layout.html",
null, $variable);
+7 -5
View File
@@ -7,14 +7,16 @@
namespace Domframework\Tests;
/** Test the outputjson.php file */
class outputjsonTest extends \PHPUnit_Framework_TestCase
use Domframework\Outputjson;
/** Test the Outputjson.php file */
class OutputjsonTest extends \PHPUnit_Framework_TestCase
{
/** Entry null */
public function testoutputjson1 ()
{
$this->expectOutputString("\"\"");
$output = new outputjson ();
$output = new Outputjson ();
$output->out ("");
}
@@ -22,7 +24,7 @@ class outputjsonTest extends \PHPUnit_Framework_TestCase
public function testoutputjson2 ()
{
$this->expectOutputString("\"string\"");
$output = new outputjson ();
$output = new Outputjson ();
$output->out ("string");
}
@@ -30,7 +32,7 @@ class outputjsonTest extends \PHPUnit_Framework_TestCase
public function testoutputjson3 ()
{
$this->expectOutputString("[1,2,3]");
$output = new outputjson ();
$output = new Outputjson ();
$output->out (array (1,2,3));
}
}
+25 -23
View File
@@ -7,24 +7,26 @@
namespace Domframework\Tests;
/** Test the password class
use Domframework\Password;
/** Test the Password class
*/
class passwordTest extends \PHPUnit_Framework_TestCase
class PasswordTest extends \PHPUnit_Framework_TestCase
{
public function test_cryptPasswd_1 ()
{
$res = \password::cryptPasswd ("AAA");
$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");
$res1 = Password::cryptPasswd ("AAA");
echo "RES1=$res1\n";
$res2 = \password::cryptPasswd ("AAA");
$res2 = Password::cryptPasswd ("AAA");
echo "RES2=$res2\n";
$res3 = \password::cryptPasswd ("AAA");
$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
@@ -33,7 +35,7 @@ class passwordTest extends \PHPUnit_Framework_TestCase
public function test_cryptPasswd_3 ()
{
$this->expectException ();
$res = \password::cryptPasswd (false);
$res = Password::cryptPasswd (false);
}
public function test_cryptPassword_MYSQL ()
@@ -127,26 +129,26 @@ class passwordTest extends \PHPUnit_Framework_TestCase
public function test_checkPassword_1 ()
{
$res = \password::checkPassword ("AAA", "AAA");
$res = Password::checkPassword ("AAA", "AAA");
$this->assertSame ($res, false);
}
public function test_checkPassword_2 ()
{
$crypt = \password::cryptPasswd ("AAA");
$res = \password::checkPassword ("AAA", $crypt);
$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"));
$res = Password::checkPassword ("AAA", Password::cryptPasswd ("BBB"));
$this->assertSame ($res, false);
}
public function test_checkPassword_4 ()
{
$res = \password::checkPassword ("AAA",
$res = Password::checkPassword ("AAA",
'$2y$11$Y.E98jbjgDpV61eK..9MT.klzTeg7ulO4WH/B5yA8cAGMIh.zoNXq');
$this->assertSame ($res, true);
}
@@ -154,68 +156,68 @@ class passwordTest extends \PHPUnit_Framework_TestCase
public function test_checkPassword_invalid1 ()
{
$this->expectException ();
$res = \password::checkPassword (false,
$res = Password::checkPassword (false,
'$2y$11$Y.E98jbjgDpV61eK..9MT.klzTeg7ulO4WH/B5yA8cAGMIh.zoNXq');
}
public function test_checkPassword_invalid2 ()
{
$this->expectException ();
$res = \password::checkPassword ("AAA", false);
$res = Password::checkPassword ("AAA", false);
}
public function test_generateASCII_defaultsize ()
{
$res = \password::generateASCII ();
$res = Password::generateASCII ();
$this->assertSame (strlen ($res), 12);
}
public function test_generateASCII_toobig ()
{
$this->expectException ();
$res = \password::generateASCII (112);
$res = Password::generateASCII (112);
}
public function test_generateASCII_toosmall ()
{
$this->expectException ();
$res = \password::generateASCII (0);
$res = Password::generateASCII (0);
}
public function test_generateAlphanum_defaultsize ()
{
$res = \password::generateAlphanum ();
$res = Password::generateAlphanum ();
$this->assertSame (strlen ($res), 12);
}
public function test_generateAlphanum_toobig ()
{
$this->expectException ();
$res = \password::generateAlphanum (112);
$res = Password::generateAlphanum (112);
}
public function test_generateAlphanum_toosmall ()
{
$this->expectException ();
$res = \password::generateAlphanum (0);
$res = Password::generateAlphanum (0);
}
public function test_generateAlphabetical_defaultsize ()
{
$res = \password::generateAlphabetical ();
$res = Password::generateAlphabetical ();
$this->assertSame (strlen ($res), 12);
}
public function test_generateAlphabetical_toobig ()
{
$this->expectException ();
$res = \password::generateAlphabetical (112);
$res = Password::generateAlphabetical (112);
}
public function test_generateAlphabetical_toosmall ()
{
$this->expectException ();
$res = \password::generateAlphabetical (0);
$res = Password::generateAlphabetical (0);
}
public function test_listMethods_1 ()
+5 -3
View File
@@ -7,11 +7,13 @@
namespace Domframework\Tests;
/** Test the queue.php file */
class queueTest extends \PHPUnit_Framework_TestCase
use Domframework\Queue;
/** Test the Queue.php file */
class QueueTest extends \PHPUnit_Framework_TestCase
{
public function test ()
{
$queue = new queue ();
$queue = new Queue ();
}
}
+19 -17
View File
@@ -7,8 +7,10 @@
namespace Domframework\Tests;
/** Test the queuefile.php file */
class queuefileTest extends \PHPUnit_Framework_TestCase
use Domframework\Queuefile;
/** Test the Queuefile.php file */
class QueuefileTest extends \PHPUnit_Framework_TestCase
{
public function test_clean ()
{
@@ -18,7 +20,7 @@ class queuefileTest extends \PHPUnit_Framework_TestCase
public function test_add1 ()
{
$queuefile = new queuefile ();
$queuefile = new Queuefile ();
$queuefile->connect ("file:///tmp/queuefileTest/queuefileTest.json");
$res = $queuefile->add ("test1");
$this->assertSame (true, is_object ($res));
@@ -26,7 +28,7 @@ class queuefileTest extends \PHPUnit_Framework_TestCase
public function test_count1 ()
{
$queuefile = new queuefile ();
$queuefile = new Queuefile ();
$queuefile->connect ("file:///tmp/queuefileTest/queuefileTest.json");
$res = $queuefile->count ();
$this->assertSame (1, $res);
@@ -34,7 +36,7 @@ class queuefileTest extends \PHPUnit_Framework_TestCase
public function test_add2 ()
{
$queuefile = new queuefile ();
$queuefile = new Queuefile ();
$queuefile->connect ("file:///tmp/queuefileTest/queuefileTest.json");
$res = $queuefile->add ("test2");
$this->assertSame (true, is_object ($res));
@@ -42,7 +44,7 @@ class queuefileTest extends \PHPUnit_Framework_TestCase
public function test_count2 ()
{
$queuefile = new queuefile ();
$queuefile = new Queuefile ();
$queuefile->connect ("file:///tmp/queuefileTest/queuefileTest.json");
$res = $queuefile->count ();
$this->assertSame (2, $res);
@@ -50,7 +52,7 @@ class queuefileTest extends \PHPUnit_Framework_TestCase
public function test_getFirst1 ()
{
$queuefile = new queuefile ();
$queuefile = new Queuefile ();
$queuefile->connect ("file:///tmp/queuefileTest/queuefileTest.json");
$res = $queuefile->getFirst ();
$this->assertSame ("test1", $res);
@@ -58,7 +60,7 @@ class queuefileTest extends \PHPUnit_Framework_TestCase
public function test_getLast1 ()
{
$queuefile = new queuefile ();
$queuefile = new Queuefile ();
$queuefile->connect ("file:///tmp/queuefileTest/queuefileTest.json");
$res = $queuefile->getLast ();
$this->assertSame ("test2", $res);
@@ -66,7 +68,7 @@ class queuefileTest extends \PHPUnit_Framework_TestCase
public function test_getRange1 ()
{
$queuefile = new queuefile ();
$queuefile = new Queuefile ();
$queuefile->connect ("file:///tmp/queuefileTest/queuefileTest.json");
$res = $queuefile->getRange (1, 1);
$this->assertSame (["test2"], $res);
@@ -74,7 +76,7 @@ class queuefileTest extends \PHPUnit_Framework_TestCase
public function test_getRange2 ()
{
$queuefile = new queuefile ();
$queuefile = new Queuefile ();
$queuefile->connect ("file:///tmp/queuefileTest/queuefileTest.json");
$res = $queuefile->getRange (0, 2);
$this->assertSame (["test1", "test2"], $res);
@@ -82,7 +84,7 @@ class queuefileTest extends \PHPUnit_Framework_TestCase
public function test_getRange3 ()
{
$queuefile = new queuefile ();
$queuefile = new Queuefile ();
$queuefile->connect ("file:///tmp/queuefileTest/queuefileTest.json");
$this->expectException ();
$res = $queuefile->getRange (0, 3);
@@ -90,7 +92,7 @@ class queuefileTest extends \PHPUnit_Framework_TestCase
public function test_getAll1 ()
{
$queuefile = new queuefile ();
$queuefile = new Queuefile ();
$queuefile->connect ("file:///tmp/queuefileTest/queuefileTest.json");
$res = $queuefile->getAll ();
$this->assertSame (["test1", "test2"], $res);
@@ -99,7 +101,7 @@ class queuefileTest extends \PHPUnit_Framework_TestCase
// AFTER THIS TEST THE FILE WILL BE EMPTY
public function test_getAll2 ()
{
$queuefile = new queuefile ();
$queuefile = new Queuefile ();
$queuefile->connect ("file:///tmp/queuefileTest/queuefileTest.json");
$res = $queuefile->clear ();
$this->assertSame (true, is_object ($res));
@@ -107,7 +109,7 @@ class queuefileTest extends \PHPUnit_Framework_TestCase
public function test_count3 ()
{
$queuefile = new queuefile ();
$queuefile = new Queuefile ();
$queuefile->connect ("file:///tmp/queuefileTest/queuefileTest.json");
$res = $queuefile->count ();
$this->assertSame (0, $res);
@@ -115,7 +117,7 @@ class queuefileTest extends \PHPUnit_Framework_TestCase
public function test_getAll3 ()
{
$queuefile = new queuefile ();
$queuefile = new Queuefile ();
$queuefile->connect ("file:///tmp/queuefileTest/queuefileTest.json");
$res = $queuefile->getAll ();
$this->assertSame ([], $res);
@@ -123,7 +125,7 @@ class queuefileTest extends \PHPUnit_Framework_TestCase
public function test_getFirst2 ()
{
$queuefile = new queuefile ();
$queuefile = new Queuefile ();
$queuefile->connect ("file:///tmp/queuefileTest/queuefileTest.json");
$res = $queuefile->getFirst ();
$this->assertSame (null, $res);
@@ -131,7 +133,7 @@ class queuefileTest extends \PHPUnit_Framework_TestCase
public function test_getLast2 ()
{
$queuefile = new queuefile ();
$queuefile = new Queuefile ();
$queuefile->connect ("file:///tmp/queuefileTest/queuefileTest.json");
$res = $queuefile->getLast ();
$this->assertSame (null, $res);
+5 -3
View File
@@ -7,11 +7,13 @@
namespace Domframework\Tests;
/** Test the ratelimit.php file */
class ratelimitTest extends \PHPUnit_Framework_TestCase
use Domframework\Ratelimit;
/** Test the Ratelimit.php file */
class RatelimitTest extends \PHPUnit_Framework_TestCase
{
public function test_ratelimit0 ()
{
$ratelimit = new ratelimit ();
$ratelimit = new Ratelimit ();
}
}
+9 -7
View File
@@ -7,8 +7,10 @@
namespace Domframework\Tests;
/** Test the ratelimitfile.php file */
class ratelimitfileTest extends \PHPUnit_Framework_TestCase
use Domframework\Ratelimitfile;
/** Test the Ratelimitfile.php file */
class RatelimitfileTest extends \PHPUnit_Framework_TestCase
{
public function test_ratelimitfile0 ()
{
@@ -18,7 +20,7 @@ class ratelimitfileTest extends \PHPUnit_Framework_TestCase
public function test_ratelimitfile1 ()
{
// Create one non ratelimited entry
$ratelimitfile = new ratelimitfile ();
$ratelimitfile = new Ratelimitfile ();
$ratelimitfile->storageDir = "/tmp/testDFWratelimit";
$res = $ratelimitfile->set ("TOTO");
$this->assertSame (true, $res);
@@ -27,7 +29,7 @@ class ratelimitfileTest extends \PHPUnit_Framework_TestCase
public function test_ratelimitfile2 ()
{
// Too much entries
$ratelimitfile = new ratelimitfile ();
$ratelimitfile = new Ratelimitfile ();
$ratelimitfile->storageDir = "/tmp/testDFWratelimit";
$ratelimitfile->set ("TOTO");
$ratelimitfile->set ("TOTO");
@@ -45,7 +47,7 @@ class ratelimitfileTest extends \PHPUnit_Framework_TestCase
public function test_ratelimitfile3 ()
{
// Del the ratelimited entry
$ratelimitfile = new ratelimitfile ();
$ratelimitfile = new Ratelimitfile ();
$ratelimitfile->storageDir = "/tmp/testDFWratelimit";
$res = $ratelimitfile->del ("TOTO");
$this->assertSame (true, $res);
@@ -54,7 +56,7 @@ class ratelimitfileTest extends \PHPUnit_Framework_TestCase
public function test_ratelimitfile4 ()
{
// Create one non ratelimited entry
$ratelimitfile = new ratelimitfile ();
$ratelimitfile = new Ratelimitfile ();
$ratelimitfile->storageDir = "/tmp/testDFWratelimit";
$res = $ratelimitfile->set ("TOTO");
$this->assertSame (true, $res);
@@ -64,7 +66,7 @@ class ratelimitfileTest extends \PHPUnit_Framework_TestCase
{
// Clean expired entries
sleep (2);
$ratelimitfile = new ratelimitfile ();
$ratelimitfile = new Ratelimitfile ();
$ratelimitfile->unittime = 1;
$ratelimitfile->storageDir = "/tmp/testDFWratelimit";
$ratelimitfile->clean ();
+8 -6
View File
@@ -7,14 +7,16 @@
namespace Domframework\Tests;
use Domframework\Rest;
/** Test the domframework REST part */
class restTest extends \PHPUnit_Framework_TestCase
class RestTest extends \PHPUnit_Framework_TestCase
{
/** No param, JSON by default
*/
public function testChooseType1 ()
{
$rest = new \rest ();
$rest = new Rest ();
$res = $rest->chooseType ();
$this->assertSame ($res, "json");
}
@@ -23,7 +25,7 @@ class restTest extends \PHPUnit_Framework_TestCase
*/
public function testChooseType2 ()
{
$rest = new \rest ();
$rest = new Rest ();
$rest->allowedtypes = array ("xml", "csv");
$res = $rest->chooseType ();
$this->assertSame ($res, "xml");
@@ -33,7 +35,7 @@ class restTest extends \PHPUnit_Framework_TestCase
*/
public function testChooseType3 ()
{
$rest = new \rest ();
$rest = new Rest ();
$_SERVER["HTTP_ACCEPT"] = "text/html,application/xml;q=0.9,*/*;q=0.8";
$res = $rest->chooseType ();
$this->assertSame ($res, "xml");
@@ -43,7 +45,7 @@ class restTest extends \PHPUnit_Framework_TestCase
*/
public function testChooseType4 ()
{
$rest = new \rest ();
$rest = new Rest ();
$_SERVER["HTTP_ACCEPT"] = "text/html;q=0.9,*/*;q=0.8";
$res = $rest->chooseType ();
$this->assertSame ($res, "json");
@@ -54,7 +56,7 @@ class restTest extends \PHPUnit_Framework_TestCase
*/
public function testChooseType5 ()
{
$rest = new \rest ();
$rest = new Rest ();
$rest->allowedtypes = array ("xml", "csv");
$_SERVER["HTTP_ACCEPT"] = "text/html;q=0.9,*/*;q=0.8";
$res = $rest->chooseType ();
+74 -72
View File
@@ -7,32 +7,34 @@
namespace Domframework\Tests;
/** Test the robotstxt file
use Domframework\Robotstxt;
/** Test the Robotstxt file
*/
class robotstxtTest extends \PHPUnit_Framework_TestCase
class RobotstxtTest extends \PHPUnit_Framework_TestCase
{
// Empty Robots
public function test_Construct_1 ()
{
$robotstxt = new robotstxt ("", "domsearch");
$robotstxt = new Robotstxt ("", "domsearch");
$res = $robotstxt->allow ();
$this->assertSame ($res, ["/"]);
}
public function test_Construct_2 ()
{
$robotstxt = new robotstxt ("", "domsearch");
$robotstxt = new Robotstxt ("", "domsearch");
$res = $robotstxt->disallow ();
$this->assertSame ($res, array ());
}
public function test_Construct_3 ()
{
$robotstxt = new robotstxt ("", "domsearch");
$robotstxt = new Robotstxt ("", "domsearch");
$res = $robotstxt->sitemaps ();
$this->assertSame ($res, array ());
}
public function test_Construct_4 ()
{
$robotstxt = new robotstxt ("", "domsearch");
$robotstxt = new Robotstxt ("", "domsearch");
$res = $robotstxt->crawldelay ();
$this->assertSame ($res, 3);
}
@@ -40,14 +42,14 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
// Allow
public function test_allow_1 ()
{
$robotstxt = new robotstxt (
$robotstxt = new Robotstxt (
"User-Agent: *\nDisallow:\n", "domsearch");
$res = $robotstxt->allow ();
$this->assertSame ($res, ["/"]);
}
public function test_allow_2 ()
{
$robotstxt = new robotstxt (
$robotstxt = new Robotstxt (
"User-Agent: *\nDisallow:\n\nUser-Agent: DomSearch\nDisallow:\n",
"domsearch");
$res = $robotstxt->allow ();
@@ -55,7 +57,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
}
public function test_allow_3 ()
{
$robotstxt = new robotstxt (
$robotstxt = new Robotstxt (
"User-Agent: DomSearch\nDisallow:\n\nUser-Agent: *\nDisallow:\n",
"domsearch");
$res = $robotstxt->allow ();
@@ -63,7 +65,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
}
public function test_allow_4 ()
{
$robotstxt = new robotstxt (
$robotstxt = new Robotstxt (
"User-Agent: DomSearch\n".
"User-Agent: User1\n".
"User-Agent: User2\n".
@@ -77,14 +79,14 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
// Disallow
public function test_disallow_1 ()
{
$robotstxt = new robotstxt (
$robotstxt = new Robotstxt (
"User-Agent: *\nDisallow: /\n", "domsearch");
$res = $robotstxt->disallow ();
$this->assertSame ($res, ["/"]);
}
public function test_disallow_2 ()
{
$robotstxt = new robotstxt (
$robotstxt = new Robotstxt (
"User-Agent: *\nDisallow: /\n\nUser-Agent: DomSearch\nDisallow: /\n",
"domsearch");
$res = $robotstxt->disallow ();
@@ -92,7 +94,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
}
public function test_disallow_3 ()
{
$robotstxt = new robotstxt (
$robotstxt = new Robotstxt (
"User-Agent: DomSearch\nDisallow: /\n\nUser-Agent: *\nDisallow: /\n",
"domsearch");
$res = $robotstxt->disallow ();
@@ -102,7 +104,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
// Sitemaps
public function test_sitemaps_1 ()
{
$robotstxt = new robotstxt (
$robotstxt = new Robotstxt (
"User-Agent: DomSearch\nDisallow: /\n\nUser-Agent: *\nDisallow: /\n",
"domsearch");
$res = $robotstxt->sitemaps ();
@@ -110,7 +112,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
}
public function test_sitemaps_2 ()
{
$robotstxt = new robotstxt (
$robotstxt = new Robotstxt (
"User-Agent: *\nDisallow: /\nSitemap: http://example.com/sitemap.xml",
"domsearch");
$res = $robotstxt->sitemaps ();
@@ -118,7 +120,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
}
public function test_sitemaps_3 ()
{
$robotstxt = new robotstxt (
$robotstxt = new Robotstxt (
"User-Agent: *\nDisallow: /\n".
"Sitemap: http://example.com/sitemap.xml\n".
"Sitemap: http://example.com/SITEMAP.XML", "domsearch");
@@ -129,7 +131,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
public function test_sitemaps_error_1 ()
{
$robotstxt = new robotstxt (
$robotstxt = new Robotstxt (
"User-Agent: *\nDisallow: /\nSitemap: URL",
"domsearch");
$res = $robotstxt->errors ();
@@ -139,28 +141,28 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
// Host
public function test_host_1 ()
{
$robotstxt = new robotstxt (
$robotstxt = new Robotstxt (
"User-Agent: *\nDisallow: /\n", "domsearch");
$res = $robotstxt->host ();
$this->assertSame ($res, null);
}
public function test_host_2 ()
{
$robotstxt = new robotstxt (
$robotstxt = new Robotstxt (
"User-Agent: *\nDisallow: /\n\nHost: localhost", "domsearch");
$res = $robotstxt->host ();
$this->assertSame ($res, "localhost");
}
public function test_host_error_1 ()
{
$robotstxt = new robotstxt (
$robotstxt = new Robotstxt (
"User-Agent: *\nDisallow: /\n\nHost: localhost\nHoST: toto", "domsearch");
$res = $robotstxt->host ();
$this->assertSame ($res, "localhost");
}
public function test_host_error_2 ()
{
$robotstxt = new robotstxt (
$robotstxt = new Robotstxt (
"User-Agent: *\nDisallow: /\n\nHost: localhost\nHoST: toto", "domsearch");
$res = $robotstxt->errors ();
$this->assertSame ($res, [4 => "Multiple Hosts set"]);
@@ -169,48 +171,48 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
// URLAllow
public function test_urlallow_1 ()
{
$robotstxt = new robotstxt ("", "domsearch");
$robotstxt = new Robotstxt ("", "domsearch");
$res = $robotstxt->URLAllow ("/");
$this->assertSame ($res, true);
}
public function test_urlallow_2 ()
{
$robotstxt = new robotstxt (
$robotstxt = new Robotstxt (
"User-Agent: *\nDisallow: /", "domsearch");
$res = $robotstxt->URLAllow ("/");
$this->assertSame ($res, false);
}
public function test_urlallow_3 ()
{
$robotstxt = new robotstxt (
$robotstxt = new Robotstxt (
"User-Agent: *\nDisallow: /\nAllow: /allow/", "domsearch");
$res = $robotstxt->URLAllow ("/");
$this->assertSame ($res, false);
}
public function test_urlallow_4 ()
{
$robotstxt = new robotstxt (
$robotstxt = new Robotstxt (
"User-Agent: *\nDisallow: /\nAllow: /allow/", "domsearch");
$res = $robotstxt->URLAllow ("/allow/file");
$this->assertSame ($res, true);
}
public function test_urlallow_5 ()
{
$robotstxt = new robotstxt (
$robotstxt = new Robotstxt (
"User-Agent: *\nDisallow: /\nAllow: /allow/*.gif$", "domsearch");
$res = $robotstxt->URLAllow ("/allow/file.gif");
$this->assertSame ($res, true);
}
public function test_urlallow_6 ()
{
$robotstxt = new robotstxt (
$robotstxt = new Robotstxt (
"User-Agent: *\nDisallow: /\nAllow: /allow/*.gif$", "domsearch");
$res = $robotstxt->URLAllow ("/allow/.gif");
$this->assertSame ($res, false);
}
public function test_urlallow_7 ()
{
$robotstxt = new robotstxt (
$robotstxt = new Robotstxt (
"User-Agent: *\nDisallow: /\nAllow: /allow/*.gif\$", "domsearch");
$res = $robotstxt->URLAllow ("/allow/file.png");
$this->assertSame ($res, false);
@@ -220,7 +222,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
public function test_rfc_unhipbot_1 ()
{
// {{{
$robotstxt = new robotstxt (
$robotstxt = new Robotstxt (
"# /robots.txt for http://www.fict.org/
# comments to webmaster@fict.org
@@ -245,7 +247,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
public function test_rfc_unhipbot_2 ()
{
// {{{
$robotstxt = new robotstxt (
$robotstxt = new Robotstxt (
"# /robots.txt for http://www.fict.org/
# comments to webmaster@fict.org
@@ -270,7 +272,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
public function test_rfc_unhipbot_3 ()
{
// {{{
$robotstxt = new robotstxt (
$robotstxt = new Robotstxt (
"# /robots.txt for http://www.fict.org/
# comments to webmaster@fict.org
@@ -295,7 +297,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
public function test_rfc_unhipbot_4 ()
{
// {{{
$robotstxt = new robotstxt (
$robotstxt = new Robotstxt (
"# /robots.txt for http://www.fict.org/
# comments to webmaster@fict.org
@@ -320,7 +322,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
public function test_rfc_unhipbot_5 ()
{
// {{{
$robotstxt = new robotstxt (
$robotstxt = new Robotstxt (
"# /robots.txt for http://www.fict.org/
# comments to webmaster@fict.org
@@ -345,7 +347,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
public function test_rfc_unhipbot_6 ()
{
// {{{
$robotstxt = new robotstxt (
$robotstxt = new Robotstxt (
"# /robots.txt for http://www.fict.org/
# comments to webmaster@fict.org
@@ -370,7 +372,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
public function test_rfc_unhipbot_7 ()
{
// {{{
$robotstxt = new robotstxt (
$robotstxt = new Robotstxt (
"# /robots.txt for http://www.fict.org/
# comments to webmaster@fict.org
@@ -395,7 +397,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
public function test_rfc_unhipbot_8 ()
{
// {{{
$robotstxt = new robotstxt (
$robotstxt = new Robotstxt (
"# /robots.txt for http://www.fict.org/
# comments to webmaster@fict.org
@@ -420,7 +422,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
public function test_rfc_unhipbot_9 ()
{
// {{{
$robotstxt = new robotstxt (
$robotstxt = new Robotstxt (
"# /robots.txt for http://www.fict.org/
# comments to webmaster@fict.org
@@ -445,7 +447,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
public function test_rfc_unhipbot_10 ()
{
// {{{
$robotstxt = new robotstxt (
$robotstxt = new Robotstxt (
"# /robots.txt for http://www.fict.org/
# comments to webmaster@fict.org
@@ -470,7 +472,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
public function test_rfc_unhipbot_11 ()
{
// {{{
$robotstxt = new robotstxt (
$robotstxt = new Robotstxt (
"# /robots.txt for http://www.fict.org/
# comments to webmaster@fict.org
@@ -495,7 +497,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
public function test_rfc_webcrawler_1 ()
{
// {{{
$robotstxt = new robotstxt (
$robotstxt = new Robotstxt (
"# /robots.txt for http://www.fict.org/
# comments to webmaster@fict.org
@@ -520,7 +522,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
public function test_rfc_webcrawler_2 ()
{
// {{{
$robotstxt = new robotstxt (
$robotstxt = new Robotstxt (
"# /robots.txt for http://www.fict.org/
# comments to webmaster@fict.org
@@ -545,7 +547,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
public function test_rfc_webcrawler_3 ()
{
// {{{
$robotstxt = new robotstxt (
$robotstxt = new Robotstxt (
"# /robots.txt for http://www.fict.org/
# comments to webmaster@fict.org
@@ -570,7 +572,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
public function test_rfc_webcrawler_4 ()
{
// {{{
$robotstxt = new robotstxt (
$robotstxt = new Robotstxt (
"# /robots.txt for http://www.fict.org/
# comments to webmaster@fict.org
@@ -595,7 +597,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
public function test_rfc_webcrawler_5 ()
{
// {{{
$robotstxt = new robotstxt (
$robotstxt = new Robotstxt (
"# /robots.txt for http://www.fict.org/
# comments to webmaster@fict.org
@@ -620,7 +622,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
public function test_rfc_webcrawler_6 ()
{
// {{{
$robotstxt = new robotstxt (
$robotstxt = new Robotstxt (
"# /robots.txt for http://www.fict.org/
# comments to webmaster@fict.org
@@ -645,7 +647,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
public function test_rfc_webcrawler_7 ()
{
// {{{
$robotstxt = new robotstxt (
$robotstxt = new Robotstxt (
"# /robots.txt for http://www.fict.org/
# comments to webmaster@fict.org
@@ -670,7 +672,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
public function test_rfc_webcrawler_8 ()
{
// {{{
$robotstxt = new robotstxt (
$robotstxt = new Robotstxt (
"# /robots.txt for http://www.fict.org/
# comments to webmaster@fict.org
@@ -695,7 +697,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
public function test_rfc_webcrawler_9 ()
{
// {{{
$robotstxt = new robotstxt (
$robotstxt = new Robotstxt (
"# /robots.txt for http://www.fict.org/
# comments to webmaster@fict.org
@@ -720,7 +722,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
public function test_rfc_webcrawler_10 ()
{
// {{{
$robotstxt = new robotstxt (
$robotstxt = new Robotstxt (
"# /robots.txt for http://www.fict.org/
# comments to webmaster@fict.org
@@ -745,7 +747,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
public function test_rfc_webcrawler_11 ()
{
// {{{
$robotstxt = new robotstxt (
$robotstxt = new Robotstxt (
"# /robots.txt for http://www.fict.org/
# comments to webmaster@fict.org
@@ -770,7 +772,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
public function test_rfc_excite_1 ()
{
// {{{
$robotstxt = new robotstxt (
$robotstxt = new Robotstxt (
"# /robots.txt for http://www.fict.org/
# comments to webmaster@fict.org
@@ -795,7 +797,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
public function test_rfc_excite_2 ()
{
// {{{
$robotstxt = new robotstxt (
$robotstxt = new Robotstxt (
"# /robots.txt for http://www.fict.org/
# comments to webmaster@fict.org
@@ -820,7 +822,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
public function test_rfc_excite_3 ()
{
// {{{
$robotstxt = new robotstxt (
$robotstxt = new Robotstxt (
"# /robots.txt for http://www.fict.org/
# comments to webmaster@fict.org
@@ -845,7 +847,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
public function test_rfc_excite_4 ()
{
// {{{
$robotstxt = new robotstxt (
$robotstxt = new Robotstxt (
"# /robots.txt for http://www.fict.org/
# comments to webmaster@fict.org
@@ -870,7 +872,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
public function test_rfc_excite_5 ()
{
// {{{
$robotstxt = new robotstxt (
$robotstxt = new Robotstxt (
"# /robots.txt for http://www.fict.org/
# comments to webmaster@fict.org
@@ -895,7 +897,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
public function test_rfc_excite_6 ()
{
// {{{
$robotstxt = new robotstxt (
$robotstxt = new Robotstxt (
"# /robots.txt for http://www.fict.org/
# comments to webmaster@fict.org
@@ -920,7 +922,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
public function test_rfc_excite_7 ()
{
// {{{
$robotstxt = new robotstxt (
$robotstxt = new Robotstxt (
"# /robots.txt for http://www.fict.org/
# comments to webmaster@fict.org
@@ -945,7 +947,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
public function test_rfc_excite_8 ()
{
// {{{
$robotstxt = new robotstxt (
$robotstxt = new Robotstxt (
"# /robots.txt for http://www.fict.org/
# comments to webmaster@fict.org
@@ -970,7 +972,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
public function test_rfc_excite_9 ()
{
// {{{
$robotstxt = new robotstxt (
$robotstxt = new Robotstxt (
"# /robots.txt for http://www.fict.org/
# comments to webmaster@fict.org
@@ -995,7 +997,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
public function test_rfc_excite_10 ()
{
// {{{
$robotstxt = new robotstxt (
$robotstxt = new Robotstxt (
"# /robots.txt for http://www.fict.org/
# comments to webmaster@fict.org
@@ -1020,7 +1022,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
public function test_rfc_excite_11 ()
{
// {{{
$robotstxt = new robotstxt (
$robotstxt = new Robotstxt (
"# /robots.txt for http://www.fict.org/
# comments to webmaster@fict.org
@@ -1045,7 +1047,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
public function test_rfc_other_1 ()
{
// {{{
$robotstxt = new robotstxt (
$robotstxt = new Robotstxt (
"# /robots.txt for http://www.fict.org/
# comments to webmaster@fict.org
@@ -1069,7 +1071,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
public function test_rfc_other_2 ()
{
// {{{
$robotstxt = new robotstxt (
$robotstxt = new Robotstxt (
"# /robots.txt for http://www.fict.org/
# comments to webmaster@fict.org
@@ -1094,7 +1096,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
public function test_rfc_other_3 ()
{
// {{{
$robotstxt = new robotstxt (
$robotstxt = new Robotstxt (
"# /robots.txt for http://www.fict.org/
# comments to webmaster@fict.org
@@ -1119,7 +1121,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
public function test_rfc_other_4 ()
{
// {{{
$robotstxt = new robotstxt (
$robotstxt = new Robotstxt (
"# /robots.txt for http://www.fict.org/
# comments to webmaster@fict.org
@@ -1144,7 +1146,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
public function test_rfc_other_5 ()
{
// {{{
$robotstxt = new robotstxt (
$robotstxt = new Robotstxt (
"# /robots.txt for http://www.fict.org/
# comments to webmaster@fict.org
@@ -1169,7 +1171,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
public function test_rfc_other_6 ()
{
// {{{
$robotstxt = new robotstxt (
$robotstxt = new Robotstxt (
"# /robots.txt for http://www.fict.org/
# comments to webmaster@fict.org
@@ -1194,7 +1196,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
public function test_rfc_other_7 ()
{
// {{{
$robotstxt = new robotstxt (
$robotstxt = new Robotstxt (
"# /robots.txt for http://www.fict.org/
# comments to webmaster@fict.org
@@ -1219,7 +1221,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
public function test_rfc_other_8 ()
{
// {{{
$robotstxt = new robotstxt (
$robotstxt = new Robotstxt (
"# /robots.txt for http://www.fict.org/
# comments to webmaster@fict.org
@@ -1244,7 +1246,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
public function test_rfc_other_9 ()
{
// {{{
$robotstxt = new robotstxt (
$robotstxt = new Robotstxt (
"# /robots.txt for http://www.fict.org/
# comments to webmaster@fict.org
@@ -1269,7 +1271,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
public function test_rfc_other_10 ()
{
// {{{
$robotstxt = new robotstxt (
$robotstxt = new Robotstxt (
"# /robots.txt for http://www.fict.org/
# comments to webmaster@fict.org
@@ -1294,7 +1296,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
public function test_rfc_other_11 ()
{
// {{{
$robotstxt = new robotstxt (
$robotstxt = new Robotstxt (
"# /robots.txt for http://www.fict.org/
# comments to webmaster@fict.org
+31 -29
View File
@@ -7,14 +7,16 @@
namespace Domframework\Tests;
/** Test the route.php file */
class routeTest extends \PHPUnit_Framework_TestCase
use Domframework\Route;
/** Test the Route.php file */
class RouteTest extends \PHPUnit_Framework_TestCase
{
/// RELATIVE ///
/** Entry null */
public function test_baseURL_1_relative ()
{
$route = new route ();
$route = new Route ();
$route->baseURL ();
$this->expectOutputString("");
}
@@ -25,7 +27,7 @@ class routeTest extends \PHPUnit_Framework_TestCase
$_SERVER["SERVER_NAME"] = "localhost";
$_SERVER["SERVER_PORT"] = "80";
$_SERVER["SCRIPT_NAME"] = "/index.php";
$route = new route ();
$route = new Route ();
echo $route->baseURL ();
$this->expectOutputString("/");
}
@@ -38,7 +40,7 @@ class routeTest extends \PHPUnit_Framework_TestCase
$_SERVER["SERVER_PORT"] = "443";
$_SERVER["HTTPS"] = true;
$_SERVER["SCRIPT_NAME"] = "/index.php";
$route = new route ();
$route = new Route ();
echo $route->baseURL ();
$this->expectOutputString("/");
}
@@ -50,7 +52,7 @@ class routeTest extends \PHPUnit_Framework_TestCase
$_SERVER["SERVER_NAME"] = "localhost";
$_SERVER["SERVER_PORT"] = "888";
$_SERVER["SCRIPT_NAME"] = "/index.php";
$route = new route ();
$route = new Route ();
echo $route->baseURL ();
$this->expectOutputString("/");
}
@@ -62,7 +64,7 @@ class routeTest extends \PHPUnit_Framework_TestCase
$_SERVER["SERVER_PORT"] = "888";
$_SERVER["HTTPS"] = true;
$_SERVER["SCRIPT_NAME"] = "/index.php";
$route = new route ();
$route = new Route ();
echo $route->baseURL ();
$this->expectOutputString("/");
}
@@ -74,7 +76,7 @@ class routeTest extends \PHPUnit_Framework_TestCase
$_SERVER["SERVER_NAME"] = "localhost";
$_SERVER["SERVER_PORT"] = "80";
$_SERVER["SCRIPT_NAME"] = "/module/index.php";
$route = new route ();
$route = new Route ();
echo $route->baseURL ("module");
$this->expectOutputString("/");
}
@@ -86,7 +88,7 @@ class routeTest extends \PHPUnit_Framework_TestCase
$_SERVER["SERVER_PORT"] = "443";
$_SERVER["HTTPS"] = true;
$_SERVER["SCRIPT_NAME"] = "/module/index.php";
$route = new route ();
$route = new Route ();
echo $route->baseURL ("module");
$this->expectOutputString("/");
}
@@ -98,7 +100,7 @@ class routeTest extends \PHPUnit_Framework_TestCase
$_SERVER["SERVER_NAME"] = "localhost";
$_SERVER["SERVER_PORT"] = "888";
$_SERVER["SCRIPT_NAME"] = "/module/index.php";
$route = new route ();
$route = new Route ();
echo $route->baseURL ("module");
$this->expectOutputString("/");
}
@@ -110,7 +112,7 @@ class routeTest extends \PHPUnit_Framework_TestCase
$_SERVER["SERVER_PORT"] = "888";
$_SERVER["HTTPS"] = true;
$_SERVER["SCRIPT_NAME"] = "/module/index.php";
$route = new route ();
$route = new Route ();
echo $route->baseURL ("module");
$this->expectOutputString("/");
}
@@ -119,7 +121,7 @@ class routeTest extends \PHPUnit_Framework_TestCase
/** Entry null */
public function test_baseURL_1_absolute ()
{
$route = new route ();
$route = new Route ();
$route->baseURL (false, true);
$this->expectOutputString("");
}
@@ -130,7 +132,7 @@ class routeTest extends \PHPUnit_Framework_TestCase
$_SERVER["SERVER_NAME"] = "localhost";
$_SERVER["SERVER_PORT"] = "80";
$_SERVER["SCRIPT_NAME"] = "/index.php";
$route = new route ();
$route = new Route ();
echo $route->baseURL (false, true);
$this->expectOutputString("https://localhost:80/");
}
@@ -143,7 +145,7 @@ class routeTest extends \PHPUnit_Framework_TestCase
$_SERVER["SERVER_PORT"] = "443";
$_SERVER["HTTPS"] = true;
$_SERVER["SCRIPT_NAME"] = "/index.php";
$route = new route ();
$route = new Route ();
echo $route->baseURL (false, true);
$this->expectOutputString("https://localhost/");
}
@@ -155,7 +157,7 @@ class routeTest extends \PHPUnit_Framework_TestCase
$_SERVER["SERVER_NAME"] = "localhost";
$_SERVER["SERVER_PORT"] = "888";
$_SERVER["SCRIPT_NAME"] = "/index.php";
$route = new route ();
$route = new Route ();
echo $route->baseURL (false, true);
$this->expectOutputString("http://localhost:888/");
}
@@ -167,7 +169,7 @@ class routeTest extends \PHPUnit_Framework_TestCase
$_SERVER["SERVER_PORT"] = "888";
$_SERVER["HTTPS"] = true;
$_SERVER["SCRIPT_NAME"] = "/index.php";
$route = new route ();
$route = new Route ();
echo $route->baseURL (false, true);
$this->expectOutputString("https://localhost:888/");
}
@@ -179,7 +181,7 @@ class routeTest extends \PHPUnit_Framework_TestCase
$_SERVER["SERVER_NAME"] = "localhost";
$_SERVER["SERVER_PORT"] = "80";
$_SERVER["SCRIPT_NAME"] = "/module/index.php";
$route = new route ();
$route = new Route ();
echo $route->baseURL ("module", true);
$this->expectOutputString("http://localhost/");
}
@@ -191,7 +193,7 @@ class routeTest extends \PHPUnit_Framework_TestCase
$_SERVER["SERVER_PORT"] = "443";
$_SERVER["HTTPS"] = true;
$_SERVER["SCRIPT_NAME"] = "/module/index.php";
$route = new route ();
$route = new Route ();
echo $route->baseURL ("module", true);
$this->expectOutputString("https://localhost/");
}
@@ -203,7 +205,7 @@ class routeTest extends \PHPUnit_Framework_TestCase
$_SERVER["SERVER_NAME"] = "localhost";
$_SERVER["SERVER_PORT"] = "888";
$_SERVER["SCRIPT_NAME"] = "/module/index.php";
$route = new route ();
$route = new Route ();
echo $route->baseURL ("module", true);
$this->expectOutputString("http://localhost:888/");
}
@@ -215,7 +217,7 @@ class routeTest extends \PHPUnit_Framework_TestCase
$_SERVER["SERVER_PORT"] = "888";
$_SERVER["HTTPS"] = true;
$_SERVER["SCRIPT_NAME"] = "/module/index.php";
$route = new route ();
$route = new Route ();
echo $route->baseURL ("module", true);
$this->expectOutputString("https://localhost:888/");
}
@@ -229,7 +231,7 @@ class routeTest extends \PHPUnit_Framework_TestCase
$_SERVER["SERVER_PORT"] = "80";
$_SERVER["SCRIPT_NAME"] = "/index.php";
$_SERVER["REQUEST_URI"] = "/index.php?url=bla";
$route = new route ();
$route = new Route ();
echo $route->requestURL ();
$this->expectOutputString("index.php?url=bla");
}
@@ -242,7 +244,7 @@ class routeTest extends \PHPUnit_Framework_TestCase
$_SERVER["HTTPS"] = true;
$_SERVER["SCRIPT_NAME"] = "/index.php";
$_SERVER["REQUEST_URI"] = "/index.php?var=1";
$route = new route ();
$route = new Route ();
echo $route->requestURL ();
$this->expectOutputString("index.php?var=1");
}
@@ -255,7 +257,7 @@ class routeTest extends \PHPUnit_Framework_TestCase
$_SERVER["SERVER_PORT"] = "888";
$_SERVER["SCRIPT_NAME"] = "/index.php";
$_SERVER["REQUEST_URI"] = "/index.php?var=1";
$route = new route ();
$route = new Route ();
echo $route->requestURL ();
$this->expectOutputString("index.php?var=1");
}
@@ -268,7 +270,7 @@ class routeTest extends \PHPUnit_Framework_TestCase
$_SERVER["HTTPS"] = true;
$_SERVER["SCRIPT_NAME"] = "/index.php";
$_SERVER["REQUEST_URI"] = "/index.php?var=1";
$route = new route ();
$route = new Route ();
echo $route->requestURL ();
$this->expectOutputString("index.php?var=1");
}
@@ -281,7 +283,7 @@ class routeTest extends \PHPUnit_Framework_TestCase
$_SERVER["SERVER_PORT"] = "80";
$_SERVER["SCRIPT_NAME"] = "/index.php";
$_SERVER["REQUEST_URI"] = "/bla";
$route = new route ();
$route = new Route ();
echo $route->requestURL ();
$this->expectOutputString("bla");
}
@@ -294,7 +296,7 @@ class routeTest extends \PHPUnit_Framework_TestCase
$_SERVER["HTTPS"] = true;
$_SERVER["SCRIPT_NAME"] = "/index.php";
$_SERVER["REQUEST_URI"] = "/var=1";
$route = new route ();
$route = new Route ();
echo $route->requestURL ();
$this->expectOutputString("var=1");
}
@@ -307,7 +309,7 @@ class routeTest extends \PHPUnit_Framework_TestCase
$_SERVER["SERVER_PORT"] = "888";
$_SERVER["SCRIPT_NAME"] = "/index.php";
$_SERVER["REQUEST_URI"] = "/var=1";
$route = new route ();
$route = new Route ();
echo $route->requestURL ();
$this->expectOutputString("var=1");
}
@@ -320,7 +322,7 @@ class routeTest extends \PHPUnit_Framework_TestCase
$_SERVER["HTTPS"] = true;
$_SERVER["SCRIPT_NAME"] = "/index.php";
$_SERVER["REQUEST_URI"] = "/var=1";
$route = new route ();
$route = new Route ();
echo $route->requestURL ();
$this->expectOutputString("var=1");
}
@@ -328,7 +330,7 @@ class routeTest extends \PHPUnit_Framework_TestCase
/** Ratelimiting in errors */
public function test_errorRateLimit1 ()
{
$route = new route ();
$route = new Route ();
$route->ratelimiter->storageDir = "/tmp/ratelimit-".time();
$route->error (new \Exception ("test1", 500));
$route->error (new \Exception ("test2", 500));
+12 -10
View File
@@ -7,21 +7,23 @@
namespace Domframework\Tests;
use Domframework\Rss;
/** Test the RSS */
class rssTest extends \PHPUnit_Framework_TestCase
class RssTest extends \PHPUnit_Framework_TestCase
{
public function test_empty0 ()
{
// Empty
$this->expectException ("Exception", "No title is provided for this RSS");
$rss = new rss ();
$rss = new Rss ();
$res = $rss->asXML ();
}
public function test_functional1 ()
{
// Functionnal 1
$rss = new rss ();
$rss = new Rss ();
$rss->title ("Global Title")
->link ("http://localhost")
->language ("fr-fr")
@@ -62,7 +64,7 @@ class rssTest extends \PHPUnit_Framework_TestCase
// Missing global description
$this->expectException ("Exception",
"No description is provided for this RSS");
$rss = new rss ();
$rss = new Rss ();
$rss->title ("Global Title")
->link ("http://localhost")
->language ("fr-fr");
@@ -73,7 +75,7 @@ class rssTest extends \PHPUnit_Framework_TestCase
{
// Missing global link
$this->expectException ("Exception", "No link is provided for this RSS");
$rss = new rss ();
$rss = new Rss ();
$rss->title ("Global Title")
->language ("fr-fr")
->description ("The Super Global Description");
@@ -84,7 +86,7 @@ class rssTest extends \PHPUnit_Framework_TestCase
{
// Missing global title
$this->expectException ("Exception", "No title is provided for this RSS");
$rss = new rss ();
$rss = new Rss ();
$rss->link ("http://localhost")
->language ("fr-fr")
->description ("The Super Global Description");
@@ -96,7 +98,7 @@ class rssTest extends \PHPUnit_Framework_TestCase
// Invalid date provided
$this->expectException ("Exception",
"lastBuildDate provided to RSS is not a valid date");
$rss = new rss ();
$rss = new Rss ();
$rss->title ("Global Title")
->link ("http://localhost")
->lastBuildDate ("2017-04-33")
@@ -110,7 +112,7 @@ class rssTest extends \PHPUnit_Framework_TestCase
// Empty Item provided
$this->expectException ("Exception",
"No title nor description defined in the RSS item");
$rss = new rss ();
$rss = new Rss ();
$rss->title ("Global Title")
->link ("http://localhost")
->lastBuildDate ("2017-04-30 12:35:32")
@@ -125,7 +127,7 @@ class rssTest extends \PHPUnit_Framework_TestCase
// Item without Title and Description
$this->expectException ("Exception",
"No title nor description defined in the RSS item");
$rss = new rss ();
$rss = new Rss ();
$rss->title ("Global Title")
->link ("http://localhost")
->lastBuildDate ("2017-04-30 12:35:32")
@@ -140,7 +142,7 @@ class rssTest extends \PHPUnit_Framework_TestCase
// Item with invalid date
$this->expectException ("Exception",
"pubDate provided to RSS Item is not a valid date");
$rss = new rss ();
$rss = new Rss ();
$rss->title ("Global Title")
->link ("http://localhost")
->lastBuildDate ("2017-10-30 12:35:32")
+10 -8
View File
@@ -7,14 +7,16 @@
namespace Domframework\Tests;
/** Test the sitemap.php file
use Domframework\Sitemap;
/** Test the Sitemap.php file
*/
class sitemapTest extends \PHPUnit_Framework_TestCase
class SitemapTest extends \PHPUnit_Framework_TestCase
{
// Empty Sitemap
public function test_EmptySitemap_1 ()
{
$sitemap = new sitemap ();
$sitemap = new Sitemap ();
$res = $sitemap->analyze ("", "http://example.com");
$this->assertSame ($res, ["urls" => [], "sitemaps" => []]);
}
@@ -22,7 +24,7 @@ class sitemapTest extends \PHPUnit_Framework_TestCase
// Empty Sitemap
public function test_EmptySitemap_2 ()
{
$sitemap = new sitemap ();
$sitemap = new Sitemap ();
$res = $sitemap->analyze (" ", "http://example.com");
$this->assertSame ($res, ["urls" => [], "sitemaps" => []]);
}
@@ -30,7 +32,7 @@ class sitemapTest extends \PHPUnit_Framework_TestCase
// Textual Sitemap
public function test_TextualSitemap_1 ()
{
$sitemap = new sitemap ();
$sitemap = new Sitemap ();
$res = $sitemap->analyze ("http://example.com", "http://example.com");
$this->assertSame ($res,
["urls" => ["http://example.com" => []],
@@ -38,7 +40,7 @@ class sitemapTest extends \PHPUnit_Framework_TestCase
}
public function test_TextualSitemap_2 ()
{
$sitemap = new sitemap ();
$sitemap = new Sitemap ();
$res = $sitemap->analyze ("http://example.com\nhttps://www.example.com\n\n",
"http://example.com");
$this->assertSame ($res,
@@ -49,7 +51,7 @@ class sitemapTest extends \PHPUnit_Framework_TestCase
// XML Sitemap
public function test_XMLSitemap_1 ()
{
$sitemap = new sitemap ();
$sitemap = new Sitemap ();
$res = $sitemap->analyze (
'<?xml version="1.0" encoding="utf-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
@@ -74,7 +76,7 @@ class sitemapTest extends \PHPUnit_Framework_TestCase
public function test_XMLSitemap_2 ()
{
$sitemap = new sitemap ();
$sitemap = new Sitemap ();
$res = $sitemap->analyze (
'<?xml version="1.0" encoding="utf-8"?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
+33 -31
View File
@@ -7,22 +7,24 @@
namespace Domframework\Tests;
/** Test the spfcheck tools
use Domframework\Spfcheck;
/** Test the Spfcheck tools
*/
class spfcheckTest extends \PHPUnit_Framework_TestCase
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 ();
$spfcheck = new Spfcheck ();
$res = $spfcheck->getRecords ("notfound.tester.fournier38.fr");
}
public function test_getRecords_SPFReject ()
{
$spfcheck = new spfcheck ();
$spfcheck = new Spfcheck ();
$res = $spfcheck->getRecords ("reject.spf.tester.fournier38.fr");
$this->assertSame ($res,
array ("reject.spf.tester.fournier38.fr" =>
@@ -33,14 +35,14 @@ class spfcheckTest extends \PHPUnit_Framework_TestCase
{
$this->expectException ("Exception",
"SPFCheck : Too much DNS requests (30 >= 30)", 500);
$spfcheck = new spfcheck ();
$spfcheck = new Spfcheck ();
$res = $spfcheck->getRecords ("loop.spf.tester.fournier38.fr");
$this->assertSame ($res, array ());
}
public function test_getRecords_Include_emptyInclude ()
{
$spfcheck = new spfcheck ();
$spfcheck = new Spfcheck ();
$res = $spfcheck->getRecords ("includeempty.spf.tester.fournier38.fr");
$this->assertSame ($res,
array ("includeempty.spf.tester.fournier38.fr" =>
@@ -49,7 +51,7 @@ class spfcheckTest extends \PHPUnit_Framework_TestCase
public function test_getRecords_Redirect_emptyRedirect ()
{
$spfcheck = new spfcheck ();
$spfcheck = new Spfcheck ();
$res = $spfcheck->getRecords ("redirectempty.spf.tester.fournier38.fr");
$this->assertSame ($res,
array ("redirectempty.spf.tester.fournier38.fr" =>
@@ -58,7 +60,7 @@ class spfcheckTest extends \PHPUnit_Framework_TestCase
public function test_getRecords_MX_emptyMX ()
{
$spfcheck = new spfcheck ();
$spfcheck = new Spfcheck ();
$res = $spfcheck->getRecords ("mx.spf.tester.fournier38.fr");
$this->assertSame ($res,
array ("mx.spf.tester.fournier38.fr" =>
@@ -67,13 +69,13 @@ class spfcheckTest extends \PHPUnit_Framework_TestCase
public function test_getRecords_MX_validMX ()
{
$spfcheck = new spfcheck ();
$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:234:3931::103",
"2a01:e0a:289:3090::206",
"2a01:e0a:163:38f1::103",
"2a01:e0a:2a7:9cd0::206",
"82.64.55.197",
"82.64.75.195"),
"-all" => array ())));
@@ -81,7 +83,7 @@ class spfcheckTest extends \PHPUnit_Framework_TestCase
public function test_getRecords_A_emptyA ()
{
$spfcheck = new spfcheck ();
$spfcheck = new Spfcheck ();
$res = $spfcheck->getRecords ("a.spf.tester.fournier38.fr");
$this->assertSame ($res,
array ("a.spf.tester.fournier38.fr" =>
@@ -90,19 +92,19 @@ class spfcheckTest extends \PHPUnit_Framework_TestCase
public function test_getRecords_A_validA ()
{
$spfcheck = new spfcheck ();
$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:234:3931::100",
"2a01:e0a:163:38f1::100",
"82.64.55.197",),
"-all" => array ())));
}
public function test_getRecords_IP4_emptyIP4 ()
{
$spfcheck = new spfcheck ();
$spfcheck = new Spfcheck ();
$res = $spfcheck->getRecords ("ip4empty.spf.tester.fournier38.fr");
$this->assertSame ($res,
array ("ip4empty.spf.tester.fournier38.fr" => array (
@@ -112,7 +114,7 @@ class spfcheckTest extends \PHPUnit_Framework_TestCase
public function test_getRecords_IP4_invalidIP4 ()
{
$spfcheck = new spfcheck ();
$spfcheck = new Spfcheck ();
$res = $spfcheck->getRecords ("ip4invalid.spf.tester.fournier38.fr");
$this->assertSame ($res,
array ("ip4invalid.spf.tester.fournier38.fr" => array (
@@ -122,7 +124,7 @@ class spfcheckTest extends \PHPUnit_Framework_TestCase
public function test_getRecords_IP4_validIP4 ()
{
$spfcheck = new spfcheck ();
$spfcheck = new Spfcheck ();
$res = $spfcheck->getRecords ("ip4valid.spf.tester.fournier38.fr");
$this->assertSame ($res,
array ("ip4valid.spf.tester.fournier38.fr" => array (
@@ -132,7 +134,7 @@ class spfcheckTest extends \PHPUnit_Framework_TestCase
public function test_getRecords_IP6_emptyIP6 ()
{
$spfcheck = new spfcheck ();
$spfcheck = new Spfcheck ();
$res = $spfcheck->getRecords ("ip6empty.spf.tester.fournier38.fr");
$this->assertSame ($res,
array ("ip6empty.spf.tester.fournier38.fr" => array (
@@ -142,7 +144,7 @@ class spfcheckTest extends \PHPUnit_Framework_TestCase
public function test_getRecords_IP6_invalidIP6 ()
{
$spfcheck = new spfcheck ();
$spfcheck = new Spfcheck ();
$res = $spfcheck->getRecords ("ip6invalid.spf.tester.fournier38.fr");
$this->assertSame ($res,
array ("ip6invalid.spf.tester.fournier38.fr" => array (
@@ -152,7 +154,7 @@ class spfcheckTest extends \PHPUnit_Framework_TestCase
public function test_getRecords_IP6_validIP6 ()
{
$spfcheck = new spfcheck ();
$spfcheck = new Spfcheck ();
$res = $spfcheck->getRecords ("ip6valid.spf.tester.fournier38.fr");
$this->assertSame ($res,
array ("ip6valid.spf.tester.fournier38.fr" => array (
@@ -162,7 +164,7 @@ class spfcheckTest extends \PHPUnit_Framework_TestCase
public function test_getRecords_PTR ()
{
$spfcheck = new spfcheck ();
$spfcheck = new Spfcheck ();
$res = $spfcheck->getRecords ("ptrvalid.spf.tester.fournier38.fr");
$this->assertSame ($res,
array ("ptrvalid.spf.tester.fournier38.fr" => array (
@@ -172,7 +174,7 @@ class spfcheckTest extends \PHPUnit_Framework_TestCase
public function test_getRecords_All_Multiple ()
{
$spfcheck = new spfcheck ();
$spfcheck = new Spfcheck ();
$res = $spfcheck->getRecords ("allmultiple.spf.tester.fournier38.fr");
$this->assertSame ($res,
array ("allmultiple.spf.tester.fournier38.fr" => array (
@@ -182,7 +184,7 @@ class spfcheckTest extends \PHPUnit_Framework_TestCase
public function test_getRecords_All_NotEnd ()
{
$spfcheck = new spfcheck ();
$spfcheck = new Spfcheck ();
$res = $spfcheck->getRecords ("allnotend.spf.tester.fournier38.fr");
$this->assertSame ($res,
array ("allnotend.spf.tester.fournier38.fr" => array (
@@ -192,7 +194,7 @@ class spfcheckTest extends \PHPUnit_Framework_TestCase
public function test_getRecords_All_NotSet ()
{
$spfcheck = new spfcheck ();
$spfcheck = new Spfcheck ();
$res = $spfcheck->getRecords ("allnotset.spf.tester.fournier38.fr");
$this->assertSame ($res,
array ("allnotset.spf.tester.fournier38.fr" => array (
@@ -201,7 +203,7 @@ class spfcheckTest extends \PHPUnit_Framework_TestCase
public function test_wideIPRange ()
{
$spfcheck = new spfcheck ();
$spfcheck = new Spfcheck ();
$spfcheck->getRecords ("wide.spf.tester.fournier38.fr");
$res = $spfcheck->getErrors ();
$this->assertSame ($res,
@@ -213,7 +215,7 @@ class spfcheckTest extends \PHPUnit_Framework_TestCase
public function test_recordsWithPlus ()
{
$spfcheck = new spfcheck ();
$spfcheck = new Spfcheck ();
$res = $spfcheck->getRecords ("plus.spf.tester.fournier38.fr");
$this->assertSame ($res,
array ("plus.spf.tester.fournier38.fr" => array (
@@ -228,7 +230,7 @@ class spfcheckTest extends \PHPUnit_Framework_TestCase
public function test_getRecords_Unknown ()
{
$spfcheck = new spfcheck ();
$spfcheck = new Spfcheck ();
$res = $spfcheck->getRecords ("unknown.spf.tester.fournier38.fr");
$this->assertSame ($res,
array ("unknown.spf.tester.fournier38.fr" => array (
@@ -238,28 +240,28 @@ class spfcheckTest extends \PHPUnit_Framework_TestCase
public function test_ipCheckToSPF_OK_inA ()
{
$spfcheck = new spfcheck ();
$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 ();
$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 ();
$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 ();
$spfcheck = new Spfcheck ();
$res = $spfcheck->ipCheckToSPF ("plus.spf.tester.fournier38.fr", "137.74.69.64");
$this->assertSame ($res, "FAIL");
}
+34 -21
View File
@@ -7,21 +7,24 @@
namespace Domframework\Tests;
use Domframework\Sse;
/** Test the domframework Server-Sent Events part */
class sseTest extends \PHPUnit_Framework_TestCase
class SseTest extends \PHPUnit_Framework_TestCase
{
public function test_loop_NOTDEFINED ()
{
$this->expectException ("Exception");
$sse = new sse ();
$sse = new Sse ();
$res = $sse->loop ();
}
public function test_loop_JUSTPING ()
{
$this->expectOutputString(str_repeat (": ping\n\n", 5));
$sse = new sse ();
@unlink ("/tmp/dfwTestSSE1");
$sse = new Sse ();
if (file_exists ("/tmp/dfwTestSSE1"))
unlink ("/tmp/dfwTestSSE1");
$sse->setBackendFiles ("/tmp/dfwTestSSE1")
->setPingTime(1);
$sse->loop ();
@@ -30,8 +33,9 @@ class sseTest extends \PHPUnit_Framework_TestCase
public function test_loop_SKIP_START ()
{
$this->expectOutputString(str_repeat (": ping\n\n", 5));
$sse = new sse ();
@unlink ("/tmp/dfwTestSSE1");
$sse = new Sse ();
if (file_exists ("/tmp/dfwTestSSE1"))
unlink ("/tmp/dfwTestSSE1");
file_put_contents ("/tmp/dfwTestSSE1", "NOT SEEN");
$sse->setBackendFiles ("/tmp/dfwTestSSE1")
->setPingTime(1);
@@ -42,8 +46,9 @@ class sseTest extends \PHPUnit_Framework_TestCase
{
$this->expectOutputString(str_repeat (": ping\n\n", 4).
"data: WILL BE SEEN\n\n: ping\n\n");
@unlink ("/tmp/dfwTestSSE1");
$sse = new sse ();
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);
@@ -59,9 +64,11 @@ class sseTest extends \PHPUnit_Framework_TestCase
"event: event1\ndata: WILL BE SEEN 1\n\n".
"event: event2\ndata: WILL BE SEEN 2\n\n".
": ping\n\n");
@unlink ("/tmp/dfwTestSSE1");
@unlink ("/tmp/dfwTestSSE2");
$sse = new sse ();
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");
@@ -79,9 +86,11 @@ class sseTest extends \PHPUnit_Framework_TestCase
"event: event1\ndata: will be seen 1\n\n".
"event: event2\ndata: WILL BE SEEN 2\n\n".
": ping\n\n");
@unlink ("/tmp/dfwTestSSE1");
@unlink ("/tmp/dfwTestSSE2");
$sse = new sse ();
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");
@@ -92,7 +101,8 @@ class sseTest extends \PHPUnit_Framework_TestCase
}
$sse->setBackendFiles (["event1" => "/tmp/dfwTestSSE1",
"event2" => "/tmp/dfwTestSSE2"])
->setHandlersEvent (["event1" => "lowerHandlersEvent"])
->setHandlersEvent ([
"event1" => __NAMESPACE__."\\lowerHandlersEvent"])
->setPingTime(1);
$sse->loop ();
}
@@ -102,8 +112,9 @@ class sseTest extends \PHPUnit_Framework_TestCase
$this->expectOutputString(str_repeat (": ping\n\n", 4).
"data: will be seen 1\n\n".
": ping\n\n");
@unlink ("/tmp/dfwTestSSE1");
$sse = new sse ();
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);
@@ -112,7 +123,7 @@ class sseTest extends \PHPUnit_Framework_TestCase
return strtolower ($val);
}
$sse->setBackendFiles ("/tmp/dfwTestSSE1")
->setHandlerDataonly ("lowerHandlerDataonly")
->setHandlerDataonly (__NAMESPACE__."\\lowerHandlerDataonly")
->setPingTime(1);
$sse->loop ();
}
@@ -122,8 +133,9 @@ class sseTest extends \PHPUnit_Framework_TestCase
$this->expectOutputString(str_repeat (": ping\n\n", 4).
"data: PREwill be seen 1POST\n\n".
": ping\n\n");
@unlink ("/tmp/dfwTestSSE1");
$sse = new sse ();
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);
@@ -132,7 +144,8 @@ class sseTest extends \PHPUnit_Framework_TestCase
return $param1.strtolower ($val).$param2;
}
$sse->setBackendFiles ("/tmp/dfwTestSSE1")
->setHandlerDataonly ("lowerHandlerDataonlyWithParams", "PRE", "POST")
->setHandlerDataonly (
__NAMESPACE__."\\lowerHandlerDataonlyWithParams", "PRE", "POST")
->setPingTime(1);
$sse->loop ();
}
+7 -5
View File
@@ -7,12 +7,14 @@
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 = new Tcpclient ("www.google.fr", 80);
$tcpclient->preferIPv4 (true);
$tcpclient->connect ();
$tcpclient->send ("GET / HTTP/1.1\r\n".
@@ -29,7 +31,7 @@ class tcpclientTest extends \PHPUnit_Framework_TestCase
public function test_GoogleIPv4orIpv6 ()
{
$tcpclient = new \tcpclient ("www.google.fr", 80);
$tcpclient = new Tcpclient ("www.google.fr", 80);
$tcpclient->connect ();
$tcpclient->send ("GET / HTTP/1.1\r\n".
"Host: www.google.fr\r\n".
@@ -45,7 +47,7 @@ class tcpclientTest extends \PHPUnit_Framework_TestCase
public function test_GoogleSSL ()
{
$tcpclient = new \tcpclient ("www.google.fr", 443);
$tcpclient = new Tcpclient ("www.google.fr", 443);
$tcpclient->connect ();
$tcpclient->cryptoEnable (true);
$tcpclient->send ("GET / HTTP/1.1\r\n".
@@ -62,7 +64,7 @@ class tcpclientTest extends \PHPUnit_Framework_TestCase
public function test_GoogleSSLIPv6 ()
{
$tcpclient = new \tcpclient ("ipv6.google.com", 443);
$tcpclient = new Tcpclient ("ipv6.google.com", 443);
$tcpclient->connect ();
$tcpclient->cryptoEnable (true);
$tcpclient->send ("GET / HTTP/1.1\r\n".
+19 -17
View File
@@ -7,8 +7,10 @@
namespace Domframework\Tests;
/** Test the userssql.php file */
class userssqlTest extends \PHPUnit_Framework_TestCase
use Domframework\Userssql;
/** Test the Userssql.php file */
class UserssqlTest extends \PHPUnit_Framework_TestCase
{
public function test_clean ()
{
@@ -17,28 +19,28 @@ class userssqlTest extends \PHPUnit_Framework_TestCase
public function test_initStorage ()
{
$userssql = new userssql ("sqlite:///tmp/database.db");
$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");
$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");
$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");
$userssql = new Userssql ("sqlite:///tmp/database.db");
$res = $userssql->listusers ();
$this->assertSame ($res, array (array ("email"=>"toto@toto.com",
"firstname"=>"Toto",
@@ -47,49 +49,49 @@ class userssqlTest extends \PHPUnit_Framework_TestCase
public function test_overwritepassword1 ()
{
$userssql = new userssql ("sqlite:///tmp/database.db");
$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");
$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");
$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");
$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");
$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");
$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");
$userssql = new Userssql ("sqlite:///tmp/database.db");
$res = $userssql->updateuser ("toto@toto.com", "titi@titi.com", "titi",
"titi2");
$this->assertSame ($res, 1);
@@ -97,7 +99,7 @@ class userssqlTest extends \PHPUnit_Framework_TestCase
public function test_listusers3 ()
{
$userssql = new userssql ("sqlite:///tmp/database.db");
$userssql = new Userssql ("sqlite:///tmp/database.db");
$res = $userssql->listusers ();
$this->assertSame ($res, array (array ("email"=>"titi@titi.com",
"firstname"=>"titi",
@@ -106,21 +108,21 @@ class userssqlTest extends \PHPUnit_Framework_TestCase
public function test_checkValidPassword5 ()
{
$userssql = new userssql ("sqlite:///tmp/database.db");
$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");
$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");
$userssql = new Userssql ("sqlite:///tmp/database.db");
$res = $userssql->listusers ();
$this->assertSame ($res, array ());
}
+6 -4
View File
@@ -7,18 +7,20 @@
namespace Domframework\Tests;
/** Test the uuid.php file */
class uuidTest extends \PHPUnit_Framework_TestCase
use Domframework\Uuid;
/** Test the Uuid.php file */
class UuidTest extends \PHPUnit_Framework_TestCase
{
public function test_uuid1 ()
{
$res = uuid::uuid4 ();
$res = Uuid::uuid4 ();
$this->assertRegExp (36, strlen ($res));
}
public function test_uuid2 ()
{
$res = uuid::uuid4 ();
$res = Uuid::uuid4 ();
$this->assertRegExp (true, strspn ("0123456789abcdef-", $res) ==
strlen ($res));
}
+27 -25
View File
@@ -7,60 +7,62 @@
namespace Domframework\Tests;
use Domframework\Verify;
/** Test the Verify */
class verifyTest extends \PHPUnit_Framework_TestCase
class VerifyTest extends \PHPUnit_Framework_TestCase
{
///////////////
// DATES //
///////////////
public function test_is_datetimeSQL1 ()
{
$verify = new \verify ();
$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 ();
$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");
$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");
$res = Verify::staticIs_datetimeSQL ("2017-13-55 22:55:17");
$this->assertSame ($res, false);
}
public function test_is_dateSQL1 ()
{
$verify = new \verify ();
$verify = new Verify ();
$res = $verify->is_dateSQL ("2017-04-13");
$this->assertSame ($res, true);
}
public function test_is_dateSQL2 ()
{
$verify = new \verify ();
$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");
$res = Verify::staticIs_dateSQL ("2017-04-13");
$this->assertSame ($res, true);
}
public function test_staticIs_dateSQL2 ()
{
$res = \verify::staticIs_dateSQL ("2017-13-55");
$res = Verify::staticIs_dateSQL ("2017-13-55");
$this->assertSame ($res, false);
}
@@ -70,13 +72,13 @@ class verifyTest extends \PHPUnit_Framework_TestCase
/////////////////
public function test_staticIsAllowedChars_1 ()
{
$res = \verify::staticIsAllowedChars ("éléphant", "abcd");
$res = Verify::staticIsAllowedChars ("éléphant", "abcd");
$this->assertSame ($res, false);
}
public function test_staticIsAllowedChars_2 ()
{
$res = \verify::staticIsAllowedChars ("éléphant", "anhplté");
$res = Verify::staticIsAllowedChars ("éléphant", "anhplté");
$this->assertSame ($res, true);
}
@@ -85,25 +87,25 @@ class verifyTest extends \PHPUnit_Framework_TestCase
/////////////////
public function test_staticIs_integer1 ()
{
$res = \verify::staticIs_integer ("2017-04-13 22:55:17");
$res = Verify::staticIs_integer ("2017-04-13 22:55:17");
$this->assertSame ($res, false);
}
public function test_staticIs_integer2 ()
{
$res = \verify::staticIs_integer ("01234");
$res = Verify::staticIs_integer ("01234");
$this->assertSame ($res, true);
}
public function test_staticIs_integer3 ()
{
$res = \verify::staticIs_integer ("0x1234");
$res = Verify::staticIs_integer ("0x1234");
$this->assertSame ($res, false);
}
public function test_staticIs_integer4 ()
{
$res = \verify::staticIs_integer ("");
$res = Verify::staticIs_integer ("");
$this->assertSame ($res, false);
}
@@ -116,27 +118,27 @@ class verifyTest extends \PHPUnit_Framework_TestCase
/////////////
public function test_is_url1 ()
{
$verify = new \verify ();
$verify = new Verify ();
$res = $verify->is_url ("invalid");
$this->assertsame ($res, false);
}
public function test_is_url2 ()
{
$verify = new \verify ();
$verify = new Verify ();
$res = $verify->is_url ("http://valid");
$this->assertsame ($res, true);
}
public function test_staticIs_url1 ()
{
$res = \verify::staticIs_url ("invalid");
$res = Verify::staticIs_url ("invalid");
$this->assertsame ($res, false);
}
public function test_staticIs_url2 ()
{
$res = \verify::staticIs_url ("http://valid");
$res = Verify::staticIs_url ("http://valid");
$this->assertsame ($res, true);
}
@@ -145,40 +147,40 @@ class verifyTest extends \PHPUnit_Framework_TestCase
////////////////
public function test_is_UUID1 ()
{
$verify = new \verify ();
$verify = new Verify ();
$res = $verify->is_UUID ("ca39275f-9224-425f-ba94-efce2aa5b52c");
$this->assertsame ($res, true);
}
public function test_is_UUID2 ()
{
$verify = new \verify ();
$verify = new Verify ();
$res = $verify->is_UUID ("zz39275f-9224-425f-ba94-efce2aa5b52c");
$this->assertsame ($res, false);
}
public function test_is_UUID3 ()
{
$verify = new \verify ();
$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");
$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");
$res = Verify::staticis_UUID ("zz39275f-9224-425f-ba94-efce2aa5b52c");
$this->assertsame ($res, false);
}
public function test_staticis_UUID3 ()
{
$res = \verify::staticis_UUID ("2c");
$res = Verify::staticis_UUID ("2c");
$this->assertsame ($res, false);
}
}
+20 -18
View File
@@ -7,6 +7,8 @@
namespace Domframework\Tests;
use Domframework\Xdiff;
/** Test the domframework xdiff part */
class xdiffTest extends \PHPUnit_Framework_TestCase
{
@@ -72,7 +74,7 @@ to this document.
public function test_diff_normal_1 ()
{
// Mode normal
$xdiff = new xdiff ();
$xdiff = new Xdiff ();
$res = $xdiff->diff ($this->string1, $this->string2);
$this->assertSame ($res, "0a1,6
> This is an important
@@ -102,7 +104,7 @@ to this document.
public function test_diff_normal_2 ()
{
// Mode normal
$xdiff = new xdiff ();
$xdiff = new Xdiff ();
$res = $xdiff->diff ("NEWLINE\n".$this->string1, $this->string2);
$this->assertSame ($res, "1c1,6
< NEWLINE
@@ -134,7 +136,7 @@ to this document.
public function test_diff_normal_3 ()
{
// Mode normal
$xdiff = new xdiff ();
$xdiff = new Xdiff ();
$res = $xdiff->diff ("NEWLINE\n", "\n");
$this->assertSame ($res, "1c1
< NEWLINE
@@ -146,7 +148,7 @@ to this document.
public function test_diff_normal_4 ()
{
// Mode normal
$xdiff = new xdiff ();
$xdiff = new Xdiff ();
$res = $xdiff->diff ("\n", "NEWLINE\n");
$this->assertSame ($res, "1c1
<
@@ -157,14 +159,14 @@ to this document.
public function test_diff_normal_5 ()
{
$xdiff = new xdiff ();
$xdiff = new Xdiff ();
$res = $xdiff->diff ("\n", "\n");
$this->assertSame ($res, "");
}
public function test_diff_normal_6 ()
{
$xdiff = new xdiff ();
$xdiff = new Xdiff ();
$res = $xdiff->diff ("\n", "");
$this->assertSame ($res, "1d0
< \n");
@@ -172,7 +174,7 @@ to this document.
public function test_diff_normal_7 ()
{
$xdiff = new xdiff ();
$xdiff = new Xdiff ();
$res = $xdiff->diff ("", "\n");
$this->assertSame ($res, "0a1
> \n");
@@ -181,7 +183,7 @@ to this document.
public function test_diff_unified_1 ()
{
// Mode unified
$xdiff = new xdiff ("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
@@ -215,7 +217,7 @@ to this document.
public function test_diff_unified_2 ()
{
// Mode unified
$xdiff = new xdiff ("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")."
@@ -246,7 +248,7 @@ to this document.
public function test_diff_unified_3 ()
{
$xdiff = new xdiff ("unified");
$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")."
@@ -258,7 +260,7 @@ to this document.
public function test_diff_unified_4 ()
{
$xdiff = new xdiff ("unified");
$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")."
@@ -270,14 +272,14 @@ to this document.
public function test_diff_unified_5 ()
{
$xdiff = new xdiff ("unified");
$xdiff = new Xdiff ("unified");
$res = $xdiff->diff ("\n", "\n");
$this->assertSame ($res, "");
}
public function test_diff_unified_6 ()
{
$xdiff = new xdiff ("unified");
$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")."
@@ -287,7 +289,7 @@ to this document.
public function test_diff_unified_7 ()
{
$xdiff = new xdiff ("unified");
$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")."
@@ -299,7 +301,7 @@ to this document.
{
file_put_contents ("/tmp/test_xdiff1", $this->string1);
file_put_contents ("/tmp/test_xdiff2", $this->string2);
$xdiff = new xdiff ("unified");
$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")."
@@ -330,14 +332,14 @@ to this document.
public function test_diffFile_unified_2 ()
{
$xdiff = new xdiff ("unified");
$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");
$xdiff = new Xdiff ("unified");
$this->setExpectedException ();
$res = $xdiff->diffFile ("/tmp/test_xdiff1", "/tmp/test_xdiffNOTEXISTS");
}
@@ -346,7 +348,7 @@ to this document.
{
file_put_contents ("/tmp/test_xdiff1", $this->string1);
file_put_contents ("/tmp/test_xdiff2", $this->string2);
$xdiff = new xdiff ("sideBySide");
$xdiff = new Xdiff ("sideBySide");
$res = $xdiff->diffFile ("/tmp/test_xdiff1", "/tmp/test_xdiff2");
$this->assertSame ($res,
" > This is an important
+7 -5
View File
@@ -7,19 +7,21 @@
namespace Domframework\Tests;
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 ();
$xmppclient = new Xmppclient ();
$res = $xmppclient->connect ("NOTFOUND.fournier38.fr", 5222, "", "");
}
public function test_connection_authenticate_1 ()
{
$xmppclient = new xmppclient ();
$xmppclient = new Xmppclient ();
$res = $xmppclient->connect ("xmpp.fournier38.fr", 5222,
"testxmpp@xmpp.fournier38.fr", "LSqmBXDUZWxk");
$this->assertSame (is_object ($res), true);
@@ -27,7 +29,7 @@ class xmppclientTest extends \PHPUnit_Framework_TestCase
public function test_connection_disco_1 ()
{
$xmppclient = new xmppclient ();
$xmppclient = new Xmppclient ();
$xmppclient->connect ("xmpp.fournier38.fr", 5222,
"testxmpp@xmpp.fournier38.fr", "LSqmBXDUZWxk");
$res = $xmppclient->discoveryService ();
@@ -36,7 +38,7 @@ class xmppclientTest extends \PHPUnit_Framework_TestCase
public function test_connection_sendMessage_1 ()
{
$xmppclient = new xmppclient ();
$xmppclient = new Xmppclient ();
$xmppclient->connect ("xmpp.fournier38.fr", 5222,
"testxmpp@xmpp.fournier38.fr", "LSqmBXDUZWxk");
$res = $xmppclient->sendMessagePrivate ("dominique@fournier38.fr",
@@ -46,7 +48,7 @@ class xmppclientTest extends \PHPUnit_Framework_TestCase
public function test_connection_sendMessage_2 ()
{
$xmppclient = new xmppclient ();
$xmppclient = new Xmppclient ();
$xmppclient->connect ("xmpp.fournier38.fr", 5222,
"testxmpp@xmpp.fournier38.fr", "LSqmBXDUZWxk");
$res = $xmppclient->sendMessagePrivate ("dominique@fournier38.fr",
+1 -1
View File
@@ -119,7 +119,7 @@ class Authjwt extends Auth
if ($auth["email"] === "anonymous")
throw new \Exception (dgettext ("domframework",
"AuthJWT : can not create token for anonymous"), 403);
$uuid = uuid::uuid4 ();
$uuid = Uuid::uuid4 ();
$cachefile = new Cachefile ();
$cachefile->directory = $this->cacheDir;
$cachefile->write ($uuid, $auth);
+11 -11
View File
@@ -78,7 +78,7 @@ class Authorizationdb extends Authorization
{
$this->treecheckExecute ($object);
}
catch (Exception $e)
catch (\Exception $e)
{
throw new \Exception ($e->getMessage(), 405);
}
@@ -163,7 +163,7 @@ class Authorizationdb extends Authorization
{
$this->treecheckExecute ($object);
}
catch (Exception $e)
catch (\Exception $e)
{
throw new \Exception ($e->getMessage(), 405);
}
@@ -191,7 +191,7 @@ class Authorizationdb extends Authorization
{
$this->treecheckWrite ($object);
}
catch (Exception $e)
catch (\Exception $e)
{
throw new \Exception ($e->getMessage(), 405);
}
@@ -227,7 +227,7 @@ class Authorizationdb extends Authorization
{
$this->treecheckExecute ($object);
}
catch (Exception $e)
catch (\Exception $e)
{
throw new \Exception ($e->getMessage(), 405);
}
@@ -259,7 +259,7 @@ class Authorizationdb extends Authorization
{
$this->treecheckWrite ($object);
}
catch (Exception $e)
catch (\Exception $e)
{
throw new \Exception ($e->getMessage(), 405);
}
@@ -301,7 +301,7 @@ class Authorizationdb extends Authorization
{
$this->treecheckExecute ($object);
}
catch (Exception $e)
catch (\Exception $e)
{
throw new \Exception ($e->getMessage(), 405);
}
@@ -347,7 +347,7 @@ class Authorizationdb extends Authorization
{
$this->treecheckExecute ($object);
}
catch (Exception $e)
catch (\Exception $e)
{
throw new \Exception ($e->getMessage(), 405);
}
@@ -390,7 +390,7 @@ class Authorizationdb extends Authorization
{
$this->treecheckExecute ($object);
}
catch (Exception $e)
catch (\Exception $e)
{
throw new \Exception ($e->getMessage(), 405);
}
@@ -430,7 +430,7 @@ class Authorizationdb extends Authorization
{
$this->treecheckExecute ($object);
}
catch (Exception $e)
catch (\Exception $e)
{
throw new \Exception ($e->getMessage(), 405);
}
@@ -468,7 +468,7 @@ class Authorizationdb extends Authorization
{
$this->treecheckExecute ($object);
}
catch (Exception $e)
catch (\Exception $e)
{
throw new \Exception ($e->getMessage(), 405);
}
@@ -506,7 +506,7 @@ class Authorizationdb extends Authorization
{
$this->treecheckExecute ($object);
}
catch (Exception $e)
catch (\Exception $e)
{
throw new \Exception ($e->getMessage(), 405);
}
+4 -4
View File
@@ -70,7 +70,7 @@ class Authzgroups
{
$st = $this->dbObject->prepare ($req);
}
catch (Exception $e)
catch (\Exception $e)
{
if ($this->dbObject->debug) echo "DEBUG : PREPARE ERROR ! Return FALSE".
$e->getMessage()."\n";
@@ -86,14 +86,14 @@ class Authzgroups
if ($rc === false)
throw new \Exception ("Can't execute SQL request", 500);
}
catch (Exception $e)
catch (\Exception $e)
{
if ($this->dbObject->debug) echo "DEBUG : EXECUTE ERROR ! Return FALSE".
$e->getMessage()."\n";
throw new \Exception ($e->getMessage(), 500);
}
$res = array ();
while ($d = $st->fetch (PDO::FETCH_ASSOC))
while ($d = $st->fetch (\PDO::FETCH_ASSOC))
$res[$d["object"]] = $d["right"];
// Transform the numerical rights to RO/RW
foreach ($res as $k=>$r)
@@ -382,7 +382,7 @@ class Authzgroups
$class= "db$table";
$this->$class->createTable ();
}
catch (Exception $e)
catch (\Exception $e)
{
echo $e->getMessage()."\n";
}
+3 -3
View File
@@ -253,7 +253,7 @@ class Cli
$constParams .= ">";
}
}
catch (Exception $e)
catch (\Exception $e)
{
// No constructor
}
@@ -346,7 +346,7 @@ class Cli
$paramsConst = $r1->getParameters();
$min = $max = count ($paramsConst);
}
catch (Exception $e)
catch (\Exception $e)
{
// No constructor available in class
}
@@ -437,7 +437,7 @@ class Cli
var_dump ($s);
}
}
catch (Exception $e)
catch (\Exception $e)
{
file_put_contents("php://stderr", $e->getMessage()."\n");
if ($this->EXPERT)
+1 -1
View File
@@ -97,7 +97,7 @@ class Convert
foreach (preg_split ("#([".preg_quote ($delimiters)."]+)#", $str, -1,
PREG_SPLIT_DELIM_CAPTURE) as $tok)
{
$res .= \convert::ucfirst ($tok);
$res .= Convert::ucfirst ($tok);
}
return $res;
}
+2 -2
View File
@@ -389,7 +389,7 @@ class Dblayer
elseif ($data[$key] !== "" && $params[0] === "datetime")
{
// The date format must be in ANSI SQL : YYYY-MM-DD HH:MM:SS
$d = DateTime::createFromFormat("Y-m-d H:i:s", $data[$key]);
$d = \DateTime::createFromFormat("Y-m-d H:i:s", $data[$key]);
if (!$d || $d->format("Y-m-d H:i:s") !== $data[$key])
{
$errors[$key] = array ("error", sprintf (
@@ -402,7 +402,7 @@ class Dblayer
elseif ($data[$key] !== "" && $params[0] === "date")
{
// The date format must be in ANSI SQL : YYYY-MM-DD
$d = DateTime::createFromFormat("Y-m-d", $data[$key]);
$d = \DateTime::createFromFormat("Y-m-d", $data[$key]);
if (!$d || $d->format("Y-m-d") !== $data[$key])
{
$errors[$key] = array ("error", sprintf (
+1 -1
View File
@@ -97,7 +97,7 @@ class Dblayerauthzgroups extends Dblayer
$this->authzgroups->accessRight ($this->module, $this->user,
$this->path."/".$line[$this->primary]);
}
catch (Exception $e)
catch (\Exception $e)
{
unset ($data[$key]);
}
+6 -6
View File
@@ -1647,10 +1647,10 @@ class Dblayeroo
if (! is_object ($object))
$this->DBException ("Invalid setForeignObj parameter: not an object");
if (! is_subclass_of ($object, __CLASS__) &&
get_class ($object) !== "dblayeroo" &&
get_class ($object) !== __NAMESPACE__."\dblayeroo")
get_class ($object) !== "Dblayeroo" &&
get_class ($object) !== __NAMESPACE__."\Dblayeroo")
$this->DBException (
"Invalid object provided to setForeignObj (not dblayeroo object)");
"Invalid object provided to setForeignObj (not Dblayeroo object)");
if (! isset ($object->table))
$this->DBException (
"Invalid object provided to setForeignObj (no table defined)");
@@ -2098,10 +2098,10 @@ class Dblayeroo
if (! is_object ($object))
$this->DBException ("Invalid object provided to join (not object)");
if (! is_subclass_of ($object, __CLASS__) &&
get_class ($object) !== "dblayeroo" &&
get_class ($object) !== __NAMESPACE__."\dblayeroo")
get_class ($object) !== "Dblayeroo" &&
get_class ($object) !== __NAMESPACE__."\Dblayeroo")
$this->DBException (
"Invalid object provided to join (not dblayeroo object)");
"Invalid object provided to join (not Dblayeroo object)");
if ($this->dsn !== $object->dsn)
$this->DBException (
"DSN different : don't support JOIN between databases");
+1 -1
View File
@@ -771,7 +771,7 @@ class Mail
// time. An exception is raised, but it is not important
$this->delHeader ($head, $sectionID);
}
catch (Exception $e)
catch (\Exception $e)
{
}
}
+8 -8
View File
@@ -60,7 +60,7 @@ class Rss
return $this->link;
if (! is_string ($link))
throw new \Exception ("Link provided to RSS is not a string", 500);
$verify = new verify ();
$verify = new Verify ();
if (! $verify->is_URL ($link))
throw new \Exception ("Link provided to RSS is not an URL", 500);
if ($link === "")
@@ -124,14 +124,14 @@ class Rss
if (! is_string ($lastBuildDate))
throw new \Exception ("lastBuildDate provided to RSS is not a string",
500);
$verify = new verify ();
$verify = new Verify ();
if (! $verify->is_datetimeSQL ($lastBuildDate))
throw new \Exception ("lastBuildDate provided to RSS is not a valid date",
500);
if ($lastBuildDate === "")
$lastBuildDate = null;
else
$lastBuildDate = \convert::convertDate ($lastBuildDate, "Y-m-d H:i:s",
$lastBuildDate = Convert::convertDate ($lastBuildDate, "Y-m-d H:i:s",
\DateTime::RFC2822);
$this->lastBuildDate = $lastBuildDate;
return $this;
@@ -194,7 +194,7 @@ class Rss
$tmpItem->pubDate = $item->pubDate ();
}
// Ident correctely the xml created in SimpleXML
$dom = new DOMDocument('1.0');
$dom = new \DOMDocument('1.0');
$dom->preserveWhiteSpace = false;
$dom->formatOutput = true;
$dom->loadXML($xml->asXML());
@@ -258,7 +258,7 @@ class Rssitem
return $this->link;
if (! is_string ($link))
throw new \Exception ("Link provided to RSS Item is not a string", 500);
$verify = new verify ();
$verify = new Verify ();
if (! $verify->is_URL ($link))
throw new \Exception ("Link provided to RSS Item is not an URL", 500);
if ($link === "")
@@ -339,14 +339,14 @@ class Rssitem
if (! is_string ($pubDate))
throw new \Exception ("pubDate provided to RSS Item is not a string",
500);
if (! \verify::staticIs_datetimeSQL ($pubDate))
if (! Verify::staticIs_datetimeSQL ($pubDate))
throw new \Exception ("pubDate provided to RSS Item is not a valid date",
500);
if ($pubDate === "")
$pubDate = null;
else
$pubDate = \convert::convertDate ($pubDate, "Y-m-d H:i:s",
DateTime::RFC2822);
$pubDate = Convert::convertDate ($pubDate, "Y-m-d H:i:s",
\DateTime::RFC2822);
$this->pubDate = $pubDate;
return $this;
}