Passage en Namespace et tous les tests fonctionnels OK
This commit is contained in:
@@ -7,12 +7,15 @@
|
|||||||
|
|
||||||
namespace Domframework\Tests;
|
namespace Domframework\Tests;
|
||||||
|
|
||||||
/** Test the authhtpasswd.php file */
|
use Domframework\Authhtpasswd;
|
||||||
class authhtpasswdTest extends \PHPUnit_Framework_TestCase
|
|
||||||
|
/** Test the Authhtpasswd.php file */
|
||||||
|
class AuthhtpasswdTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
public function test_clean ()
|
public function test_clean ()
|
||||||
{
|
{
|
||||||
@unlink ("/tmp/htpasswd.file");
|
if (file_exists ("/tmp/htpasswd.file"))
|
||||||
|
unlink ("/tmp/htpasswd.file");
|
||||||
file_put_contents ("/tmp/htpasswd.file",
|
file_put_contents ("/tmp/htpasswd.file",
|
||||||
'toto@toto.com:$2y$05$dO7qyX4simzg3pMgWyqHgeAjFauXEyUdPdyrwDMVNj4fTuE24TGuq'
|
'toto@toto.com:$2y$05$dO7qyX4simzg3pMgWyqHgeAjFauXEyUdPdyrwDMVNj4fTuE24TGuq'
|
||||||
."\n".
|
."\n".
|
||||||
@@ -23,7 +26,7 @@ class authhtpasswdTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_connect ()
|
public function test_connect ()
|
||||||
{
|
{
|
||||||
$authhtpasswd = new authhtpasswd ();
|
$authhtpasswd = new Authhtpasswd ();
|
||||||
$authhtpasswd->htpasswdFile = "/tmp/htpasswd.file";
|
$authhtpasswd->htpasswdFile = "/tmp/htpasswd.file";
|
||||||
$res = $authhtpasswd->connect ();
|
$res = $authhtpasswd->connect ();
|
||||||
$this->assertSame ($res, null);
|
$this->assertSame ($res, null);
|
||||||
@@ -31,7 +34,7 @@ class authhtpasswdTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_authentication1 ()
|
public function test_authentication1 ()
|
||||||
{
|
{
|
||||||
$authhtpasswd = new authhtpasswd ();
|
$authhtpasswd = new Authhtpasswd ();
|
||||||
$authhtpasswd->htpasswdFile = "/tmp/htpasswd.file";
|
$authhtpasswd->htpasswdFile = "/tmp/htpasswd.file";
|
||||||
$res = $authhtpasswd->authentication ("toto@toto.com", "toto123");
|
$res = $authhtpasswd->authentication ("toto@toto.com", "toto123");
|
||||||
$this->assertSame ($res, true);
|
$this->assertSame ($res, true);
|
||||||
@@ -39,7 +42,7 @@ class authhtpasswdTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_authentication2 ()
|
public function test_authentication2 ()
|
||||||
{
|
{
|
||||||
$authhtpasswd = new authhtpasswd ();
|
$authhtpasswd = new Authhtpasswd ();
|
||||||
$authhtpasswd->htpasswdFile = "/tmp/htpasswd.file";
|
$authhtpasswd->htpasswdFile = "/tmp/htpasswd.file";
|
||||||
$this->setExpectedException ("Exception");
|
$this->setExpectedException ("Exception");
|
||||||
$res = $authhtpasswd->authentication ("UNKNOWN@toto.com", "toto123");
|
$res = $authhtpasswd->authentication ("UNKNOWN@toto.com", "toto123");
|
||||||
@@ -47,7 +50,7 @@ class authhtpasswdTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_authentication3 ()
|
public function test_authentication3 ()
|
||||||
{
|
{
|
||||||
$authhtpasswd = new authhtpasswd ();
|
$authhtpasswd = new Authhtpasswd ();
|
||||||
$authhtpasswd->htpasswdFile = "/tmp/htpasswd.file";
|
$authhtpasswd->htpasswdFile = "/tmp/htpasswd.file";
|
||||||
$this->setExpectedException ("Exception");
|
$this->setExpectedException ("Exception");
|
||||||
$res = $authhtpasswd->authentication ("toto@toto.com", "BAD PASSWD");
|
$res = $authhtpasswd->authentication ("toto@toto.com", "BAD PASSWD");
|
||||||
@@ -55,7 +58,7 @@ class authhtpasswdTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_authentication4 ()
|
public function test_authentication4 ()
|
||||||
{
|
{
|
||||||
$authhtpasswd = new authhtpasswd ();
|
$authhtpasswd = new Authhtpasswd ();
|
||||||
$authhtpasswd->htpasswdFile = "/tmp/htpasswd.file";
|
$authhtpasswd->htpasswdFile = "/tmp/htpasswd.file";
|
||||||
$res = $authhtpasswd->authentication ("titi@titi.com", "toto123");
|
$res = $authhtpasswd->authentication ("titi@titi.com", "toto123");
|
||||||
$this->assertSame ($res, true);
|
$this->assertSame ($res, true);
|
||||||
|
|||||||
@@ -7,8 +7,10 @@
|
|||||||
|
|
||||||
namespace Domframework\Tests;
|
namespace Domframework\Tests;
|
||||||
|
|
||||||
/** Test the authjwt.php file */
|
use Domframework\Authjwt;
|
||||||
class authjwtTest extends \PHPUnit_Framework_TestCase
|
|
||||||
|
/** Test the Authjwt.php file */
|
||||||
|
class AuthjwtTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
public function __construct ()
|
public function __construct ()
|
||||||
{
|
{
|
||||||
@@ -29,7 +31,7 @@ class authjwtTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function testJWT1 ()
|
public function testJWT1 ()
|
||||||
// {{{
|
// {{{
|
||||||
{
|
{
|
||||||
$authjwt = new authjwt ();
|
$authjwt = new Authjwt ();
|
||||||
$authjwt->cacheDir = $this->cacheDir;
|
$authjwt->cacheDir = $this->cacheDir;
|
||||||
$authjwt->serverKey = $this->serverKey;
|
$authjwt->serverKey = $this->serverKey;
|
||||||
$authjwt->cipherKey = $this->cipherKey;
|
$authjwt->cipherKey = $this->cipherKey;
|
||||||
@@ -44,7 +46,7 @@ class authjwtTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function testAuthValid1 ()
|
public function testAuthValid1 ()
|
||||||
// {{{
|
// {{{
|
||||||
{
|
{
|
||||||
$authjwt = new authjwt ();
|
$authjwt = new Authjwt ();
|
||||||
$_SERVER["HTTP_AUTHENTICATION"] = "Bearer ".$this->token;
|
$_SERVER["HTTP_AUTHENTICATION"] = "Bearer ".$this->token;
|
||||||
$authjwt->cacheDir = $this->cacheDir;
|
$authjwt->cacheDir = $this->cacheDir;
|
||||||
$authjwt->serverKey = $this->serverKey;
|
$authjwt->serverKey = $this->serverKey;
|
||||||
@@ -62,7 +64,7 @@ class authjwtTest extends \PHPUnit_Framework_TestCase
|
|||||||
// {{{
|
// {{{
|
||||||
{
|
{
|
||||||
$this->expectException ("Exception", "JWT Signature not readable", 403);
|
$this->expectException ("Exception", "JWT Signature not readable", 403);
|
||||||
$authjwt = new authjwt ();
|
$authjwt = new Authjwt ();
|
||||||
$_SERVER["HTTP_AUTHENTICATION"] = "Bearer ".$this->token."NO";
|
$_SERVER["HTTP_AUTHENTICATION"] = "Bearer ".$this->token."NO";
|
||||||
$authjwt->cacheDir = $this->cacheDir;
|
$authjwt->cacheDir = $this->cacheDir;
|
||||||
$authjwt->serverKey = $this->serverKey;
|
$authjwt->serverKey = $this->serverKey;
|
||||||
@@ -78,7 +80,7 @@ class authjwtTest extends \PHPUnit_Framework_TestCase
|
|||||||
// {{{
|
// {{{
|
||||||
{
|
{
|
||||||
$this->expectException ("Exception", "JWT with Empty algorithm", 403);
|
$this->expectException ("Exception", "JWT with Empty algorithm", 403);
|
||||||
$authjwt = new authjwt ();
|
$authjwt = new Authjwt ();
|
||||||
$_SERVER["HTTP_AUTHENTICATION"] = "Bearer "."NO".$this->token;
|
$_SERVER["HTTP_AUTHENTICATION"] = "Bearer "."NO".$this->token;
|
||||||
$authjwt->cacheDir = $this->cacheDir;
|
$authjwt->cacheDir = $this->cacheDir;
|
||||||
$authjwt->serverKey = $this->serverKey;
|
$authjwt->serverKey = $this->serverKey;
|
||||||
@@ -94,7 +96,7 @@ class authjwtTest extends \PHPUnit_Framework_TestCase
|
|||||||
// {{{
|
// {{{
|
||||||
{
|
{
|
||||||
$this->expectException ("Exception", "No Authentication available", 401);
|
$this->expectException ("Exception", "No Authentication available", 401);
|
||||||
$authjwt = new authjwt ();
|
$authjwt = new Authjwt ();
|
||||||
unset ($_SERVER["HTTP_AUTHENTICATION"]);
|
unset ($_SERVER["HTTP_AUTHENTICATION"]);
|
||||||
$authjwt->cacheDir = $this->cacheDir;
|
$authjwt->cacheDir = $this->cacheDir;
|
||||||
$authjwt->serverKey = $this->serverKey;
|
$authjwt->serverKey = $this->serverKey;
|
||||||
@@ -111,7 +113,7 @@ class authjwtTest extends \PHPUnit_Framework_TestCase
|
|||||||
{
|
{
|
||||||
$this->expectException ("Exception", "No Bearer Authentication available",
|
$this->expectException ("Exception", "No Bearer Authentication available",
|
||||||
401);
|
401);
|
||||||
$authjwt = new authjwt ();
|
$authjwt = new Authjwt ();
|
||||||
$_SERVER["HTTP_AUTHENTICATION"] = "Bearer";
|
$_SERVER["HTTP_AUTHENTICATION"] = "Bearer";
|
||||||
$authjwt->cacheDir = $this->cacheDir;
|
$authjwt->cacheDir = $this->cacheDir;
|
||||||
$authjwt->serverKey = $this->serverKey;
|
$authjwt->serverKey = $this->serverKey;
|
||||||
@@ -129,7 +131,7 @@ class authjwtTest extends \PHPUnit_Framework_TestCase
|
|||||||
$this->expectException ("Exception",
|
$this->expectException ("Exception",
|
||||||
"AuthJWT : No email available in auth", 403);
|
"AuthJWT : No email available in auth", 403);
|
||||||
$auth = ["password" => "ToTo"];
|
$auth = ["password" => "ToTo"];
|
||||||
$authjwt = new authjwt ();
|
$authjwt = new Authjwt ();
|
||||||
$authjwt->cacheDir = $this->cacheDir;
|
$authjwt->cacheDir = $this->cacheDir;
|
||||||
$authjwt->serverKey = $this->serverKey;
|
$authjwt->serverKey = $this->serverKey;
|
||||||
$authjwt->cipherKey = $this->cipherKey;
|
$authjwt->cipherKey = $this->cipherKey;
|
||||||
@@ -148,7 +150,7 @@ class authjwtTest extends \PHPUnit_Framework_TestCase
|
|||||||
$this->expectException ("Exception",
|
$this->expectException ("Exception",
|
||||||
"AuthJWT : can not create token for anonymous", 403);
|
"AuthJWT : can not create token for anonymous", 403);
|
||||||
$auth = ["email" => "anonymous"];
|
$auth = ["email" => "anonymous"];
|
||||||
$authjwt = new authjwt ();
|
$authjwt = new Authjwt ();
|
||||||
$authjwt->cacheDir = $this->cacheDir;
|
$authjwt->cacheDir = $this->cacheDir;
|
||||||
$authjwt->serverKey = $this->serverKey;
|
$authjwt->serverKey = $this->serverKey;
|
||||||
$authjwt->cipherKey = $this->cipherKey;
|
$authjwt->cipherKey = $this->cipherKey;
|
||||||
@@ -164,7 +166,7 @@ class authjwtTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function testLogout1 ()
|
public function testLogout1 ()
|
||||||
// {{{
|
// {{{
|
||||||
{
|
{
|
||||||
$authjwt = new authjwt ();
|
$authjwt = new Authjwt ();
|
||||||
$authjwt->cacheDir = $this->cacheDir;
|
$authjwt->cacheDir = $this->cacheDir;
|
||||||
$authjwt->serverKey = $this->serverKey;
|
$authjwt->serverKey = $this->serverKey;
|
||||||
$authjwt->cipherKey = $this->cipherKey;
|
$authjwt->cipherKey = $this->cipherKey;
|
||||||
@@ -180,7 +182,7 @@ class authjwtTest extends \PHPUnit_Framework_TestCase
|
|||||||
// {{{
|
// {{{
|
||||||
{
|
{
|
||||||
$this->expectException ("Exception", "No Authentication available", 401);
|
$this->expectException ("Exception", "No Authentication available", 401);
|
||||||
$authjwt = new authjwt ();
|
$authjwt = new Authjwt ();
|
||||||
$authjwt->cacheDir = $this->cacheDir;
|
$authjwt->cacheDir = $this->cacheDir;
|
||||||
$authjwt->serverKey = $this->serverKey;
|
$authjwt->serverKey = $this->serverKey;
|
||||||
$authjwt->cipherKey = $this->cipherKey;
|
$authjwt->cipherKey = $this->cipherKey;
|
||||||
@@ -196,7 +198,7 @@ class authjwtTest extends \PHPUnit_Framework_TestCase
|
|||||||
{
|
{
|
||||||
$this->expectException ("Exception", "No Bearer Authentication available",
|
$this->expectException ("Exception", "No Bearer Authentication available",
|
||||||
401);
|
401);
|
||||||
$authjwt = new authjwt ();
|
$authjwt = new Authjwt ();
|
||||||
$authjwt->cacheDir = $this->cacheDir;
|
$authjwt->cacheDir = $this->cacheDir;
|
||||||
$authjwt->serverKey = $this->serverKey;
|
$authjwt->serverKey = $this->serverKey;
|
||||||
$authjwt->cipherKey = $this->cipherKey;
|
$authjwt->cipherKey = $this->cipherKey;
|
||||||
@@ -211,7 +213,7 @@ class authjwtTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function testUnusedFunctions1 ()
|
public function testUnusedFunctions1 ()
|
||||||
// {{{
|
// {{{
|
||||||
{
|
{
|
||||||
$authjwt = new authjwt ();
|
$authjwt = new Authjwt ();
|
||||||
$res = $authjwt->connect ();
|
$res = $authjwt->connect ();
|
||||||
$this->assertSame ($res, true);
|
$this->assertSame ($res, true);
|
||||||
}
|
}
|
||||||
@@ -224,7 +226,7 @@ class authjwtTest extends \PHPUnit_Framework_TestCase
|
|||||||
{
|
{
|
||||||
$this->expectException ("Exception",
|
$this->expectException ("Exception",
|
||||||
"The password can't be change for JWT users", 405);
|
"The password can't be change for JWT users", 405);
|
||||||
$authjwt = new authjwt ();
|
$authjwt = new Authjwt ();
|
||||||
$res = $authjwt->changepassword ("unused", "unused");
|
$res = $authjwt->changepassword ("unused", "unused");
|
||||||
}
|
}
|
||||||
// }}}
|
// }}}
|
||||||
@@ -236,7 +238,7 @@ class authjwtTest extends \PHPUnit_Framework_TestCase
|
|||||||
{
|
{
|
||||||
$this->expectException ("Exception",
|
$this->expectException ("Exception",
|
||||||
"The password can't be overwrite for JWT users", 405);
|
"The password can't be overwrite for JWT users", 405);
|
||||||
$authjwt = new authjwt ();
|
$authjwt = new Authjwt ();
|
||||||
$res = $authjwt->overwritepassword ("unused", "unused");
|
$res = $authjwt->overwritepassword ("unused", "unused");
|
||||||
}
|
}
|
||||||
// }}}
|
// }}}
|
||||||
|
|||||||
@@ -7,20 +7,22 @@
|
|||||||
|
|
||||||
namespace Domframework\Tests;
|
namespace Domframework\Tests;
|
||||||
|
|
||||||
|
use Domframework\Authsympa;
|
||||||
|
|
||||||
/** Test the authentication on Sympa Service */
|
/** Test the authentication on Sympa Service */
|
||||||
class authsympaTest extends \PHPUnit_Framework_TestCase
|
class AuthsympaTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
public function test_connect_1 ()
|
public function test_connect_1 ()
|
||||||
{
|
{
|
||||||
// Empty
|
// Empty
|
||||||
$authsympa = new authsympa ();
|
$authsympa = new Authsympa ();
|
||||||
$this->expectException ();
|
$this->expectException ();
|
||||||
$authsympa->connect ();
|
$authsympa->connect ();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_connect_2 ()
|
public function test_connect_2 ()
|
||||||
{
|
{
|
||||||
$authsympa = new authsympa ();
|
$authsympa = new Authsympa ();
|
||||||
$authsympa->wsdl = "https://listes.grenoble.cnrs.fr/sympa/wsdl";
|
$authsympa->wsdl = "https://listes.grenoble.cnrs.fr/sympa/wsdl";
|
||||||
$authsympa->connect ();
|
$authsympa->connect ();
|
||||||
$res = $authsympa->getDetails ();
|
$res = $authsympa->getDetails ();
|
||||||
@@ -30,7 +32,7 @@ class authsympaTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function test_auth_1 ()
|
public function test_auth_1 ()
|
||||||
{
|
{
|
||||||
// Invalid password
|
// Invalid password
|
||||||
$authsympa = new authsympa ();
|
$authsympa = new Authsympa ();
|
||||||
$authsympa->wsdl = "https://listes.grenoble.cnrs.fr/sympa/wsdl";
|
$authsympa->wsdl = "https://listes.grenoble.cnrs.fr/sympa/wsdl";
|
||||||
$authsympa->list = "listtest@listes.grenoble.cnrs.fr";
|
$authsympa->list = "listtest@listes.grenoble.cnrs.fr";
|
||||||
$authsympa->connect ();
|
$authsympa->connect ();
|
||||||
@@ -41,7 +43,7 @@ class authsympaTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function test_auth_2 ()
|
public function test_auth_2 ()
|
||||||
{
|
{
|
||||||
// Unknown user
|
// Unknown user
|
||||||
$authsympa = new authsympa ();
|
$authsympa = new Authsympa ();
|
||||||
$authsympa->wsdl = "https://listes.grenoble.cnrs.fr/sympa/wsdl";
|
$authsympa->wsdl = "https://listes.grenoble.cnrs.fr/sympa/wsdl";
|
||||||
$authsympa->list = "listtest@listes.grenoble.cnrs.fr";
|
$authsympa->list = "listtest@listes.grenoble.cnrs.fr";
|
||||||
$authsympa->connect ();
|
$authsympa->connect ();
|
||||||
@@ -52,7 +54,7 @@ class authsympaTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function test_auth_3 ()
|
public function test_auth_3 ()
|
||||||
{
|
{
|
||||||
// OK !
|
// OK !
|
||||||
$authsympa = new authsympa ();
|
$authsympa = new Authsympa ();
|
||||||
$authsympa->wsdl = "https://listes.grenoble.cnrs.fr/sympa/wsdl";
|
$authsympa->wsdl = "https://listes.grenoble.cnrs.fr/sympa/wsdl";
|
||||||
$authsympa->list = "listtest@listes.grenoble.cnrs.fr";
|
$authsympa->list = "listtest@listes.grenoble.cnrs.fr";
|
||||||
$authsympa->connect ();
|
$authsympa->connect ();
|
||||||
@@ -63,7 +65,7 @@ class authsympaTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function test_auth_4 ()
|
public function test_auth_4 ()
|
||||||
{
|
{
|
||||||
// Unknown list
|
// Unknown list
|
||||||
$authsympa = new authsympa ();
|
$authsympa = new Authsympa ();
|
||||||
$authsympa->wsdl = "https://listes.grenoble.cnrs.fr/sympa/wsdl";
|
$authsympa->wsdl = "https://listes.grenoble.cnrs.fr/sympa/wsdl";
|
||||||
$authsympa->list = "unknown@listes.grenoble.cnrs.fr";
|
$authsympa->list = "unknown@listes.grenoble.cnrs.fr";
|
||||||
$authsympa->connect ();
|
$authsympa->connect ();
|
||||||
@@ -74,7 +76,7 @@ class authsympaTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function test_auth_5 ()
|
public function test_auth_5 ()
|
||||||
{
|
{
|
||||||
// User not in list
|
// User not in list
|
||||||
$authsympa = new authsympa ();
|
$authsympa = new Authsympa ();
|
||||||
$authsympa->wsdl = "https://listes.grenoble.cnrs.fr/sympa/wsdl";
|
$authsympa->wsdl = "https://listes.grenoble.cnrs.fr/sympa/wsdl";
|
||||||
$authsympa->list = "admins@listes.grenoble.cnrs.fr";
|
$authsympa->list = "admins@listes.grenoble.cnrs.fr";
|
||||||
$authsympa->connect ();
|
$authsympa->connect ();
|
||||||
|
|||||||
@@ -7,8 +7,10 @@
|
|||||||
|
|
||||||
namespace Domframework\Tests;
|
namespace Domframework\Tests;
|
||||||
|
|
||||||
/** Test the authzgroups.php file */
|
use Domframework\Authzgroups;
|
||||||
class authzgroupsTest extends \PHPUnit_Framework_TestCase
|
|
||||||
|
/** Test the Authzgroups.php file */
|
||||||
|
class AuthzgroupsTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
private $dbconfig = array (
|
private $dbconfig = array (
|
||||||
"dsn" => "sqlite:/tmp/databaseAuthzGroups.db",
|
"dsn" => "sqlite:/tmp/databaseAuthzGroups.db",
|
||||||
@@ -19,12 +21,13 @@ class authzgroupsTest extends \PHPUnit_Framework_TestCase
|
|||||||
);
|
);
|
||||||
public function test_Initialization ()
|
public function test_Initialization ()
|
||||||
{
|
{
|
||||||
@unlink ("/tmp/databaseAuthzGroups.db");
|
if (file_exists ("/tmp/databaseAuthzGroups.db"))
|
||||||
|
unlink ("/tmp/databaseAuthzGroups.db");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_createTables1 ()
|
public function test_createTables1 ()
|
||||||
{
|
{
|
||||||
$authz = new authzgroups ();
|
$authz = new Authzgroups ();
|
||||||
$this->setExpectedException ("Exception");
|
$this->setExpectedException ("Exception");
|
||||||
$authz->createTables ();
|
$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
|
// Must use the model to create the database structure as there is no
|
||||||
// creation of tables in controller
|
// creation of tables in controller
|
||||||
$authz = new authzgroups ();
|
$authz = new Authzgroups ();
|
||||||
$res = $authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
|
$res = $authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
|
||||||
$this->dbconfig["password"],
|
$this->dbconfig["password"],
|
||||||
$this->dbconfig["driver_options"]);
|
$this->dbconfig["driver_options"]);
|
||||||
@@ -42,7 +45,7 @@ class authzgroupsTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_createTables2 ()
|
public function test_createTables2 ()
|
||||||
{
|
{
|
||||||
$authz = new authzgroups ();
|
$authz = new Authzgroups ();
|
||||||
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
|
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
|
||||||
$this->dbconfig["password"],
|
$this->dbconfig["password"],
|
||||||
$this->dbconfig["driver_options"]);
|
$this->dbconfig["driver_options"]);
|
||||||
@@ -55,7 +58,7 @@ class authzgroupsTest extends \PHPUnit_Framework_TestCase
|
|||||||
////////////////
|
////////////////
|
||||||
public function test_objectCreate1 ()
|
public function test_objectCreate1 ()
|
||||||
{
|
{
|
||||||
$authz = new authzgroups ();
|
$authz = new Authzgroups ();
|
||||||
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
|
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
|
||||||
$this->dbconfig["password"],
|
$this->dbconfig["password"],
|
||||||
$this->dbconfig["driver_options"]);
|
$this->dbconfig["driver_options"]);
|
||||||
@@ -65,7 +68,7 @@ class authzgroupsTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_objectUpdate1 ()
|
public function test_objectUpdate1 ()
|
||||||
{
|
{
|
||||||
$authz = new authzgroups ();
|
$authz = new Authzgroups ();
|
||||||
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
|
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
|
||||||
$this->dbconfig["password"],
|
$this->dbconfig["password"],
|
||||||
$this->dbconfig["driver_options"]);
|
$this->dbconfig["driver_options"]);
|
||||||
@@ -75,7 +78,7 @@ class authzgroupsTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_objectDelete1 ()
|
public function test_objectDelete1 ()
|
||||||
{
|
{
|
||||||
$authz = new authzgroups ();
|
$authz = new Authzgroups ();
|
||||||
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
|
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
|
||||||
$this->dbconfig["password"],
|
$this->dbconfig["password"],
|
||||||
$this->dbconfig["driver_options"]);
|
$this->dbconfig["driver_options"]);
|
||||||
@@ -89,7 +92,7 @@ class authzgroupsTest extends \PHPUnit_Framework_TestCase
|
|||||||
////////////////
|
////////////////
|
||||||
public function test_groupCreate1 ()
|
public function test_groupCreate1 ()
|
||||||
{
|
{
|
||||||
$authz = new authzgroups ();
|
$authz = new Authzgroups ();
|
||||||
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
|
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
|
||||||
$this->dbconfig["password"],
|
$this->dbconfig["password"],
|
||||||
$this->dbconfig["driver_options"]);
|
$this->dbconfig["driver_options"]);
|
||||||
@@ -99,7 +102,7 @@ class authzgroupsTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_groupUpdate1 ()
|
public function test_groupUpdate1 ()
|
||||||
{
|
{
|
||||||
$authz = new authzgroups ();
|
$authz = new Authzgroups ();
|
||||||
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
|
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
|
||||||
$this->dbconfig["password"],
|
$this->dbconfig["password"],
|
||||||
$this->dbconfig["driver_options"]);
|
$this->dbconfig["driver_options"]);
|
||||||
@@ -109,7 +112,7 @@ class authzgroupsTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_groupDelete1 ()
|
public function test_groupDelete1 ()
|
||||||
{
|
{
|
||||||
$authz = new authzgroups ();
|
$authz = new Authzgroups ();
|
||||||
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
|
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
|
||||||
$this->dbconfig["password"],
|
$this->dbconfig["password"],
|
||||||
$this->dbconfig["driver_options"]);
|
$this->dbconfig["driver_options"]);
|
||||||
@@ -123,7 +126,7 @@ class authzgroupsTest extends \PHPUnit_Framework_TestCase
|
|||||||
/////////////////////
|
/////////////////////
|
||||||
public function test_groupmemberCreate1 ()
|
public function test_groupmemberCreate1 ()
|
||||||
{
|
{
|
||||||
$authz = new authzgroups ();
|
$authz = new Authzgroups ();
|
||||||
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
|
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
|
||||||
$this->dbconfig["password"],
|
$this->dbconfig["password"],
|
||||||
$this->dbconfig["driver_options"]);
|
$this->dbconfig["driver_options"]);
|
||||||
@@ -134,7 +137,7 @@ class authzgroupsTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_groupmemberCreate2 ()
|
public function test_groupmemberCreate2 ()
|
||||||
{
|
{
|
||||||
$authz = new authzgroups ();
|
$authz = new Authzgroups ();
|
||||||
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
|
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
|
||||||
$this->dbconfig["password"],
|
$this->dbconfig["password"],
|
||||||
$this->dbconfig["driver_options"]);
|
$this->dbconfig["driver_options"]);
|
||||||
@@ -144,7 +147,7 @@ class authzgroupsTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_groupmemberDelete1 ()
|
public function test_groupmemberDelete1 ()
|
||||||
{
|
{
|
||||||
$authz = new authzgroups ();
|
$authz = new Authzgroups ();
|
||||||
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
|
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
|
||||||
$this->dbconfig["password"],
|
$this->dbconfig["password"],
|
||||||
$this->dbconfig["driver_options"]);
|
$this->dbconfig["driver_options"]);
|
||||||
@@ -155,7 +158,7 @@ class authzgroupsTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_groupmemberReadGroup1 ()
|
public function test_groupmemberReadGroup1 ()
|
||||||
{
|
{
|
||||||
$authz = new authzgroups ();
|
$authz = new Authzgroups ();
|
||||||
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
|
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
|
||||||
$this->dbconfig["password"],
|
$this->dbconfig["password"],
|
||||||
$this->dbconfig["driver_options"]);
|
$this->dbconfig["driver_options"]);
|
||||||
@@ -166,7 +169,7 @@ class authzgroupsTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_groupmemberReadGroup2 ()
|
public function test_groupmemberReadGroup2 ()
|
||||||
{
|
{
|
||||||
$authz = new authzgroups ();
|
$authz = new Authzgroups ();
|
||||||
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
|
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
|
||||||
$this->dbconfig["password"],
|
$this->dbconfig["password"],
|
||||||
$this->dbconfig["driver_options"]);
|
$this->dbconfig["driver_options"]);
|
||||||
@@ -176,7 +179,7 @@ class authzgroupsTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_groupmemberReadUser1 ()
|
public function test_groupmemberReadUser1 ()
|
||||||
{
|
{
|
||||||
$authz = new authzgroups ();
|
$authz = new Authzgroups ();
|
||||||
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
|
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
|
||||||
$this->dbconfig["password"],
|
$this->dbconfig["password"],
|
||||||
$this->dbconfig["driver_options"]);
|
$this->dbconfig["driver_options"]);
|
||||||
@@ -189,7 +192,7 @@ class authzgroupsTest extends \PHPUnit_Framework_TestCase
|
|||||||
////////////////
|
////////////////
|
||||||
public function test_rightCreate1 ()
|
public function test_rightCreate1 ()
|
||||||
{
|
{
|
||||||
$authz = new authzgroups ();
|
$authz = new Authzgroups ();
|
||||||
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
|
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
|
||||||
$this->dbconfig["password"],
|
$this->dbconfig["password"],
|
||||||
$this->dbconfig["driver_options"]);
|
$this->dbconfig["driver_options"]);
|
||||||
@@ -199,7 +202,7 @@ class authzgroupsTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_rightUpdate1 ()
|
public function test_rightUpdate1 ()
|
||||||
{
|
{
|
||||||
$authz = new authzgroups ();
|
$authz = new Authzgroups ();
|
||||||
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
|
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
|
||||||
$this->dbconfig["password"],
|
$this->dbconfig["password"],
|
||||||
$this->dbconfig["driver_options"]);
|
$this->dbconfig["driver_options"]);
|
||||||
@@ -209,7 +212,7 @@ class authzgroupsTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_rightDelete1 ()
|
public function test_rightDelete1 ()
|
||||||
{
|
{
|
||||||
$authz = new authzgroups ();
|
$authz = new Authzgroups ();
|
||||||
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
|
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
|
||||||
$this->dbconfig["password"],
|
$this->dbconfig["password"],
|
||||||
$this->dbconfig["driver_options"]);
|
$this->dbconfig["driver_options"]);
|
||||||
@@ -224,7 +227,7 @@ class authzgroupsTest extends \PHPUnit_Framework_TestCase
|
|||||||
//////////////////////////////////////////////
|
//////////////////////////////////////////////
|
||||||
public function test_deleteGroupmember2 ()
|
public function test_deleteGroupmember2 ()
|
||||||
{
|
{
|
||||||
$authz = new authzgroups ();
|
$authz = new Authzgroups ();
|
||||||
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
|
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
|
||||||
$this->dbconfig["password"],
|
$this->dbconfig["password"],
|
||||||
$this->dbconfig["driver_options"]);
|
$this->dbconfig["driver_options"]);
|
||||||
@@ -234,7 +237,7 @@ class authzgroupsTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_deleteObject2 ()
|
public function test_deleteObject2 ()
|
||||||
{
|
{
|
||||||
$authz = new authzgroups ();
|
$authz = new Authzgroups ();
|
||||||
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
|
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
|
||||||
$this->dbconfig["password"],
|
$this->dbconfig["password"],
|
||||||
$this->dbconfig["driver_options"]);
|
$this->dbconfig["driver_options"]);
|
||||||
@@ -244,7 +247,7 @@ class authzgroupsTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_deleteGroup2 ()
|
public function test_deleteGroup2 ()
|
||||||
{
|
{
|
||||||
$authz = new authzgroups ();
|
$authz = new Authzgroups ();
|
||||||
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
|
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
|
||||||
$this->dbconfig["password"],
|
$this->dbconfig["password"],
|
||||||
$this->dbconfig["driver_options"]);
|
$this->dbconfig["driver_options"]);
|
||||||
@@ -257,7 +260,7 @@ class authzgroupsTest extends \PHPUnit_Framework_TestCase
|
|||||||
/////////////////////
|
/////////////////////
|
||||||
public function test_userrightsget1 ()
|
public function test_userrightsget1 ()
|
||||||
{
|
{
|
||||||
$authz = new authzgroups ();
|
$authz = new Authzgroups ();
|
||||||
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
|
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
|
||||||
$this->dbconfig["password"],
|
$this->dbconfig["password"],
|
||||||
$this->dbconfig["driver_options"]);
|
$this->dbconfig["driver_options"]);
|
||||||
@@ -286,7 +289,7 @@ class authzgroupsTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_allow1 ()
|
public function test_allow1 ()
|
||||||
{
|
{
|
||||||
$authz = new authzgroups ();
|
$authz = new Authzgroups ();
|
||||||
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
|
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
|
||||||
$this->dbconfig["password"],
|
$this->dbconfig["password"],
|
||||||
$this->dbconfig["driver_options"]);
|
$this->dbconfig["driver_options"]);
|
||||||
@@ -296,7 +299,7 @@ class authzgroupsTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_allow2 ()
|
public function test_allow2 ()
|
||||||
{
|
{
|
||||||
$authz = new authzgroups ();
|
$authz = new Authzgroups ();
|
||||||
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
|
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
|
||||||
$this->dbconfig["password"],
|
$this->dbconfig["password"],
|
||||||
$this->dbconfig["driver_options"]);
|
$this->dbconfig["driver_options"]);
|
||||||
@@ -307,7 +310,7 @@ class authzgroupsTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_allow3 ()
|
public function test_allow3 ()
|
||||||
{
|
{
|
||||||
$authz = new authzgroups ();
|
$authz = new Authzgroups ();
|
||||||
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
|
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
|
||||||
$this->dbconfig["password"],
|
$this->dbconfig["password"],
|
||||||
$this->dbconfig["driver_options"]);
|
$this->dbconfig["driver_options"]);
|
||||||
@@ -318,7 +321,7 @@ class authzgroupsTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_allow4 ()
|
public function test_allow4 ()
|
||||||
{
|
{
|
||||||
$authz = new authzgroups ();
|
$authz = new Authzgroups ();
|
||||||
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
|
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
|
||||||
$this->dbconfig["password"],
|
$this->dbconfig["password"],
|
||||||
$this->dbconfig["driver_options"]);
|
$this->dbconfig["driver_options"]);
|
||||||
|
|||||||
@@ -7,8 +7,10 @@
|
|||||||
|
|
||||||
namespace Domframework\Tests;
|
namespace Domframework\Tests;
|
||||||
|
|
||||||
/** Test the authzgroupsoo.php file */
|
use Domframework\Authzgroupsoo;
|
||||||
class authzgroupsooTest extends \PHPUnit_Framework_TestCase
|
|
||||||
|
/** Test the Authzgroupsoo.php file */
|
||||||
|
class AuthzgroupsooTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
private $dbconfig = array (
|
private $dbconfig = array (
|
||||||
"dsn" => "sqlite:/tmp/databaseAuthzGroupsoo.db",
|
"dsn" => "sqlite:/tmp/databaseAuthzGroupsoo.db",
|
||||||
@@ -19,12 +21,13 @@ class authzgroupsooTest extends \PHPUnit_Framework_TestCase
|
|||||||
);
|
);
|
||||||
public function test_Initialization ()
|
public function test_Initialization ()
|
||||||
{
|
{
|
||||||
@unlink ("/tmp/databaseAuthzGroupsoo.db");
|
if (file_exists ("/tmp/databaseAuthzGroupsoo.db"))
|
||||||
|
unlink ("/tmp/databaseAuthzGroupsoo.db");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_createTables1 ()
|
public function test_createTables1 ()
|
||||||
{
|
{
|
||||||
$authz = new authzgroupsoo ();
|
$authz = new Authzgroupsoo ();
|
||||||
$this->setExpectedException ("Exception");
|
$this->setExpectedException ("Exception");
|
||||||
$authz->createTables ();
|
$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
|
// Must use the model to create the database structure as there is no
|
||||||
// creation of tables in controller
|
// creation of tables in controller
|
||||||
$authz = new authzgroupsoo ();
|
$authz = new Authzgroupsoo ();
|
||||||
$res = $authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
|
$res = $authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
|
||||||
$this->dbconfig["password"],
|
$this->dbconfig["password"],
|
||||||
$this->dbconfig["driver_options"]);
|
$this->dbconfig["driver_options"]);
|
||||||
@@ -42,7 +45,7 @@ class authzgroupsooTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_createTables2 ()
|
public function test_createTables2 ()
|
||||||
{
|
{
|
||||||
$authz = new authzgroupsoo ();
|
$authz = new Authzgroupsoo ();
|
||||||
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
|
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
|
||||||
$this->dbconfig["password"],
|
$this->dbconfig["password"],
|
||||||
$this->dbconfig["driver_options"]);
|
$this->dbconfig["driver_options"]);
|
||||||
@@ -55,7 +58,7 @@ class authzgroupsooTest extends \PHPUnit_Framework_TestCase
|
|||||||
////////////////
|
////////////////
|
||||||
public function test_objectCreate1 ()
|
public function test_objectCreate1 ()
|
||||||
{
|
{
|
||||||
$authz = new authzgroupsoo ();
|
$authz = new Authzgroupsoo ();
|
||||||
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
|
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
|
||||||
$this->dbconfig["password"],
|
$this->dbconfig["password"],
|
||||||
$this->dbconfig["driver_options"]);
|
$this->dbconfig["driver_options"]);
|
||||||
@@ -65,7 +68,7 @@ class authzgroupsooTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_objectUpdate1 ()
|
public function test_objectUpdate1 ()
|
||||||
{
|
{
|
||||||
$authz = new authzgroupsoo ();
|
$authz = new Authzgroupsoo ();
|
||||||
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
|
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
|
||||||
$this->dbconfig["password"],
|
$this->dbconfig["password"],
|
||||||
$this->dbconfig["driver_options"]);
|
$this->dbconfig["driver_options"]);
|
||||||
@@ -75,7 +78,7 @@ class authzgroupsooTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_objectDelete1 ()
|
public function test_objectDelete1 ()
|
||||||
{
|
{
|
||||||
$authz = new authzgroupsoo ();
|
$authz = new Authzgroupsoo ();
|
||||||
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
|
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
|
||||||
$this->dbconfig["password"],
|
$this->dbconfig["password"],
|
||||||
$this->dbconfig["driver_options"]);
|
$this->dbconfig["driver_options"]);
|
||||||
@@ -89,7 +92,7 @@ class authzgroupsooTest extends \PHPUnit_Framework_TestCase
|
|||||||
////////////////
|
////////////////
|
||||||
public function test_groupCreate1 ()
|
public function test_groupCreate1 ()
|
||||||
{
|
{
|
||||||
$authz = new authzgroupsoo ();
|
$authz = new Authzgroupsoo ();
|
||||||
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
|
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
|
||||||
$this->dbconfig["password"],
|
$this->dbconfig["password"],
|
||||||
$this->dbconfig["driver_options"]);
|
$this->dbconfig["driver_options"]);
|
||||||
@@ -99,7 +102,7 @@ class authzgroupsooTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_groupUpdate1 ()
|
public function test_groupUpdate1 ()
|
||||||
{
|
{
|
||||||
$authz = new authzgroupsoo ();
|
$authz = new Authzgroupsoo ();
|
||||||
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
|
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
|
||||||
$this->dbconfig["password"],
|
$this->dbconfig["password"],
|
||||||
$this->dbconfig["driver_options"]);
|
$this->dbconfig["driver_options"]);
|
||||||
@@ -109,7 +112,7 @@ class authzgroupsooTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_groupDelete1 ()
|
public function test_groupDelete1 ()
|
||||||
{
|
{
|
||||||
$authz = new authzgroupsoo ();
|
$authz = new Authzgroupsoo ();
|
||||||
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
|
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
|
||||||
$this->dbconfig["password"],
|
$this->dbconfig["password"],
|
||||||
$this->dbconfig["driver_options"]);
|
$this->dbconfig["driver_options"]);
|
||||||
@@ -123,7 +126,7 @@ class authzgroupsooTest extends \PHPUnit_Framework_TestCase
|
|||||||
/////////////////////
|
/////////////////////
|
||||||
public function test_groupmemberCreate1 ()
|
public function test_groupmemberCreate1 ()
|
||||||
{
|
{
|
||||||
$authz = new authzgroupsoo ();
|
$authz = new Authzgroupsoo ();
|
||||||
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
|
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
|
||||||
$this->dbconfig["password"],
|
$this->dbconfig["password"],
|
||||||
$this->dbconfig["driver_options"]);
|
$this->dbconfig["driver_options"]);
|
||||||
@@ -134,7 +137,7 @@ class authzgroupsooTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_groupmemberCreate2 ()
|
public function test_groupmemberCreate2 ()
|
||||||
{
|
{
|
||||||
$authz = new authzgroupsoo ();
|
$authz = new Authzgroupsoo ();
|
||||||
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
|
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
|
||||||
$this->dbconfig["password"],
|
$this->dbconfig["password"],
|
||||||
$this->dbconfig["driver_options"]);
|
$this->dbconfig["driver_options"]);
|
||||||
@@ -144,7 +147,7 @@ class authzgroupsooTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_groupmemberDelete1 ()
|
public function test_groupmemberDelete1 ()
|
||||||
{
|
{
|
||||||
$authz = new authzgroupsoo ();
|
$authz = new Authzgroupsoo ();
|
||||||
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
|
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
|
||||||
$this->dbconfig["password"],
|
$this->dbconfig["password"],
|
||||||
$this->dbconfig["driver_options"]);
|
$this->dbconfig["driver_options"]);
|
||||||
@@ -155,7 +158,7 @@ class authzgroupsooTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_groupmemberReadGroup1 ()
|
public function test_groupmemberReadGroup1 ()
|
||||||
{
|
{
|
||||||
$authz = new authzgroupsoo ();
|
$authz = new Authzgroupsoo ();
|
||||||
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
|
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
|
||||||
$this->dbconfig["password"],
|
$this->dbconfig["password"],
|
||||||
$this->dbconfig["driver_options"]);
|
$this->dbconfig["driver_options"]);
|
||||||
@@ -166,7 +169,7 @@ class authzgroupsooTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_groupmemberReadGroup2 ()
|
public function test_groupmemberReadGroup2 ()
|
||||||
{
|
{
|
||||||
$authz = new authzgroupsoo ();
|
$authz = new Authzgroupsoo ();
|
||||||
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
|
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
|
||||||
$this->dbconfig["password"],
|
$this->dbconfig["password"],
|
||||||
$this->dbconfig["driver_options"]);
|
$this->dbconfig["driver_options"]);
|
||||||
@@ -176,7 +179,7 @@ class authzgroupsooTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_groupmemberReadUser1 ()
|
public function test_groupmemberReadUser1 ()
|
||||||
{
|
{
|
||||||
$authz = new authzgroupsoo ();
|
$authz = new Authzgroupsoo ();
|
||||||
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
|
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
|
||||||
$this->dbconfig["password"],
|
$this->dbconfig["password"],
|
||||||
$this->dbconfig["driver_options"]);
|
$this->dbconfig["driver_options"]);
|
||||||
@@ -189,7 +192,7 @@ class authzgroupsooTest extends \PHPUnit_Framework_TestCase
|
|||||||
////////////////
|
////////////////
|
||||||
public function test_rightCreate1 ()
|
public function test_rightCreate1 ()
|
||||||
{
|
{
|
||||||
$authz = new authzgroupsoo ();
|
$authz = new Authzgroupsoo ();
|
||||||
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
|
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
|
||||||
$this->dbconfig["password"],
|
$this->dbconfig["password"],
|
||||||
$this->dbconfig["driver_options"]);
|
$this->dbconfig["driver_options"]);
|
||||||
@@ -199,7 +202,7 @@ class authzgroupsooTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_rightUpdate1 ()
|
public function test_rightUpdate1 ()
|
||||||
{
|
{
|
||||||
$authz = new authzgroupsoo ();
|
$authz = new Authzgroupsoo ();
|
||||||
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
|
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
|
||||||
$this->dbconfig["password"],
|
$this->dbconfig["password"],
|
||||||
$this->dbconfig["driver_options"]);
|
$this->dbconfig["driver_options"]);
|
||||||
@@ -209,7 +212,7 @@ class authzgroupsooTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_rightDelete1 ()
|
public function test_rightDelete1 ()
|
||||||
{
|
{
|
||||||
$authz = new authzgroupsoo ();
|
$authz = new Authzgroupsoo ();
|
||||||
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
|
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
|
||||||
$this->dbconfig["password"],
|
$this->dbconfig["password"],
|
||||||
$this->dbconfig["driver_options"]);
|
$this->dbconfig["driver_options"]);
|
||||||
@@ -224,7 +227,7 @@ class authzgroupsooTest extends \PHPUnit_Framework_TestCase
|
|||||||
//////////////////////////////////////////////
|
//////////////////////////////////////////////
|
||||||
public function test_deleteGroupmember2 ()
|
public function test_deleteGroupmember2 ()
|
||||||
{
|
{
|
||||||
$authz = new authzgroupsoo ();
|
$authz = new Authzgroupsoo ();
|
||||||
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
|
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
|
||||||
$this->dbconfig["password"],
|
$this->dbconfig["password"],
|
||||||
$this->dbconfig["driver_options"]);
|
$this->dbconfig["driver_options"]);
|
||||||
@@ -234,7 +237,7 @@ class authzgroupsooTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_deleteObject2 ()
|
public function test_deleteObject2 ()
|
||||||
{
|
{
|
||||||
$authz = new authzgroupsoo ();
|
$authz = new Authzgroupsoo ();
|
||||||
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
|
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
|
||||||
$this->dbconfig["password"],
|
$this->dbconfig["password"],
|
||||||
$this->dbconfig["driver_options"]);
|
$this->dbconfig["driver_options"]);
|
||||||
@@ -244,7 +247,7 @@ class authzgroupsooTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_deleteGroup2 ()
|
public function test_deleteGroup2 ()
|
||||||
{
|
{
|
||||||
$authz = new authzgroupsoo ();
|
$authz = new Authzgroupsoo ();
|
||||||
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
|
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
|
||||||
$this->dbconfig["password"],
|
$this->dbconfig["password"],
|
||||||
$this->dbconfig["driver_options"]);
|
$this->dbconfig["driver_options"]);
|
||||||
@@ -257,7 +260,7 @@ class authzgroupsooTest extends \PHPUnit_Framework_TestCase
|
|||||||
/////////////////////
|
/////////////////////
|
||||||
public function test_userrightsget1 ()
|
public function test_userrightsget1 ()
|
||||||
{
|
{
|
||||||
$authz = new authzgroupsoo ();
|
$authz = new Authzgroupsoo ();
|
||||||
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
|
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
|
||||||
$this->dbconfig["password"],
|
$this->dbconfig["password"],
|
||||||
$this->dbconfig["driver_options"]);
|
$this->dbconfig["driver_options"]);
|
||||||
@@ -286,7 +289,7 @@ class authzgroupsooTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_allow1 ()
|
public function test_allow1 ()
|
||||||
{
|
{
|
||||||
$authz = new authzgroupsoo ();
|
$authz = new Authzgroupsoo ();
|
||||||
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
|
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
|
||||||
$this->dbconfig["password"],
|
$this->dbconfig["password"],
|
||||||
$this->dbconfig["driver_options"]);
|
$this->dbconfig["driver_options"]);
|
||||||
@@ -296,7 +299,7 @@ class authzgroupsooTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_allow2 ()
|
public function test_allow2 ()
|
||||||
{
|
{
|
||||||
$authz = new authzgroupsoo ();
|
$authz = new Authzgroupsoo ();
|
||||||
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
|
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
|
||||||
$this->dbconfig["password"],
|
$this->dbconfig["password"],
|
||||||
$this->dbconfig["driver_options"]);
|
$this->dbconfig["driver_options"]);
|
||||||
@@ -307,7 +310,7 @@ class authzgroupsooTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_allow3 ()
|
public function test_allow3 ()
|
||||||
{
|
{
|
||||||
$authz = new authzgroupsoo ();
|
$authz = new Authzgroupsoo ();
|
||||||
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
|
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
|
||||||
$this->dbconfig["password"],
|
$this->dbconfig["password"],
|
||||||
$this->dbconfig["driver_options"]);
|
$this->dbconfig["driver_options"]);
|
||||||
@@ -318,7 +321,7 @@ class authzgroupsooTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_allow4 ()
|
public function test_allow4 ()
|
||||||
{
|
{
|
||||||
$authz = new authzgroupsoo ();
|
$authz = new Authzgroupsoo ();
|
||||||
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
|
$authz->connect ($this->dbconfig["dsn"], $this->dbconfig["username"],
|
||||||
$this->dbconfig["password"],
|
$this->dbconfig["password"],
|
||||||
$this->dbconfig["driver_options"]);
|
$this->dbconfig["driver_options"]);
|
||||||
|
|||||||
@@ -7,8 +7,10 @@
|
|||||||
|
|
||||||
namespace Domframework\Tests;
|
namespace Domframework\Tests;
|
||||||
|
|
||||||
/** Test the cache.php file */
|
use Domframework\Cachefile;
|
||||||
class cachefileTest extends \PHPUnit_Framework_TestCase
|
|
||||||
|
/** Test the Cachefile.php file */
|
||||||
|
class CachefileTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
public function testInit ()
|
public function testInit ()
|
||||||
{
|
{
|
||||||
@@ -19,7 +21,7 @@ class cachefileTest extends \PHPUnit_Framework_TestCase
|
|||||||
// Unknown cache file : return FALSE
|
// Unknown cache file : return FALSE
|
||||||
public function testRead1 ()
|
public function testRead1 ()
|
||||||
{
|
{
|
||||||
$c = new cachefile ();
|
$c = new Cachefile ();
|
||||||
$c->directory = "/tmp/cache";
|
$c->directory = "/tmp/cache";
|
||||||
$res = $c->read ("id");
|
$res = $c->read ("id");
|
||||||
$this->assertFalse ($res);
|
$this->assertFalse ($res);
|
||||||
@@ -28,7 +30,7 @@ class cachefileTest extends \PHPUnit_Framework_TestCase
|
|||||||
// Write in cache file
|
// Write in cache file
|
||||||
public function testWrite1 ()
|
public function testWrite1 ()
|
||||||
{
|
{
|
||||||
$c = new cachefile ();
|
$c = new Cachefile ();
|
||||||
$c->directory = "/tmp/cache";
|
$c->directory = "/tmp/cache";
|
||||||
$res = $c->write ("id","DATA_TO_STORE", 3);
|
$res = $c->write ("id","DATA_TO_STORE", 3);
|
||||||
$this->assertTrue ($res);
|
$this->assertTrue ($res);
|
||||||
@@ -37,7 +39,7 @@ class cachefileTest extends \PHPUnit_Framework_TestCase
|
|||||||
// Previous cache file : return DATA_TO_STORE
|
// Previous cache file : return DATA_TO_STORE
|
||||||
public function testRead2 ()
|
public function testRead2 ()
|
||||||
{
|
{
|
||||||
$c = new cachefile ();
|
$c = new Cachefile ();
|
||||||
$c->directory = "/tmp/cache";
|
$c->directory = "/tmp/cache";
|
||||||
$res = $c->read ("id");
|
$res = $c->read ("id");
|
||||||
$this->assertSame ("DATA_TO_STORE", $res);
|
$this->assertSame ("DATA_TO_STORE", $res);
|
||||||
@@ -52,7 +54,7 @@ class cachefileTest extends \PHPUnit_Framework_TestCase
|
|||||||
// Previous cache file but expired : return false
|
// Previous cache file but expired : return false
|
||||||
public function testRead3 ()
|
public function testRead3 ()
|
||||||
{
|
{
|
||||||
$c = new cachefile ();
|
$c = new Cachefile ();
|
||||||
$c->directory = "/tmp/cache";
|
$c->directory = "/tmp/cache";
|
||||||
$res = $c->read ("id");
|
$res = $c->read ("id");
|
||||||
$this->assertFalse ($res);
|
$this->assertFalse ($res);
|
||||||
@@ -61,7 +63,7 @@ class cachefileTest extends \PHPUnit_Framework_TestCase
|
|||||||
// Write in cache file
|
// Write in cache file
|
||||||
public function testWrite2 ()
|
public function testWrite2 ()
|
||||||
{
|
{
|
||||||
$c = new cachefile ();
|
$c = new Cachefile ();
|
||||||
$c->directory = "/tmp/cache";
|
$c->directory = "/tmp/cache";
|
||||||
$res = $c->write ("id","DATA_TO_STORE", 30);
|
$res = $c->write ("id","DATA_TO_STORE", 30);
|
||||||
$this->assertTrue ($res);
|
$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
|
// This test takes 10s to wait the lock which will never be released
|
||||||
public function testRead4 ()
|
public function testRead4 ()
|
||||||
{
|
{
|
||||||
$c = new cachefile ();
|
$c = new Cachefile ();
|
||||||
$c->directory = "/tmp/cache";
|
$c->directory = "/tmp/cache";
|
||||||
$res = $c->read ("id");
|
$res = $c->read ("id");
|
||||||
$this->assertSame ("DATA_TO_STORE", $res);
|
$this->assertSame ("DATA_TO_STORE", $res);
|
||||||
@@ -85,7 +87,7 @@ class cachefileTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function testDel1 ()
|
public function testDel1 ()
|
||||||
{
|
{
|
||||||
$c = new cachefile ();
|
$c = new Cachefile ();
|
||||||
$c->directory = "/tmp/cache";
|
$c->directory = "/tmp/cache";
|
||||||
$res = $c->delete ("id");
|
$res = $c->delete ("id");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,13 +7,15 @@
|
|||||||
|
|
||||||
namespace Domframework\Tests;
|
namespace Domframework\Tests;
|
||||||
|
|
||||||
|
use Domframework\Certificationauthority;
|
||||||
|
|
||||||
/** Test the certification Authority
|
/** Test the certification Authority
|
||||||
*/
|
*/
|
||||||
class certificationauthorityTest extends \PHPUnit_Framework_TestCase
|
class CertificationauthorityTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
public function test_createCA_1 ()
|
public function test_createCA_1 ()
|
||||||
{
|
{
|
||||||
$certificationauthority = new certificationauthority ();
|
$certificationauthority = new Certificationauthority ();
|
||||||
$certificationauthority->createCA ("FR", "FOURNIER38", "CATEST");
|
$certificationauthority->createCA ("FR", "FOURNIER38", "CATEST");
|
||||||
$caCert = explode ("\n", $certificationauthority->caCert ());
|
$caCert = explode ("\n", $certificationauthority->caCert ());
|
||||||
$caKey = explode ("\n", $certificationauthority->caKey ());
|
$caKey = explode ("\n", $certificationauthority->caKey ());
|
||||||
@@ -24,7 +26,7 @@ class certificationauthorityTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_createCA_2 ()
|
public function test_createCA_2 ()
|
||||||
{
|
{
|
||||||
$certificationauthority = new certificationauthority ();
|
$certificationauthority = new Certificationauthority ();
|
||||||
$certificationauthority->createCA ("FR", "FOURNIER38", "CATEST");
|
$certificationauthority->createCA ("FR", "FOURNIER38", "CATEST");
|
||||||
$caCert = $certificationauthority->caCert ();
|
$caCert = $certificationauthority->caCert ();
|
||||||
file_put_contents ("/tmp/test_createCA_2", $caCert);
|
file_put_contents ("/tmp/test_createCA_2", $caCert);
|
||||||
@@ -37,7 +39,7 @@ class certificationauthorityTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_createPK_1 ()
|
public function test_createPK_1 ()
|
||||||
{
|
{
|
||||||
$certificationauthority = new certificationauthority ();
|
$certificationauthority = new Certificationauthority ();
|
||||||
$privateKey = $certificationauthority->createPrivateKey () -> privateKey ();
|
$privateKey = $certificationauthority->createPrivateKey () -> privateKey ();
|
||||||
$privateKey = explode ("\n", $privateKey);
|
$privateKey = explode ("\n", $privateKey);
|
||||||
$this->assertSame ($privateKey[0], "-----BEGIN PRIVATE KEY-----");
|
$this->assertSame ($privateKey[0], "-----BEGIN PRIVATE KEY-----");
|
||||||
@@ -45,7 +47,7 @@ class certificationauthorityTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_createCSR_1 ()
|
public function test_createCSR_1 ()
|
||||||
{
|
{
|
||||||
$certificationauthority = new certificationauthority ();
|
$certificationauthority = new Certificationauthority ();
|
||||||
$csr = $certificationauthority->createCSR ("FR", "FOURNIER38", "CSR");
|
$csr = $certificationauthority->createCSR ("FR", "FOURNIER38", "CSR");
|
||||||
$csr = explode ("\n", $csr);
|
$csr = explode ("\n", $csr);
|
||||||
$this->assertSame ($csr[0], "-----BEGIN CERTIFICATE REQUEST-----");
|
$this->assertSame ($csr[0], "-----BEGIN CERTIFICATE REQUEST-----");
|
||||||
@@ -53,7 +55,7 @@ class certificationauthorityTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_signCSR_1 ()
|
public function test_signCSR_1 ()
|
||||||
{
|
{
|
||||||
$certificationauthority = new certificationauthority ();
|
$certificationauthority = new Certificationauthority ();
|
||||||
$certificationauthority->createCA ("FR", "FOURNIER38", "CATEST");
|
$certificationauthority->createCA ("FR", "FOURNIER38", "CATEST");
|
||||||
$caCert = $certificationauthority->caCert ();
|
$caCert = $certificationauthority->caCert ();
|
||||||
$caKey = $certificationauthority->caKey ();
|
$caKey = $certificationauthority->caKey ();
|
||||||
@@ -65,7 +67,7 @@ class certificationauthorityTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_signCSR_2 ()
|
public function test_signCSR_2 ()
|
||||||
{
|
{
|
||||||
$certificationauthority = new certificationauthority ();
|
$certificationauthority = new Certificationauthority ();
|
||||||
$certificationauthority->createCA ("FR", "FOURNIER38", "CATEST");
|
$certificationauthority->createCA ("FR", "FOURNIER38", "CATEST");
|
||||||
$caCert = $certificationauthority->caCert ();
|
$caCert = $certificationauthority->caCert ();
|
||||||
$caKey = $certificationauthority->caKey ();
|
$caKey = $certificationauthority->caKey ();
|
||||||
@@ -82,7 +84,7 @@ class certificationauthorityTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function test_signCSR_3 ()
|
public function test_signCSR_3 ()
|
||||||
{
|
{
|
||||||
// Check if generated cert X509v3 Extended Key Usage are valid
|
// Check if generated cert X509v3 Extended Key Usage are valid
|
||||||
$certificationauthority = new certificationauthority ();
|
$certificationauthority = new Certificationauthority ();
|
||||||
$certificationauthority->createCA ("FR", "FOURNIER38", "CATEST");
|
$certificationauthority->createCA ("FR", "FOURNIER38", "CATEST");
|
||||||
$caCert = $certificationauthority->caCert ();
|
$caCert = $certificationauthority->caCert ();
|
||||||
$caKey = $certificationauthority->caKey ();
|
$caKey = $certificationauthority->caKey ();
|
||||||
@@ -100,7 +102,7 @@ class certificationauthorityTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function test_signCSR_4 ()
|
public function test_signCSR_4 ()
|
||||||
{
|
{
|
||||||
// Check if generated cert issuer name is valid
|
// Check if generated cert issuer name is valid
|
||||||
$certificationauthority = new certificationauthority ();
|
$certificationauthority = new Certificationauthority ();
|
||||||
$certificationauthority->createCA ("FR", "FOURNIER38", "CATEST");
|
$certificationauthority->createCA ("FR", "FOURNIER38", "CATEST");
|
||||||
$caCert = $certificationauthority->caCert ();
|
$caCert = $certificationauthority->caCert ();
|
||||||
$caKey = $certificationauthority->caKey ();
|
$caKey = $certificationauthority->caKey ();
|
||||||
@@ -117,7 +119,7 @@ class certificationauthorityTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function test_signCSR_5 ()
|
public function test_signCSR_5 ()
|
||||||
{
|
{
|
||||||
// Check if generated cert is not tagged CA
|
// Check if generated cert is not tagged CA
|
||||||
$certificationauthority = new certificationauthority ();
|
$certificationauthority = new Certificationauthority ();
|
||||||
$certificationauthority->createCA ("FR", "FOURNIER38", "CATEST");
|
$certificationauthority->createCA ("FR", "FOURNIER38", "CATEST");
|
||||||
$caCert = $certificationauthority->caCert ();
|
$caCert = $certificationauthority->caCert ();
|
||||||
$caKey = $certificationauthority->caKey ();
|
$caKey = $certificationauthority->caKey ();
|
||||||
@@ -134,7 +136,7 @@ class certificationauthorityTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function test_signCSR_6 ()
|
public function test_signCSR_6 ()
|
||||||
{
|
{
|
||||||
// Check if generated cert has Alternative Names
|
// Check if generated cert has Alternative Names
|
||||||
$certificationauthority = new certificationauthority ();
|
$certificationauthority = new Certificationauthority ();
|
||||||
$certificationauthority->createCA ("FR", "FOURNIER38", "CATEST");
|
$certificationauthority->createCA ("FR", "FOURNIER38", "CATEST");
|
||||||
$caCert = $certificationauthority->caCert ();
|
$caCert = $certificationauthority->caCert ();
|
||||||
$caKey = $certificationauthority->caKey ();
|
$caKey = $certificationauthority->caKey ();
|
||||||
|
|||||||
@@ -7,8 +7,10 @@
|
|||||||
|
|
||||||
namespace Domframework\Tests;
|
namespace Domframework\Tests;
|
||||||
|
|
||||||
/** Test the config.php file */
|
use Domframework\Config;
|
||||||
class configTest extends \PHPUnit_Framework_TestCase
|
|
||||||
|
/** Test the Config.php file */
|
||||||
|
class ConfigTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
|
|
||||||
public function test_ExternFile ()
|
public function test_ExternFile ()
|
||||||
@@ -19,14 +21,14 @@ class configTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_params1 ()
|
public function test_params1 ()
|
||||||
{
|
{
|
||||||
$c = new config ();
|
$c = new Config ();
|
||||||
$res = $c->params ();
|
$res = $c->params ();
|
||||||
$this->assertSame (array (), $res);
|
$this->assertSame (array (), $res);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGet1 ()
|
public function testGet1 ()
|
||||||
{
|
{
|
||||||
$c = new config ();
|
$c = new Config ();
|
||||||
$c->confFile = "/tmp/testconf.php";
|
$c->confFile = "/tmp/testconf.php";
|
||||||
$c->default = array (
|
$c->default = array (
|
||||||
"database"=>array (
|
"database"=>array (
|
||||||
@@ -46,7 +48,7 @@ class configTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function testSet1 ()
|
public function testSet1 ()
|
||||||
{
|
{
|
||||||
$c = new config ();
|
$c = new Config ();
|
||||||
$c->confFile = "/tmp/testconf.php";
|
$c->confFile = "/tmp/testconf.php";
|
||||||
$c->default = array (
|
$c->default = array (
|
||||||
"database"=>array (
|
"database"=>array (
|
||||||
@@ -58,7 +60,7 @@ class configTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function testGet2 ()
|
public function testGet2 ()
|
||||||
{
|
{
|
||||||
$c = new config ();
|
$c = new Config ();
|
||||||
$c->confFile = "/tmp/testconf.php";
|
$c->confFile = "/tmp/testconf.php";
|
||||||
$c->default = array (
|
$c->default = array (
|
||||||
"database"=>array (
|
"database"=>array (
|
||||||
@@ -73,7 +75,7 @@ class configTest extends \PHPUnit_Framework_TestCase
|
|||||||
/** Can't create file */
|
/** Can't create file */
|
||||||
public function testGet3 ()
|
public function testGet3 ()
|
||||||
{
|
{
|
||||||
$c = new config ();
|
$c = new Config ();
|
||||||
$c->confFile = "/tmp/1/2.3/dd/testconf.php";
|
$c->confFile = "/tmp/1/2.3/dd/testconf.php";
|
||||||
$c->default = array (
|
$c->default = array (
|
||||||
"database"=>array (
|
"database"=>array (
|
||||||
@@ -86,7 +88,7 @@ class configTest extends \PHPUnit_Framework_TestCase
|
|||||||
/** Can't read the file */
|
/** Can't read the file */
|
||||||
public function testGet4 ()
|
public function testGet4 ()
|
||||||
{
|
{
|
||||||
$c = new config ();
|
$c = new Config ();
|
||||||
$c->confFile = "/tmp/testconf.php";
|
$c->confFile = "/tmp/testconf.php";
|
||||||
chmod ("/tmp/testconf.php", 0222);
|
chmod ("/tmp/testconf.php", 0222);
|
||||||
$c->default = array (
|
$c->default = array (
|
||||||
@@ -100,7 +102,7 @@ class configTest extends \PHPUnit_Framework_TestCase
|
|||||||
/** File non exists and can not be created */
|
/** File non exists and can not be created */
|
||||||
public function testSet2 ()
|
public function testSet2 ()
|
||||||
{
|
{
|
||||||
$c = new config ();
|
$c = new Config ();
|
||||||
$c->confFile = "/tmp/1/2.3/dd/testconf.php";
|
$c->confFile = "/tmp/1/2.3/dd/testconf.php";
|
||||||
$c->default = array (
|
$c->default = array (
|
||||||
"database"=>array (
|
"database"=>array (
|
||||||
@@ -113,7 +115,7 @@ class configTest extends \PHPUnit_Framework_TestCase
|
|||||||
/** Can't read the file */
|
/** Can't read the file */
|
||||||
public function testSet3 ()
|
public function testSet3 ()
|
||||||
{
|
{
|
||||||
$c = new config ();
|
$c = new Config ();
|
||||||
$c->confFile = "/tmp/testconf.php";
|
$c->confFile = "/tmp/testconf.php";
|
||||||
chmod ("/tmp/testconf.php", 0222);
|
chmod ("/tmp/testconf.php", 0222);
|
||||||
$c->default = array (
|
$c->default = array (
|
||||||
@@ -127,7 +129,7 @@ class configTest extends \PHPUnit_Framework_TestCase
|
|||||||
/** Can't write the file */
|
/** Can't write the file */
|
||||||
public function testSet4 ()
|
public function testSet4 ()
|
||||||
{
|
{
|
||||||
$c = new config ();
|
$c = new Config ();
|
||||||
$c->confFile = "/tmp/testconf.php";
|
$c->confFile = "/tmp/testconf.php";
|
||||||
chmod ("/tmp/testconf.php", 0444);
|
chmod ("/tmp/testconf.php", 0444);
|
||||||
$c->default = array (
|
$c->default = array (
|
||||||
@@ -141,7 +143,7 @@ class configTest extends \PHPUnit_Framework_TestCase
|
|||||||
/** Save TRUE/FALSE/NULL/String values */
|
/** Save TRUE/FALSE/NULL/String values */
|
||||||
public function testSet5 ()
|
public function testSet5 ()
|
||||||
{
|
{
|
||||||
$c = new config ();
|
$c = new Config ();
|
||||||
$c->confFile = "/tmp/testconf.php";
|
$c->confFile = "/tmp/testconf.php";
|
||||||
chmod ("/tmp/testconf.php", 0666);
|
chmod ("/tmp/testconf.php", 0666);
|
||||||
$c->default = array (
|
$c->default = array (
|
||||||
@@ -158,7 +160,7 @@ class configTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function testGet6 ()
|
public function testGet6 ()
|
||||||
{
|
{
|
||||||
$c = new config ();
|
$c = new Config ();
|
||||||
$c->confFile = "/tmp/testconf.php";
|
$c->confFile = "/tmp/testconf.php";
|
||||||
chmod ("/tmp/testconf.php", 0666);
|
chmod ("/tmp/testconf.php", 0666);
|
||||||
$c->default = array (
|
$c->default = array (
|
||||||
@@ -183,7 +185,7 @@ class configTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function testSet7 ()
|
public function testSet7 ()
|
||||||
{
|
{
|
||||||
$c = new config ();
|
$c = new Config ();
|
||||||
$c->confFile = "/tmp/testconf.php";
|
$c->confFile = "/tmp/testconf.php";
|
||||||
chmod ("/tmp/testconf.php", 0666);
|
chmod ("/tmp/testconf.php", 0666);
|
||||||
$c->default = array (
|
$c->default = array (
|
||||||
@@ -207,7 +209,7 @@ class configTest extends \PHPUnit_Framework_TestCase
|
|||||||
}
|
}
|
||||||
public function testGet7 ()
|
public function testGet7 ()
|
||||||
{
|
{
|
||||||
$c = new config ();
|
$c = new Config ();
|
||||||
$c->confFile = "/tmp/testconf.php";
|
$c->confFile = "/tmp/testconf.php";
|
||||||
chmod ("/tmp/testconf.php", 0666);
|
chmod ("/tmp/testconf.php", 0666);
|
||||||
$c->default = array (
|
$c->default = array (
|
||||||
@@ -233,7 +235,7 @@ class configTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function testGet8 ()
|
public function testGet8 ()
|
||||||
{
|
{
|
||||||
$c = new config ();
|
$c = new Config ();
|
||||||
$c->confFile = "/tmp/testconf.php";
|
$c->confFile = "/tmp/testconf.php";
|
||||||
chmod ("/tmp/testconf.php", 0666);
|
chmod ("/tmp/testconf.php", 0666);
|
||||||
$c->default = array (
|
$c->default = array (
|
||||||
|
|||||||
@@ -7,60 +7,62 @@
|
|||||||
|
|
||||||
namespace Domframework\Tests;
|
namespace Domframework\Tests;
|
||||||
|
|
||||||
|
use Domframework\Convert;
|
||||||
|
|
||||||
/** Test the Conversion of format */
|
/** Test the Conversion of format */
|
||||||
class convertTest extends \PHPUnit_Framework_TestCase
|
class ConvertTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
public function test_convertDate1 ()
|
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");
|
$this->assertSame ($res, "13/04/2017");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_convertDate2 ()
|
public function test_convertDate2 ()
|
||||||
{
|
{
|
||||||
$this->setExpectedException ("Exception");
|
$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 ()
|
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");
|
$this->assertSame ($res, "2017-13-33");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_ucwords_1 ()
|
public function test_ucwords_1 ()
|
||||||
{
|
{
|
||||||
$res = \convert::ucwords (" test yuyu ");
|
$res = Convert::ucwords (" test yuyu ");
|
||||||
$this->assertSame ($res, " Test Yuyu ");
|
$this->assertSame ($res, " Test Yuyu ");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_ucwords_2 ()
|
public function test_ucwords_2 ()
|
||||||
{
|
{
|
||||||
$res = \convert::ucwords ("");
|
$res = Convert::ucwords ("");
|
||||||
$this->assertSame ($res, "");
|
$this->assertSame ($res, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_ucwords_3 ()
|
public function test_ucwords_3 ()
|
||||||
{
|
{
|
||||||
$res = \convert::ucwords ("test");
|
$res = Convert::ucwords ("test");
|
||||||
$this->assertSame ($res, "Test");
|
$this->assertSame ($res, "Test");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_ucwords_4 ()
|
public function test_ucwords_4 ()
|
||||||
{
|
{
|
||||||
$res = \convert::ucwords ("TEST");
|
$res = Convert::ucwords ("TEST");
|
||||||
$this->assertSame ($res, "Test");
|
$this->assertSame ($res, "Test");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_ucwords_5 ()
|
public function test_ucwords_5 ()
|
||||||
{
|
{
|
||||||
$res = \convert::ucwords ("édouard étienne");
|
$res = Convert::ucwords ("édouard étienne");
|
||||||
$this->assertSame ($res, "Édouard Étienne");
|
$this->assertSame ($res, "Édouard Étienne");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_ucwords_6 ()
|
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");
|
$this->assertSame ($res, "Édou-Ard D'Étienne");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,7 +74,7 @@ class convertTest extends \PHPUnit_Framework_TestCase
|
|||||||
$res = "";
|
$res = "";
|
||||||
for ($i = -8 ; $i <= 8 ; $i++)
|
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".
|
$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".
|
"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 ()
|
public function test_humanSize_2 ()
|
||||||
{
|
{
|
||||||
$res = \convert::humanSize (1441234);
|
$res = Convert::humanSize (1441234);
|
||||||
$this->assertSame ($res, "1.44MB");
|
$this->assertSame ($res, "1.44MB");
|
||||||
}
|
}
|
||||||
public function test_humanSize_3 ()
|
public function test_humanSize_3 ()
|
||||||
{
|
{
|
||||||
$res = \convert::humanSize (10441234);
|
$res = Convert::humanSize (10441234);
|
||||||
$this->assertSame ($res, "10.44MB");
|
$this->assertSame ($res, "10.44MB");
|
||||||
}
|
}
|
||||||
public function test_humanSize_4 ()
|
public function test_humanSize_4 ()
|
||||||
{
|
{
|
||||||
$res = \convert::humanSize (0.123, 0);
|
$res = Convert::humanSize (0.123, 0);
|
||||||
$this->assertSame ($res, "123mB");
|
$this->assertSame ($res, "123mB");
|
||||||
}
|
}
|
||||||
public function test_humanSize_5 ()
|
public function test_humanSize_5 ()
|
||||||
{
|
{
|
||||||
$res = \convert::humanSize (0.12345, 2);
|
$res = Convert::humanSize (0.12345, 2);
|
||||||
$this->assertSame ($res, "123.45mB");
|
$this->assertSame ($res, "123.45mB");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_humanSize_6 ()
|
public function test_humanSize_6 ()
|
||||||
{
|
{
|
||||||
$res = \convert::humanSize (-0.12345, 2);
|
$res = Convert::humanSize (-0.12345, 2);
|
||||||
$this->assertSame ($res, "-123.45mB");
|
$this->assertSame ($res, "-123.45mB");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_humanSize_7 ()
|
public function test_humanSize_7 ()
|
||||||
{
|
{
|
||||||
$res = \convert::humanSize (-12345, 2);
|
$res = Convert::humanSize (-12345, 2);
|
||||||
$this->assertSame ($res, "-12.35kB");
|
$this->assertSame ($res, "-12.35kB");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_humanSize_8 ()
|
public function test_humanSize_8 ()
|
||||||
{
|
{
|
||||||
$res = \convert::humanSize (0, 2);
|
$res = Convert::humanSize (0, 2);
|
||||||
$this->assertSame ($res, "0.00B");
|
$this->assertSame ($res, "0.00B");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -123,27 +125,27 @@ class convertTest extends \PHPUnit_Framework_TestCase
|
|||||||
{
|
{
|
||||||
$this->expectException ("Exception",
|
$this->expectException ("Exception",
|
||||||
"convert::humanSize value not numerical : string", 500);
|
"convert::humanSize value not numerical : string", 500);
|
||||||
$res = \convert::humanSize ("1441234");
|
$res = Convert::humanSize ("1441234");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_humanSize_error2 ()
|
public function test_humanSize_error2 ()
|
||||||
{
|
{
|
||||||
$this->expectException ("Exception",
|
$this->expectException ("Exception",
|
||||||
"convert::humanSize decimal not integer : double", 500);
|
"convert::humanSize decimal not integer : double", 500);
|
||||||
$res = \convert::humanSize (1441234, 0.1);
|
$res = Convert::humanSize (1441234, 0.1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_humanSize_error3 ()
|
public function test_humanSize_error3 ()
|
||||||
{
|
{
|
||||||
$this->expectException ("Exception",
|
$this->expectException ("Exception",
|
||||||
"convert::humanSize decimal value negative", 500);
|
"convert::humanSize decimal value negative", 500);
|
||||||
$res = \convert::humanSize (1441234, -1);
|
$res = Convert::humanSize (1441234, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_humanSize_error4 ()
|
public function test_humanSize_error4 ()
|
||||||
{
|
{
|
||||||
$this->expectException ("Exception",
|
$this->expectException ("Exception",
|
||||||
"convert::humanSize power value !== 1000 and 1024 : 2000", 500);
|
"convert::humanSize power value !== 1000 and 1024 : 2000", 500);
|
||||||
$res = \convert::humanSize (1441234, 2, 2000);
|
$res = Convert::humanSize (1441234, 2, 2000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,12 +7,14 @@
|
|||||||
|
|
||||||
namespace Domframework\Tests;
|
namespace Domframework\Tests;
|
||||||
|
|
||||||
/** Test the csrf.php file */
|
use Domframework\Csrf;
|
||||||
class csrfTest extends \PHPUnit_Framework_TestCase
|
|
||||||
|
/** Test the Csrf.php file */
|
||||||
|
class CsrfTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
public function test_csrf1 ()
|
public function test_csrf1 ()
|
||||||
{
|
{
|
||||||
$csrf = new csrf ();
|
$csrf = new Csrf ();
|
||||||
$res = $csrf->createToken ();
|
$res = $csrf->createToken ();
|
||||||
$GLOBALS["CSRFTEST-Token"] = $res;
|
$GLOBALS["CSRFTEST-Token"] = $res;
|
||||||
$this->assertSame (30, strlen ($res));
|
$this->assertSame (30, strlen ($res));
|
||||||
@@ -20,7 +22,7 @@ class csrfTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_csrf2 ()
|
public function test_csrf2 ()
|
||||||
{
|
{
|
||||||
$csrf = new csrf ();
|
$csrf = new Csrf ();
|
||||||
$res = $csrf->createToken ();
|
$res = $csrf->createToken ();
|
||||||
$this->assertSame (
|
$this->assertSame (
|
||||||
strspn ($res,
|
strspn ($res,
|
||||||
@@ -29,14 +31,14 @@ class csrfTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_csrf3 ()
|
public function test_csrf3 ()
|
||||||
{
|
{
|
||||||
$csrf = new csrf ();
|
$csrf = new Csrf ();
|
||||||
$this->setExpectedException ("Exception");
|
$this->setExpectedException ("Exception");
|
||||||
$res = $csrf->checkToken ("NOT VALID TOKEN");
|
$res = $csrf->checkToken ("NOT VALID TOKEN");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_csrf4 ()
|
public function test_csrf4 ()
|
||||||
{
|
{
|
||||||
$csrf = new csrf ();
|
$csrf = new Csrf ();
|
||||||
$token = $csrf->createToken ();
|
$token = $csrf->createToken ();
|
||||||
$res = $csrf->checkToken ($token);
|
$res = $csrf->checkToken ($token);
|
||||||
$this->assertSame (true, $res);
|
$this->assertSame (true, $res);
|
||||||
@@ -44,7 +46,7 @@ class csrfTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_csrf5 ()
|
public function test_csrf5 ()
|
||||||
{
|
{
|
||||||
$csrf = new csrf ();
|
$csrf = new Csrf ();
|
||||||
$token = $csrf->createToken ();
|
$token = $csrf->createToken ();
|
||||||
$res = $csrf->extendToken ($token);
|
$res = $csrf->extendToken ($token);
|
||||||
$this->assertSame (true, $res);
|
$this->assertSame (true, $res);
|
||||||
@@ -52,7 +54,7 @@ class csrfTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_csrf6 ()
|
public function test_csrf6 ()
|
||||||
{
|
{
|
||||||
$csrf = new csrf ();
|
$csrf = new Csrf ();
|
||||||
$token = $csrf->createToken ();
|
$token = $csrf->createToken ();
|
||||||
$res = $csrf->getToken ();
|
$res = $csrf->getToken ();
|
||||||
$this->assertSame ($token, $res);
|
$this->assertSame ($token, $res);
|
||||||
@@ -60,16 +62,16 @@ class csrfTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_csrf7 ()
|
public function test_csrf7 ()
|
||||||
{
|
{
|
||||||
$csrf = new csrf ();
|
$csrf = new Csrf ();
|
||||||
$res = $csrf->getToken ();
|
$res = $csrf->getToken ();
|
||||||
$this->assertSame (30, strlen ($res));
|
$this->assertSame (30, strlen ($res));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_csrf_multiple_1 ()
|
public function test_csrf_multiple_1 ()
|
||||||
{
|
{
|
||||||
$csrf1 = new csrf ();
|
$csrf1 = new Csrf ();
|
||||||
$token1 = $csrf1->createToken ();
|
$token1 = $csrf1->createToken ();
|
||||||
$csrf2 = new csrf ();
|
$csrf2 = new Csrf ();
|
||||||
$token2 = $csrf2->createToken ();
|
$token2 = $csrf2->createToken ();
|
||||||
$this->assertSame (true,
|
$this->assertSame (true,
|
||||||
$csrf2->checkToken ($token1) && $csrf2->checkToken ($token2));
|
$csrf2->checkToken ($token1) && $csrf2->checkToken ($token2));
|
||||||
@@ -77,16 +79,16 @@ class csrfTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_csrf_multiple_extend_2 ()
|
public function test_csrf_multiple_extend_2 ()
|
||||||
{
|
{
|
||||||
$csrf = new csrf ();
|
$csrf = new Csrf ();
|
||||||
$res = $csrf->extendToken ($GLOBALS["CSRFTEST-Token"]);
|
$res = $csrf->extendToken ($GLOBALS["CSRFTEST-Token"]);
|
||||||
$this->assertSame (true, $res);
|
$this->assertSame (true, $res);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_csrf_multiple_get ()
|
public function test_csrf_multiple_get ()
|
||||||
{
|
{
|
||||||
$csrf1 = new csrf ();
|
$csrf1 = new Csrf ();
|
||||||
$token1 = $csrf1->createToken ();
|
$token1 = $csrf1->createToken ();
|
||||||
$csrf2 = new csrf ();
|
$csrf2 = new Csrf ();
|
||||||
$token2 = $csrf2->getToken ();
|
$token2 = $csrf2->getToken ();
|
||||||
$this->assertSame ($token1, $token2);
|
$this->assertSame ($token1, $token2);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,14 +7,16 @@
|
|||||||
|
|
||||||
namespace Domframework\Tests;
|
namespace Domframework\Tests;
|
||||||
|
|
||||||
/** Test the dbjson database */
|
use Domframework\Dbjson;
|
||||||
class dbjsonTest extends \PHPUnit_Framework_TestCase
|
|
||||||
|
/** Test the Dbjson database */
|
||||||
|
class DbjsonTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
public function test_insertOne1 ()
|
public function test_insertOne1 ()
|
||||||
{
|
{
|
||||||
// Document #0
|
// Document #0
|
||||||
define ("dbfile", "/tmp/dbjson-".time());
|
define ("dbfile", "/tmp/dbjson-".time());
|
||||||
$dbjson = new dbjson ("dbjson://".dbfile);
|
$dbjson = new Dbjson ("dbjson://".dbfile);
|
||||||
$res = $dbjson->insertOne ("collection",
|
$res = $dbjson->insertOne ("collection",
|
||||||
array ("key1"=>"val1", "key2"=>"val2"));
|
array ("key1"=>"val1", "key2"=>"val2"));
|
||||||
$this->assertSame ($res, 1);
|
$this->assertSame ($res, 1);
|
||||||
@@ -23,7 +25,7 @@ class dbjsonTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function test_insertOne2 ()
|
public function test_insertOne2 ()
|
||||||
{
|
{
|
||||||
// Document #1
|
// Document #1
|
||||||
$dbjson = new dbjson ("dbjson://".dbfile);
|
$dbjson = new Dbjson ("dbjson://".dbfile);
|
||||||
$res = $dbjson->insertOne ("collection",
|
$res = $dbjson->insertOne ("collection",
|
||||||
array ("key1"=>"val1", "key2"=>"val2"));
|
array ("key1"=>"val1", "key2"=>"val2"));
|
||||||
$this->assertSame ($res, 1);
|
$this->assertSame ($res, 1);
|
||||||
@@ -33,7 +35,7 @@ class dbjsonTest extends \PHPUnit_Framework_TestCase
|
|||||||
{
|
{
|
||||||
// Error : Invalid array provided (not array of array)
|
// Error : Invalid array provided (not array of array)
|
||||||
$this->setExpectedException ("Exception");
|
$this->setExpectedException ("Exception");
|
||||||
$dbjson = new dbjson ("dbjson://".dbfile);
|
$dbjson = new Dbjson ("dbjson://".dbfile);
|
||||||
$res = $dbjson->insertMany ("collection",
|
$res = $dbjson->insertMany ("collection",
|
||||||
array ("key1"=>"val1", "key2"=>"val2"));
|
array ("key1"=>"val1", "key2"=>"val2"));
|
||||||
}
|
}
|
||||||
@@ -41,7 +43,7 @@ class dbjsonTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function test_insertMany2 ()
|
public function test_insertMany2 ()
|
||||||
{
|
{
|
||||||
// Document #2 and #3
|
// Document #2 and #3
|
||||||
$dbjson = new dbjson ("dbjson://".dbfile);
|
$dbjson = new Dbjson ("dbjson://".dbfile);
|
||||||
$res = $dbjson->insertMany ("collection",
|
$res = $dbjson->insertMany ("collection",
|
||||||
array (array ("key1"=>"val3", "key2"=>"val2"),
|
array (array ("key1"=>"val3", "key2"=>"val2"),
|
||||||
array ("key1"=>"val3", "key2"=>"val4")));
|
array ("key1"=>"val3", "key2"=>"val4")));
|
||||||
@@ -51,21 +53,21 @@ class dbjsonTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function test_filter1 ()
|
public function test_filter1 ()
|
||||||
{
|
{
|
||||||
// Return all the keys (filter = array ())
|
// Return all the keys (filter = array ())
|
||||||
$dbjson = new dbjson ("dbjson://".dbfile);
|
$dbjson = new Dbjson ("dbjson://".dbfile);
|
||||||
$res = $dbjson->filter ("collection", array ());
|
$res = $dbjson->filter ("collection", array ());
|
||||||
$this->assertSame (array_keys ($res), array (0,1,2,3));
|
$this->assertSame (array_keys ($res), array (0,1,2,3));
|
||||||
}
|
}
|
||||||
public function test_filter2 ()
|
public function test_filter2 ()
|
||||||
{
|
{
|
||||||
// Return the keys where filter = array ("key2"=>"val2"))
|
// 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"));
|
$res = $dbjson->filter ("collection", array ("key2"=>"val2"));
|
||||||
$this->assertSame (array_keys ($res), array (0,1,2));
|
$this->assertSame (array_keys ($res), array (0,1,2));
|
||||||
}
|
}
|
||||||
public function test_filter3 ()
|
public function test_filter3 ()
|
||||||
{
|
{
|
||||||
// Return the keys where filter = array ("key1"=>"val3","key2"=>"val2"))
|
// 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",
|
$res = $dbjson->filter ("collection", array ("key1"=>"val3",
|
||||||
"key2"=>"val2"));
|
"key2"=>"val2"));
|
||||||
$this->assertSame (count ($res), 1);
|
$this->assertSame (count ($res), 1);
|
||||||
@@ -74,7 +76,7 @@ class dbjsonTest extends \PHPUnit_Framework_TestCase
|
|||||||
{
|
{
|
||||||
// Return the keys where filter = array ("key1"=>array ("val3", "=="),
|
// Return the keys where filter = array ("key1"=>array ("val3", "=="),
|
||||||
// "key2"=>array ("val2", "=="))
|
// "key2"=>array ("val2", "=="))
|
||||||
$dbjson = new dbjson ("dbjson://".dbfile);
|
$dbjson = new Dbjson ("dbjson://".dbfile);
|
||||||
$res = $dbjson->filter ("collection",array ("key1"=>array ("val3", "=="),
|
$res = $dbjson->filter ("collection",array ("key1"=>array ("val3", "=="),
|
||||||
"key2"=>array ("val2", "==")));
|
"key2"=>array ("val2", "==")));
|
||||||
$this->assertSame (count ($res), 1);
|
$this->assertSame (count ($res), 1);
|
||||||
@@ -83,7 +85,7 @@ class dbjsonTest extends \PHPUnit_Framework_TestCase
|
|||||||
{
|
{
|
||||||
// Return the keys where filter = array ("key1"=>array ("val3", "<="),
|
// Return the keys where filter = array ("key1"=>array ("val3", "<="),
|
||||||
// "key2"=>array ("val2", "=="))
|
// "key2"=>array ("val2", "=="))
|
||||||
$dbjson = new dbjson ("dbjson://".dbfile);
|
$dbjson = new Dbjson ("dbjson://".dbfile);
|
||||||
$res = $dbjson->filter ("collection", array ("key1"=>array ("val3", "<="),
|
$res = $dbjson->filter ("collection", array ("key1"=>array ("val3", "<="),
|
||||||
"key2"=>array ("val2", "==")));
|
"key2"=>array ("val2", "==")));
|
||||||
$this->assertSame (array_keys ($res), array (0,1,2));
|
$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", "<="),
|
// Return the keys where filter = array ("key1"=>array ("val3", "<="),
|
||||||
// "key2"=>array ("val2", ">"))
|
// "key2"=>array ("val2", ">"))
|
||||||
$dbjson = new dbjson ("dbjson://".dbfile);
|
$dbjson = new Dbjson ("dbjson://".dbfile);
|
||||||
$res = $dbjson->filter ("collection", array ("key1"=>array ("val3", "<="),
|
$res = $dbjson->filter ("collection", array ("key1"=>array ("val3", "<="),
|
||||||
"key2"=>array ("val2", ">")));
|
"key2"=>array ("val2", ">")));
|
||||||
$this->assertSame (count ($res), 1);
|
$this->assertSame (count ($res), 1);
|
||||||
@@ -100,7 +102,7 @@ class dbjsonTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_find1 ()
|
public function test_find1 ()
|
||||||
{
|
{
|
||||||
$dbjson = new dbjson ("dbjson://".dbfile);
|
$dbjson = new Dbjson ("dbjson://".dbfile);
|
||||||
$res = $dbjson->find ("collection", array ("key1"=>array ("val3", "<="),
|
$res = $dbjson->find ("collection", array ("key1"=>array ("val3", "<="),
|
||||||
"key2"=>array ("val2", ">")));
|
"key2"=>array ("val2", ">")));
|
||||||
$res = array_values ($res);
|
$res = array_values ($res);
|
||||||
@@ -111,7 +113,7 @@ class dbjsonTest extends \PHPUnit_Framework_TestCase
|
|||||||
}
|
}
|
||||||
public function test_find2 ()
|
public function test_find2 ()
|
||||||
{
|
{
|
||||||
$dbjson = new dbjson ("dbjson://".dbfile);
|
$dbjson = new Dbjson ("dbjson://".dbfile);
|
||||||
$res = $dbjson->find ("collection", array ("key1"=>array ("val3", "<="),
|
$res = $dbjson->find ("collection", array ("key1"=>array ("val3", "<="),
|
||||||
"key2"=>array ("val2", ">")),
|
"key2"=>array ("val2", ">")),
|
||||||
"*");
|
"*");
|
||||||
@@ -125,14 +127,14 @@ class dbjsonTest extends \PHPUnit_Framework_TestCase
|
|||||||
{
|
{
|
||||||
// Exception : fields not an array
|
// Exception : fields not an array
|
||||||
$this->setExpectedException ("Exception");
|
$this->setExpectedException ("Exception");
|
||||||
$dbjson = new dbjson ("dbjson://".dbfile);
|
$dbjson = new Dbjson ("dbjson://".dbfile);
|
||||||
$res = $dbjson->find ("collection", array ("key1"=>array ("val3", "<="),
|
$res = $dbjson->find ("collection", array ("key1"=>array ("val3", "<="),
|
||||||
"key2"=>array ("val2", ">")),
|
"key2"=>array ("val2", ">")),
|
||||||
"key1");
|
"key1");
|
||||||
}
|
}
|
||||||
public function test_find4 ()
|
public function test_find4 ()
|
||||||
{
|
{
|
||||||
$dbjson = new dbjson ("dbjson://".dbfile);
|
$dbjson = new Dbjson ("dbjson://".dbfile);
|
||||||
$res = $dbjson->find ("collection", array ("key1"=>array ("val3", "<="),
|
$res = $dbjson->find ("collection", array ("key1"=>array ("val3", "<="),
|
||||||
"key2"=>array ("val2", ">")),
|
"key2"=>array ("val2", ">")),
|
||||||
array ("key1"));
|
array ("key1"));
|
||||||
@@ -143,7 +145,7 @@ class dbjsonTest extends \PHPUnit_Framework_TestCase
|
|||||||
}
|
}
|
||||||
public function test_find5 ()
|
public function test_find5 ()
|
||||||
{
|
{
|
||||||
$dbjson = new dbjson ("dbjson://".dbfile);
|
$dbjson = new Dbjson ("dbjson://".dbfile);
|
||||||
$res = $dbjson->find ("collection", array ("key1"=>array ("val3", "<="),
|
$res = $dbjson->find ("collection", array ("key1"=>array ("val3", "<="),
|
||||||
"key2"=>array ("val2", ">")),
|
"key2"=>array ("val2", ">")),
|
||||||
array ("key1", "key2"));
|
array ("key1", "key2"));
|
||||||
@@ -155,7 +157,7 @@ class dbjsonTest extends \PHPUnit_Framework_TestCase
|
|||||||
}
|
}
|
||||||
public function test_find6 ()
|
public function test_find6 ()
|
||||||
{
|
{
|
||||||
$dbjson = new dbjson ("dbjson://".dbfile);
|
$dbjson = new Dbjson ("dbjson://".dbfile);
|
||||||
$res = $dbjson->find ("collection", array ("key1"=>array ("val3", "<="),
|
$res = $dbjson->find ("collection", array ("key1"=>array ("val3", "<="),
|
||||||
"key2"=>array ("val2", "==")),
|
"key2"=>array ("val2", "==")),
|
||||||
array ("key1", "key2"));
|
array ("key1", "key2"));
|
||||||
@@ -173,7 +175,7 @@ class dbjsonTest extends \PHPUnit_Framework_TestCase
|
|||||||
}
|
}
|
||||||
public function test_find7 ()
|
public function test_find7 ()
|
||||||
{
|
{
|
||||||
$dbjson = new dbjson ("dbjson://".dbfile);
|
$dbjson = new Dbjson ("dbjson://".dbfile);
|
||||||
$res = $dbjson->find ("collection", array ("key1"=>array ("val3", "<="),
|
$res = $dbjson->find ("collection", array ("key1"=>array ("val3", "<="),
|
||||||
"key2"=>array ("val2", "==")),
|
"key2"=>array ("val2", "==")),
|
||||||
array ("key2"));
|
array ("key2"));
|
||||||
@@ -188,7 +190,7 @@ class dbjsonTest extends \PHPUnit_Framework_TestCase
|
|||||||
}
|
}
|
||||||
public function test_find8 ()
|
public function test_find8 ()
|
||||||
{
|
{
|
||||||
$dbjson = new dbjson ("dbjson://".dbfile);
|
$dbjson = new Dbjson ("dbjson://".dbfile);
|
||||||
$res = $dbjson->find ("collection", array ("key1"=>array ("val3", "<="),
|
$res = $dbjson->find ("collection", array ("key1"=>array ("val3", "<="),
|
||||||
"key2"=>array ("val2", "==")),
|
"key2"=>array ("val2", "==")),
|
||||||
array ("key2"), 1);
|
array ("key2"), 1);
|
||||||
@@ -200,7 +202,7 @@ class dbjsonTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_deleteOne1 ()
|
public function test_deleteOne1 ()
|
||||||
{
|
{
|
||||||
$dbjson = new dbjson ("dbjson://".dbfile);
|
$dbjson = new Dbjson ("dbjson://".dbfile);
|
||||||
$res = $dbjson->deleteOne ("collection",
|
$res = $dbjson->deleteOne ("collection",
|
||||||
array ("key1"=>array ("val3", "<="),
|
array ("key1"=>array ("val3", "<="),
|
||||||
"key2"=>array ("val2", "==")));
|
"key2"=>array ("val2", "==")));
|
||||||
@@ -208,7 +210,7 @@ class dbjsonTest extends \PHPUnit_Framework_TestCase
|
|||||||
}
|
}
|
||||||
public function test_find9 ()
|
public function test_find9 ()
|
||||||
{
|
{
|
||||||
$dbjson = new dbjson ("dbjson://".dbfile);
|
$dbjson = new Dbjson ("dbjson://".dbfile);
|
||||||
$res = $dbjson->find ("collection", array ("key1"=>array ("val3", "<="),
|
$res = $dbjson->find ("collection", array ("key1"=>array ("val3", "<="),
|
||||||
"key2"=>array ("val2", "==")),
|
"key2"=>array ("val2", "==")),
|
||||||
array ("key2"));
|
array ("key2"));
|
||||||
@@ -222,7 +224,7 @@ class dbjsonTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_deleteMany1 ()
|
public function test_deleteMany1 ()
|
||||||
{
|
{
|
||||||
$dbjson = new dbjson ("dbjson://".dbfile);
|
$dbjson = new Dbjson ("dbjson://".dbfile);
|
||||||
$res = $dbjson->deleteMany ("collection",
|
$res = $dbjson->deleteMany ("collection",
|
||||||
array ("key1"=>array ("val3", "<="),
|
array ("key1"=>array ("val3", "<="),
|
||||||
"key2"=>array ("val2", "==")));
|
"key2"=>array ("val2", "==")));
|
||||||
@@ -230,7 +232,7 @@ class dbjsonTest extends \PHPUnit_Framework_TestCase
|
|||||||
}
|
}
|
||||||
public function test_find10 ()
|
public function test_find10 ()
|
||||||
{
|
{
|
||||||
$dbjson = new dbjson ("dbjson://".dbfile);
|
$dbjson = new Dbjson ("dbjson://".dbfile);
|
||||||
$res = $dbjson->find ("collection", array ("key1"=>array ("val3", "<="),
|
$res = $dbjson->find ("collection", array ("key1"=>array ("val3", "<="),
|
||||||
"key2"=>array ("val2", "==")),
|
"key2"=>array ("val2", "==")),
|
||||||
array ("key2"));
|
array ("key2"));
|
||||||
@@ -242,7 +244,7 @@ class dbjsonTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_find11 ()
|
public function test_find11 ()
|
||||||
{
|
{
|
||||||
$dbjson = new dbjson ("dbjson://".dbfile);
|
$dbjson = new Dbjson ("dbjson://".dbfile);
|
||||||
$res = array_values ($dbjson->find ("collection"));
|
$res = array_values ($dbjson->find ("collection"));
|
||||||
// ["_id"] is random : skip the test
|
// ["_id"] is random : skip the test
|
||||||
unset ($res[0]["_id"]);
|
unset ($res[0]["_id"]);
|
||||||
@@ -251,13 +253,13 @@ class dbjsonTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_replace1 ()
|
public function test_replace1 ()
|
||||||
{
|
{
|
||||||
$dbjson = new dbjson ("dbjson://".dbfile);
|
$dbjson = new Dbjson ("dbjson://".dbfile);
|
||||||
$res = $dbjson->replace ("collection", array (), array ("key2"=>"val5"));
|
$res = $dbjson->replace ("collection", array (), array ("key2"=>"val5"));
|
||||||
$this->assertSame ($res, 1);
|
$this->assertSame ($res, 1);
|
||||||
}
|
}
|
||||||
public function test_find12 ()
|
public function test_find12 ()
|
||||||
{
|
{
|
||||||
$dbjson = new dbjson ("dbjson://".dbfile);
|
$dbjson = new Dbjson ("dbjson://".dbfile);
|
||||||
$res = array_values ($dbjson->find ("collection"));
|
$res = array_values ($dbjson->find ("collection"));
|
||||||
// ["_id"] is random : skip the test
|
// ["_id"] is random : skip the test
|
||||||
unset ($res[0]["_id"]);
|
unset ($res[0]["_id"]);
|
||||||
@@ -266,14 +268,14 @@ class dbjsonTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_update1 ()
|
public function test_update1 ()
|
||||||
{
|
{
|
||||||
$dbjson = new dbjson ("dbjson://".dbfile);
|
$dbjson = new Dbjson ("dbjson://".dbfile);
|
||||||
$res = $dbjson->update ("collection", array (), array ("key2"=>"val6",
|
$res = $dbjson->update ("collection", array (), array ("key2"=>"val6",
|
||||||
"key5"=>"val5"));
|
"key5"=>"val5"));
|
||||||
$this->assertSame ($res, 1);
|
$this->assertSame ($res, 1);
|
||||||
}
|
}
|
||||||
public function test_find13 ()
|
public function test_find13 ()
|
||||||
{
|
{
|
||||||
$dbjson = new dbjson ("dbjson://".dbfile);
|
$dbjson = new Dbjson ("dbjson://".dbfile);
|
||||||
$res = array_values ($dbjson->find ("collection"));
|
$res = array_values ($dbjson->find ("collection"));
|
||||||
// ["_id"] is random : skip the test
|
// ["_id"] is random : skip the test
|
||||||
unset ($res[0]["_id"]);
|
unset ($res[0]["_id"]);
|
||||||
@@ -283,14 +285,14 @@ class dbjsonTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function test_insertOne3 ()
|
public function test_insertOne3 ()
|
||||||
{
|
{
|
||||||
// Document #4
|
// Document #4
|
||||||
$dbjson = new dbjson ("dbjson://".dbfile);
|
$dbjson = new Dbjson ("dbjson://".dbfile);
|
||||||
$res = $dbjson->insertOne ("collection",
|
$res = $dbjson->insertOne ("collection",
|
||||||
array ("key1"=>"val1", "key2"=>"val2"));
|
array ("key1"=>"val1", "key2"=>"val2"));
|
||||||
$this->assertSame ($res, 1);
|
$this->assertSame ($res, 1);
|
||||||
}
|
}
|
||||||
public function test_find14 ()
|
public function test_find14 ()
|
||||||
{
|
{
|
||||||
$dbjson = new dbjson ("dbjson://".dbfile);
|
$dbjson = new Dbjson ("dbjson://".dbfile);
|
||||||
$res = array_values ($dbjson->find ("collection"));
|
$res = array_values ($dbjson->find ("collection"));
|
||||||
// ["_id"] is random : skip the test
|
// ["_id"] is random : skip the test
|
||||||
unset ($res[0]["_id"]);
|
unset ($res[0]["_id"]);
|
||||||
@@ -303,14 +305,14 @@ class dbjsonTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_update2 ()
|
public function test_update2 ()
|
||||||
{
|
{
|
||||||
$dbjson = new dbjson ("dbjson://".dbfile);
|
$dbjson = new Dbjson ("dbjson://".dbfile);
|
||||||
$res = $dbjson->update ("collection", array (), array ("key2"=>"val7",
|
$res = $dbjson->update ("collection", array (), array ("key2"=>"val7",
|
||||||
"key5"=>"val8"));
|
"key5"=>"val8"));
|
||||||
$this->assertSame ($res, 2);
|
$this->assertSame ($res, 2);
|
||||||
}
|
}
|
||||||
public function test_find15 ()
|
public function test_find15 ()
|
||||||
{
|
{
|
||||||
$dbjson = new dbjson ("dbjson://".dbfile);
|
$dbjson = new Dbjson ("dbjson://".dbfile);
|
||||||
$res = array_values ($dbjson->find ("collection"));
|
$res = array_values ($dbjson->find ("collection"));
|
||||||
// ["_id"] is random : skip the test
|
// ["_id"] is random : skip the test
|
||||||
unset ($res[0]["_id"]);
|
unset ($res[0]["_id"]);
|
||||||
@@ -324,7 +326,7 @@ class dbjsonTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_update3 ()
|
public function test_update3 ()
|
||||||
{
|
{
|
||||||
$dbjson = new dbjson ("dbjson://".dbfile);
|
$dbjson = new Dbjson ("dbjson://".dbfile);
|
||||||
$res = $dbjson->update ("collection", array (),
|
$res = $dbjson->update ("collection", array (),
|
||||||
array ("key2"=>"val9",
|
array ("key2"=>"val9",
|
||||||
"key5"=>"val7",
|
"key5"=>"val7",
|
||||||
@@ -333,7 +335,7 @@ class dbjsonTest extends \PHPUnit_Framework_TestCase
|
|||||||
}
|
}
|
||||||
public function test_find16 ()
|
public function test_find16 ()
|
||||||
{
|
{
|
||||||
$dbjson = new dbjson ("dbjson://".dbfile);
|
$dbjson = new Dbjson ("dbjson://".dbfile);
|
||||||
$res = array_values ($dbjson->find ("collection"));
|
$res = array_values ($dbjson->find ("collection"));
|
||||||
// ["_id"] is random : skip the test
|
// ["_id"] is random : skip the test
|
||||||
unset ($res[0]["_id"]);
|
unset ($res[0]["_id"]);
|
||||||
@@ -346,8 +348,8 @@ class dbjsonTest extends \PHPUnit_Framework_TestCase
|
|||||||
// Concurrency tests
|
// Concurrency tests
|
||||||
public function test_concurrency1 ()
|
public function test_concurrency1 ()
|
||||||
{
|
{
|
||||||
$dbjson1 = new dbjson ("dbjson://".dbfile);
|
$dbjson1 = new Dbjson ("dbjson://".dbfile);
|
||||||
$dbjson2 = new dbjson ("dbjson://".dbfile);
|
$dbjson2 = new Dbjson ("dbjson://".dbfile);
|
||||||
$dbjson1->insertOne ("collection",
|
$dbjson1->insertOne ("collection",
|
||||||
array ("key1"=>"val1", "key2"=>"val2"));
|
array ("key1"=>"val1", "key2"=>"val2"));
|
||||||
$res = array_values ($dbjson2->find ("collection"));
|
$res = array_values ($dbjson2->find ("collection"));
|
||||||
|
|||||||
@@ -7,7 +7,9 @@
|
|||||||
|
|
||||||
namespace Domframework\Tests;
|
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 column name 'group', 'object', 'where', 'with space'
|
||||||
// Test with table 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 ()
|
public function test_dropTable ()
|
||||||
{
|
{
|
||||||
$dbconfig = $this->confs["{ENGINE}"];
|
$dbconfig = $this->confs["{ENGINE}"];
|
||||||
$db = new dblayer ($dbconfig["dsn"], $dbconfig["username"],
|
$db = new Dblayer ($dbconfig["dsn"], $dbconfig["username"],
|
||||||
$dbconfig["password"], $dbconfig["driver_options"]);
|
$dbconfig["password"], $dbconfig["driver_options"]);
|
||||||
foreach (array ("users", "grouped", "multiple", "multiple2", "users3",
|
foreach (array ("users", "grouped", "multiple", "multiple2", "users3",
|
||||||
"readOR") as
|
"readOR") as
|
||||||
@@ -53,7 +55,7 @@ class dblayerTest{ENGINE} extends PHPUnit_Framework_TestCase
|
|||||||
{
|
{
|
||||||
$res = $db->dropTable();
|
$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
|
// Create a table named grouped
|
||||||
$dbconfig = $this->confs["{ENGINE}"];
|
$dbconfig = $this->confs["{ENGINE}"];
|
||||||
$db = new dblayer ($dbconfig["dsn"], $dbconfig["username"],
|
$db = new Dblayer ($dbconfig["dsn"], $dbconfig["username"],
|
||||||
$dbconfig["password"], $dbconfig["driver_options"]);
|
$dbconfig["password"], $dbconfig["driver_options"]);
|
||||||
$db->table = "grouped";
|
$db->table = "grouped";
|
||||||
$db->fields = array ("group"=>array ("varchar", "255", "not null"),
|
$db->fields = array ("group"=>array ("varchar", "255", "not null"),
|
||||||
@@ -85,7 +87,7 @@ class dblayerTest{ENGINE} extends PHPUnit_Framework_TestCase
|
|||||||
public function test_insert1 ()
|
public function test_insert1 ()
|
||||||
{
|
{
|
||||||
$dbconfig = $this->confs["{ENGINE}"];
|
$dbconfig = $this->confs["{ENGINE}"];
|
||||||
$db = new dblayer ($dbconfig["dsn"], $dbconfig["username"],
|
$db = new Dblayer ($dbconfig["dsn"], $dbconfig["username"],
|
||||||
$dbconfig["password"], $dbconfig["driver_options"]);
|
$dbconfig["password"], $dbconfig["driver_options"]);
|
||||||
$db->table = "grouped";
|
$db->table = "grouped";
|
||||||
$db->fields = array ("group"=>array ("varchar", "255", "not null"),
|
$db->fields = array ("group"=>array ("varchar", "255", "not null"),
|
||||||
@@ -105,7 +107,7 @@ class dblayerTest{ENGINE} extends PHPUnit_Framework_TestCase
|
|||||||
public function test_read1 ()
|
public function test_read1 ()
|
||||||
{
|
{
|
||||||
$dbconfig = $this->confs["{ENGINE}"];
|
$dbconfig = $this->confs["{ENGINE}"];
|
||||||
$db = new dblayer ($dbconfig["dsn"], $dbconfig["username"],
|
$db = new Dblayer ($dbconfig["dsn"], $dbconfig["username"],
|
||||||
$dbconfig["password"], $dbconfig["driver_options"]);
|
$dbconfig["password"], $dbconfig["driver_options"]);
|
||||||
$db->table = "grouped";
|
$db->table = "grouped";
|
||||||
$db->fields = array ("group"=>array ("varchar", "255", "not null"),
|
$db->fields = array ("group"=>array ("varchar", "255", "not null"),
|
||||||
@@ -126,7 +128,7 @@ class dblayerTest{ENGINE} extends PHPUnit_Framework_TestCase
|
|||||||
public function test_update1 ()
|
public function test_update1 ()
|
||||||
{
|
{
|
||||||
$dbconfig = $this->confs["{ENGINE}"];
|
$dbconfig = $this->confs["{ENGINE}"];
|
||||||
$db = new dblayer ($dbconfig["dsn"], $dbconfig["username"],
|
$db = new Dblayer ($dbconfig["dsn"], $dbconfig["username"],
|
||||||
$dbconfig["password"], $dbconfig["driver_options"]);
|
$dbconfig["password"], $dbconfig["driver_options"]);
|
||||||
$db->table = "grouped";
|
$db->table = "grouped";
|
||||||
$db->fields = array ("group"=>array ("varchar", "255", "not null"),
|
$db->fields = array ("group"=>array ("varchar", "255", "not null"),
|
||||||
@@ -144,7 +146,7 @@ class dblayerTest{ENGINE} extends PHPUnit_Framework_TestCase
|
|||||||
public function test_read2 ()
|
public function test_read2 ()
|
||||||
{
|
{
|
||||||
$dbconfig = $this->confs["{ENGINE}"];
|
$dbconfig = $this->confs["{ENGINE}"];
|
||||||
$db = new dblayer ($dbconfig["dsn"], $dbconfig["username"],
|
$db = new Dblayer ($dbconfig["dsn"], $dbconfig["username"],
|
||||||
$dbconfig["password"], $dbconfig["driver_options"]);
|
$dbconfig["password"], $dbconfig["driver_options"]);
|
||||||
$db->table = "grouped";
|
$db->table = "grouped";
|
||||||
$db->fields = array ("group"=>array ("varchar", "255", "not null"),
|
$db->fields = array ("group"=>array ("varchar", "255", "not null"),
|
||||||
@@ -165,7 +167,7 @@ class dblayerTest{ENGINE} extends PHPUnit_Framework_TestCase
|
|||||||
public function test_update2 ()
|
public function test_update2 ()
|
||||||
{
|
{
|
||||||
$dbconfig = $this->confs["{ENGINE}"];
|
$dbconfig = $this->confs["{ENGINE}"];
|
||||||
$db = new dblayer ($dbconfig["dsn"], $dbconfig["username"],
|
$db = new Dblayer ($dbconfig["dsn"], $dbconfig["username"],
|
||||||
$dbconfig["password"], $dbconfig["driver_options"]);
|
$dbconfig["password"], $dbconfig["driver_options"]);
|
||||||
$db->table = "grouped";
|
$db->table = "grouped";
|
||||||
$db->fields = array ("group"=>array ("varchar", "255", "not null"),
|
$db->fields = array ("group"=>array ("varchar", "255", "not null"),
|
||||||
@@ -184,7 +186,7 @@ class dblayerTest{ENGINE} extends PHPUnit_Framework_TestCase
|
|||||||
public function test_read3 ()
|
public function test_read3 ()
|
||||||
{
|
{
|
||||||
$dbconfig = $this->confs["{ENGINE}"];
|
$dbconfig = $this->confs["{ENGINE}"];
|
||||||
$db = new dblayer ($dbconfig["dsn"], $dbconfig["username"],
|
$db = new Dblayer ($dbconfig["dsn"], $dbconfig["username"],
|
||||||
$dbconfig["password"], $dbconfig["driver_options"]);
|
$dbconfig["password"], $dbconfig["driver_options"]);
|
||||||
$db->table = "grouped";
|
$db->table = "grouped";
|
||||||
$db->fields = array ("group"=>array ("varchar", "255", "not null"),
|
$db->fields = array ("group"=>array ("varchar", "255", "not null"),
|
||||||
@@ -205,7 +207,7 @@ class dblayerTest{ENGINE} extends PHPUnit_Framework_TestCase
|
|||||||
public function test_update3 ()
|
public function test_update3 ()
|
||||||
{
|
{
|
||||||
$dbconfig = $this->confs["{ENGINE}"];
|
$dbconfig = $this->confs["{ENGINE}"];
|
||||||
$db = new dblayer ($dbconfig["dsn"], $dbconfig["username"],
|
$db = new Dblayer ($dbconfig["dsn"], $dbconfig["username"],
|
||||||
$dbconfig["password"], $dbconfig["driver_options"]);
|
$dbconfig["password"], $dbconfig["driver_options"]);
|
||||||
$db->table = "grouped";
|
$db->table = "grouped";
|
||||||
$db->fields = array ("group"=>array ("varchar", "255", "not null"),
|
$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
|
// Create a table named group
|
||||||
$dbconfig = $this->confs["{ENGINE}"];
|
$dbconfig = $this->confs["{ENGINE}"];
|
||||||
$db = new dblayer ($dbconfig["dsn"], $dbconfig["username"],
|
$db = new Dblayer ($dbconfig["dsn"], $dbconfig["username"],
|
||||||
$dbconfig["password"], $dbconfig["driver_options"]);
|
$dbconfig["password"], $dbconfig["driver_options"]);
|
||||||
$db->disconnect ();
|
$db->disconnect ();
|
||||||
$db = new dblayer ($dbconfig["dsn"], $dbconfig["username"],
|
$db = new Dblayer ($dbconfig["dsn"], $dbconfig["username"],
|
||||||
$dbconfig["password"], $dbconfig["driver_options"]);
|
$dbconfig["password"], $dbconfig["driver_options"]);
|
||||||
$db->table = "users";
|
$db->table = "users";
|
||||||
$db->fields = array ("user"=>array ("varchar", "255", "not null"),
|
$db->fields = array ("user"=>array ("varchar", "255", "not null"),
|
||||||
@@ -254,7 +256,7 @@ class dblayerTest{ENGINE} extends PHPUnit_Framework_TestCase
|
|||||||
public function test_insert2 ()
|
public function test_insert2 ()
|
||||||
{
|
{
|
||||||
$dbconfig = $this->confs["{ENGINE}"];
|
$dbconfig = $this->confs["{ENGINE}"];
|
||||||
$db = new dblayer ($dbconfig["dsn"], $dbconfig["username"],
|
$db = new Dblayer ($dbconfig["dsn"], $dbconfig["username"],
|
||||||
$dbconfig["password"], $dbconfig["driver_options"]);
|
$dbconfig["password"], $dbconfig["driver_options"]);
|
||||||
$db->table = "users";
|
$db->table = "users";
|
||||||
$db->fields = array ("user"=>array ("varchar", "255", "not null"),
|
$db->fields = array ("user"=>array ("varchar", "255", "not null"),
|
||||||
@@ -279,7 +281,7 @@ class dblayerTest{ENGINE} extends PHPUnit_Framework_TestCase
|
|||||||
public function test_insert3 ()
|
public function test_insert3 ()
|
||||||
{
|
{
|
||||||
$dbconfig = $this->confs["{ENGINE}"];
|
$dbconfig = $this->confs["{ENGINE}"];
|
||||||
$db = new dblayer ($dbconfig["dsn"], $dbconfig["username"],
|
$db = new Dblayer ($dbconfig["dsn"], $dbconfig["username"],
|
||||||
$dbconfig["password"], $dbconfig["driver_options"]);
|
$dbconfig["password"], $dbconfig["driver_options"]);
|
||||||
$db->table = "users";
|
$db->table = "users";
|
||||||
$db->fields = array ("user"=>array ("varchar", "255", "not null"),
|
$db->fields = array ("user"=>array ("varchar", "255", "not null"),
|
||||||
@@ -302,7 +304,7 @@ class dblayerTest{ENGINE} extends PHPUnit_Framework_TestCase
|
|||||||
public function test_insert4 ()
|
public function test_insert4 ()
|
||||||
{
|
{
|
||||||
$dbconfig = $this->confs["{ENGINE}"];
|
$dbconfig = $this->confs["{ENGINE}"];
|
||||||
$db = new dblayer ($dbconfig["dsn"], $dbconfig["username"],
|
$db = new Dblayer ($dbconfig["dsn"], $dbconfig["username"],
|
||||||
$dbconfig["password"], $dbconfig["driver_options"]);
|
$dbconfig["password"], $dbconfig["driver_options"]);
|
||||||
$db->table = "users";
|
$db->table = "users";
|
||||||
$db->fields = array ("user"=>array ("varchar", "255", "not null"),
|
$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
|
// Create a table named group
|
||||||
$dbconfig = $this->confs["{ENGINE}"];
|
$dbconfig = $this->confs["{ENGINE}"];
|
||||||
$db = new dblayer ($dbconfig["dsn"], $dbconfig["username"],
|
$db = new Dblayer ($dbconfig["dsn"], $dbconfig["username"],
|
||||||
$dbconfig["password"], $dbconfig["driver_options"]);
|
$dbconfig["password"], $dbconfig["driver_options"]);
|
||||||
$db->table = "multiple";
|
$db->table = "multiple";
|
||||||
$db->fields = array ("user"=>array ("varchar", "255", "not null"),
|
$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"),
|
"where"=>array ("varchar", "255", "not null"),
|
||||||
"with space"=>array ("varchar", "255", "not null"));
|
"with space"=>array ("varchar", "255", "not null"));
|
||||||
$db->createTable ();
|
$db->createTable ();
|
||||||
$db2 = new dblayer ($dbconfig["dsn"], $dbconfig["username"],
|
$db2 = new Dblayer ($dbconfig["dsn"], $dbconfig["username"],
|
||||||
$dbconfig["password"], $dbconfig["driver_options"]);
|
$dbconfig["password"], $dbconfig["driver_options"]);
|
||||||
$db2->table = "multiple2";
|
$db2->table = "multiple2";
|
||||||
$db2->fields = array ("user"=>array ("varchar", "255", "not null"),
|
$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
|
// Create a table named group
|
||||||
$dbconfig = $this->confs["{ENGINE}"];
|
$dbconfig = $this->confs["{ENGINE}"];
|
||||||
$db = new dblayer ($dbconfig["dsn"], $dbconfig["username"],
|
$db = new Dblayer ($dbconfig["dsn"], $dbconfig["username"],
|
||||||
$dbconfig["password"], $dbconfig["driver_options"]);
|
$dbconfig["password"], $dbconfig["driver_options"]);
|
||||||
$db->table = "users3";
|
$db->table = "users3";
|
||||||
$db->fields = array ("user"=>array ("varchar", "255", "not null"),
|
$db->fields = array ("user"=>array ("varchar", "255", "not null"),
|
||||||
@@ -372,7 +374,7 @@ class dblayerTest{ENGINE} extends PHPUnit_Framework_TestCase
|
|||||||
public function test_readOR1 ()
|
public function test_readOR1 ()
|
||||||
{
|
{
|
||||||
$dbconfig = $this->confs["{ENGINE}"];
|
$dbconfig = $this->confs["{ENGINE}"];
|
||||||
$db = new dblayer ($dbconfig["dsn"], $dbconfig["username"],
|
$db = new Dblayer ($dbconfig["dsn"], $dbconfig["username"],
|
||||||
$dbconfig["password"], $dbconfig["driver_options"]);
|
$dbconfig["password"], $dbconfig["driver_options"]);
|
||||||
$db->table = "readOR";
|
$db->table = "readOR";
|
||||||
$db->fields = array ("id"=>array ("integer"),
|
$db->fields = array ("id"=>array ("integer"),
|
||||||
|
|||||||
@@ -7,7 +7,10 @@
|
|||||||
|
|
||||||
namespace Domframework\Tests;
|
namespace Domframework\Tests;
|
||||||
|
|
||||||
class dblayerauthzgroupsTest extends \PHPUnit_Framework_TestCase
|
use Domframework\Dblayerauthzgroups;
|
||||||
|
use Domframework\Authzgroups;
|
||||||
|
|
||||||
|
class DblayerauthzgroupsTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
public $confs = array (
|
public $confs = array (
|
||||||
"sqlite" => array (
|
"sqlite" => array (
|
||||||
@@ -27,7 +30,7 @@ class dblayerauthzgroupsTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function test_createTablesAuthzgroups ()
|
public function test_createTablesAuthzgroups ()
|
||||||
{
|
{
|
||||||
$dbconfig = $this->confs["sqlite"];
|
$dbconfig = $this->confs["sqlite"];
|
||||||
$a = new authzgroups ();
|
$a = new Authzgroups ();
|
||||||
$a->connect ($dbconfig["dsn"], $dbconfig["username"],
|
$a->connect ($dbconfig["dsn"], $dbconfig["username"],
|
||||||
$dbconfig["password"], $dbconfig["driver_options"]);
|
$dbconfig["password"], $dbconfig["driver_options"]);
|
||||||
$a->createTables ();
|
$a->createTables ();
|
||||||
@@ -48,11 +51,11 @@ class dblayerauthzgroupsTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function test_createTable ()
|
public function test_createTable ()
|
||||||
{
|
{
|
||||||
$dbconfig = $this->confs["sqlite"];
|
$dbconfig = $this->confs["sqlite"];
|
||||||
$n = new dblayerauthzgroups ($dbconfig["dsn"], $dbconfig["username"],
|
$n = new Dblayerauthzgroups ($dbconfig["dsn"], $dbconfig["username"],
|
||||||
$dbconfig["password"],
|
$dbconfig["password"],
|
||||||
$dbconfig["driver_options"]);
|
$dbconfig["driver_options"]);
|
||||||
$n->disconnect ();
|
$n->disconnect ();
|
||||||
$n = new dblayerauthzgroups ($dbconfig["dsn"], $dbconfig["username"],
|
$n = new Dblayerauthzgroups ($dbconfig["dsn"], $dbconfig["username"],
|
||||||
$dbconfig["password"],
|
$dbconfig["password"],
|
||||||
$dbconfig["driver_options"]);
|
$dbconfig["driver_options"]);
|
||||||
$n->tableSet ("dns zones")
|
$n->tableSet ("dns zones")
|
||||||
@@ -73,10 +76,10 @@ class dblayerauthzgroupsTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function test_insert1 ()
|
public function test_insert1 ()
|
||||||
{
|
{
|
||||||
$dbconfig = $this->confs["sqlite"];
|
$dbconfig = $this->confs["sqlite"];
|
||||||
$a = new authzgroups ();
|
$a = new Authzgroups ();
|
||||||
$a->connect ($dbconfig["dsn"], $dbconfig["username"],
|
$a->connect ($dbconfig["dsn"], $dbconfig["username"],
|
||||||
$dbconfig["password"], $dbconfig["driver_options"]);
|
$dbconfig["password"], $dbconfig["driver_options"]);
|
||||||
$n = new dblayerauthzgroups ($dbconfig["dsn"], $dbconfig["username"],
|
$n = new Dblayerauthzgroups ($dbconfig["dsn"], $dbconfig["username"],
|
||||||
$dbconfig["password"],
|
$dbconfig["password"],
|
||||||
$dbconfig["driver_options"]);
|
$dbconfig["driver_options"]);
|
||||||
$n->tableSet ("dns zones")
|
$n->tableSet ("dns zones")
|
||||||
@@ -105,7 +108,7 @@ class dblayerauthzgroupsTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function test_addAuthzgroups ()
|
public function test_addAuthzgroups ()
|
||||||
{
|
{
|
||||||
$dbconfig = $this->confs["sqlite"];
|
$dbconfig = $this->confs["sqlite"];
|
||||||
$a = new authzgroups ();
|
$a = new Authzgroups ();
|
||||||
$a->connect ($dbconfig["dsn"], $dbconfig["username"],
|
$a->connect ($dbconfig["dsn"], $dbconfig["username"],
|
||||||
$dbconfig["password"], $dbconfig["driver_options"]);
|
$dbconfig["password"], $dbconfig["driver_options"]);
|
||||||
$res = $a->allow ("modTest", "user", "/article/base/poub/1");
|
$res = $a->allow ("modTest", "user", "/article/base/poub/1");
|
||||||
@@ -115,10 +118,10 @@ class dblayerauthzgroupsTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function test_insert2 ()
|
public function test_insert2 ()
|
||||||
{
|
{
|
||||||
$dbconfig = $this->confs["sqlite"];
|
$dbconfig = $this->confs["sqlite"];
|
||||||
$a = new authzgroups ();
|
$a = new Authzgroups ();
|
||||||
$a->connect ($dbconfig["dsn"], $dbconfig["username"],
|
$a->connect ($dbconfig["dsn"], $dbconfig["username"],
|
||||||
$dbconfig["password"], $dbconfig["driver_options"]);
|
$dbconfig["password"], $dbconfig["driver_options"]);
|
||||||
$n = new dblayerauthzgroups ($dbconfig["dsn"], $dbconfig["username"],
|
$n = new Dblayerauthzgroups ($dbconfig["dsn"], $dbconfig["username"],
|
||||||
$dbconfig["password"],
|
$dbconfig["password"],
|
||||||
$dbconfig["driver_options"]);
|
$dbconfig["driver_options"]);
|
||||||
$n->tableSet ("dns zones")
|
$n->tableSet ("dns zones")
|
||||||
@@ -150,10 +153,10 @@ class dblayerauthzgroupsTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function test_read1 ()
|
public function test_read1 ()
|
||||||
{
|
{
|
||||||
$dbconfig = $this->confs["sqlite"];
|
$dbconfig = $this->confs["sqlite"];
|
||||||
$a = new authzgroups ();
|
$a = new Authzgroups ();
|
||||||
$a->connect ($dbconfig["dsn"], $dbconfig["username"],
|
$a->connect ($dbconfig["dsn"], $dbconfig["username"],
|
||||||
$dbconfig["password"], $dbconfig["driver_options"]);
|
$dbconfig["password"], $dbconfig["driver_options"]);
|
||||||
$n = new dblayerauthzgroups ($dbconfig["dsn"], $dbconfig["username"],
|
$n = new Dblayerauthzgroups ($dbconfig["dsn"], $dbconfig["username"],
|
||||||
$dbconfig["password"],
|
$dbconfig["password"],
|
||||||
$dbconfig["driver_options"]);
|
$dbconfig["driver_options"]);
|
||||||
$n->tableSet ("dns zones")
|
$n->tableSet ("dns zones")
|
||||||
@@ -181,7 +184,7 @@ class dblayerauthzgroupsTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function test_rightDel ()
|
public function test_rightDel ()
|
||||||
{
|
{
|
||||||
$dbconfig = $this->confs["sqlite"];
|
$dbconfig = $this->confs["sqlite"];
|
||||||
$a = new authzgroups ();
|
$a = new Authzgroups ();
|
||||||
$a->connect ($dbconfig["dsn"], $dbconfig["username"],
|
$a->connect ($dbconfig["dsn"], $dbconfig["username"],
|
||||||
$dbconfig["password"], $dbconfig["driver_options"]);
|
$dbconfig["password"], $dbconfig["driver_options"]);
|
||||||
$a->rightDel ("modTest", "group", "/article/base/poub/2");
|
$a->rightDel ("modTest", "group", "/article/base/poub/2");
|
||||||
@@ -194,10 +197,10 @@ class dblayerauthzgroupsTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function test_read2 ()
|
public function test_read2 ()
|
||||||
{
|
{
|
||||||
$dbconfig = $this->confs["sqlite"];
|
$dbconfig = $this->confs["sqlite"];
|
||||||
$a = new authzgroups ();
|
$a = new Authzgroups ();
|
||||||
$a->connect ($dbconfig["dsn"], $dbconfig["username"],
|
$a->connect ($dbconfig["dsn"], $dbconfig["username"],
|
||||||
$dbconfig["password"], $dbconfig["driver_options"]);
|
$dbconfig["password"], $dbconfig["driver_options"]);
|
||||||
$n = new dblayerauthzgroups ($dbconfig["dsn"], $dbconfig["username"],
|
$n = new Dblayerauthzgroups ($dbconfig["dsn"], $dbconfig["username"],
|
||||||
$dbconfig["password"],
|
$dbconfig["password"],
|
||||||
$dbconfig["driver_options"]);
|
$dbconfig["driver_options"]);
|
||||||
$n->tableSet ("dns zones")
|
$n->tableSet ("dns zones")
|
||||||
@@ -225,10 +228,10 @@ class dblayerauthzgroupsTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function test_delEntry1 ()
|
public function test_delEntry1 ()
|
||||||
{
|
{
|
||||||
$dbconfig = $this->confs["sqlite"];
|
$dbconfig = $this->confs["sqlite"];
|
||||||
$a = new authzgroups ();
|
$a = new Authzgroups ();
|
||||||
$a->connect ($dbconfig["dsn"], $dbconfig["username"],
|
$a->connect ($dbconfig["dsn"], $dbconfig["username"],
|
||||||
$dbconfig["password"], $dbconfig["driver_options"]);
|
$dbconfig["password"], $dbconfig["driver_options"]);
|
||||||
$n = new dblayerauthzgroups ($dbconfig["dsn"], $dbconfig["username"],
|
$n = new Dblayerauthzgroups ($dbconfig["dsn"], $dbconfig["username"],
|
||||||
$dbconfig["password"],
|
$dbconfig["password"],
|
||||||
$dbconfig["driver_options"]);
|
$dbconfig["driver_options"]);
|
||||||
$n->tableSet ("dns zones")
|
$n->tableSet ("dns zones")
|
||||||
@@ -255,7 +258,7 @@ class dblayerauthzgroupsTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function test_rightRO ()
|
public function test_rightRO ()
|
||||||
{
|
{
|
||||||
$dbconfig = $this->confs["sqlite"];
|
$dbconfig = $this->confs["sqlite"];
|
||||||
$a = new authzgroups ();
|
$a = new Authzgroups ();
|
||||||
$a->connect ($dbconfig["dsn"], $dbconfig["username"],
|
$a->connect ($dbconfig["dsn"], $dbconfig["username"],
|
||||||
$dbconfig["password"], $dbconfig["driver_options"]);
|
$dbconfig["password"], $dbconfig["driver_options"]);
|
||||||
$res = $a->rightUpdate ("modTest", "group", "/article/base/poub/1", "RO");
|
$res = $a->rightUpdate ("modTest", "group", "/article/base/poub/1", "RO");
|
||||||
@@ -267,10 +270,10 @@ class dblayerauthzgroupsTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function test_updateEntry2 ()
|
public function test_updateEntry2 ()
|
||||||
{
|
{
|
||||||
$dbconfig = $this->confs["sqlite"];
|
$dbconfig = $this->confs["sqlite"];
|
||||||
$a = new authzgroups ();
|
$a = new Authzgroups ();
|
||||||
$a->connect ($dbconfig["dsn"], $dbconfig["username"],
|
$a->connect ($dbconfig["dsn"], $dbconfig["username"],
|
||||||
$dbconfig["password"], $dbconfig["driver_options"]);
|
$dbconfig["password"], $dbconfig["driver_options"]);
|
||||||
$n = new dblayerauthzgroups ($dbconfig["dsn"], $dbconfig["username"],
|
$n = new Dblayerauthzgroups ($dbconfig["dsn"], $dbconfig["username"],
|
||||||
$dbconfig["password"],
|
$dbconfig["password"],
|
||||||
$dbconfig["driver_options"]);
|
$dbconfig["driver_options"]);
|
||||||
$n->tableSet ("dns zones")
|
$n->tableSet ("dns zones")
|
||||||
@@ -297,10 +300,10 @@ class dblayerauthzgroupsTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function test_delEntry2 ()
|
public function test_delEntry2 ()
|
||||||
{
|
{
|
||||||
$dbconfig = $this->confs["sqlite"];
|
$dbconfig = $this->confs["sqlite"];
|
||||||
$a = new authzgroups ();
|
$a = new Authzgroups ();
|
||||||
$a->connect ($dbconfig["dsn"], $dbconfig["username"],
|
$a->connect ($dbconfig["dsn"], $dbconfig["username"],
|
||||||
$dbconfig["password"], $dbconfig["driver_options"]);
|
$dbconfig["password"], $dbconfig["driver_options"]);
|
||||||
$n = new dblayerauthzgroups ($dbconfig["dsn"], $dbconfig["username"],
|
$n = new Dblayerauthzgroups ($dbconfig["dsn"], $dbconfig["username"],
|
||||||
$dbconfig["password"],
|
$dbconfig["password"],
|
||||||
$dbconfig["driver_options"]);
|
$dbconfig["driver_options"]);
|
||||||
$n->tableSet ("dns zones")
|
$n->tableSet ("dns zones")
|
||||||
@@ -327,7 +330,7 @@ class dblayerauthzgroupsTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function test_rightRW ()
|
public function test_rightRW ()
|
||||||
{
|
{
|
||||||
$dbconfig = $this->confs["sqlite"];
|
$dbconfig = $this->confs["sqlite"];
|
||||||
$a = new authzgroups ();
|
$a = new Authzgroups ();
|
||||||
$a->connect ($dbconfig["dsn"], $dbconfig["username"],
|
$a->connect ($dbconfig["dsn"], $dbconfig["username"],
|
||||||
$dbconfig["password"], $dbconfig["driver_options"]);
|
$dbconfig["password"], $dbconfig["driver_options"]);
|
||||||
$res = $a->rightUpdate ("modTest", "group", "/article/base/poub/1", "RW");
|
$res = $a->rightUpdate ("modTest", "group", "/article/base/poub/1", "RW");
|
||||||
@@ -339,10 +342,10 @@ class dblayerauthzgroupsTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function test_updateEntry3 ()
|
public function test_updateEntry3 ()
|
||||||
{
|
{
|
||||||
$dbconfig = $this->confs["sqlite"];
|
$dbconfig = $this->confs["sqlite"];
|
||||||
$a = new authzgroups ();
|
$a = new Authzgroups ();
|
||||||
$a->connect ($dbconfig["dsn"], $dbconfig["username"],
|
$a->connect ($dbconfig["dsn"], $dbconfig["username"],
|
||||||
$dbconfig["password"], $dbconfig["driver_options"]);
|
$dbconfig["password"], $dbconfig["driver_options"]);
|
||||||
$n = new dblayerauthzgroups ($dbconfig["dsn"], $dbconfig["username"],
|
$n = new Dblayerauthzgroups ($dbconfig["dsn"], $dbconfig["username"],
|
||||||
$dbconfig["password"],
|
$dbconfig["password"],
|
||||||
$dbconfig["driver_options"]);
|
$dbconfig["driver_options"]);
|
||||||
$n->tableSet ("dns zones")
|
$n->tableSet ("dns zones")
|
||||||
@@ -369,10 +372,10 @@ class dblayerauthzgroupsTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function test_delEntry3 ()
|
public function test_delEntry3 ()
|
||||||
{
|
{
|
||||||
$dbconfig = $this->confs["sqlite"];
|
$dbconfig = $this->confs["sqlite"];
|
||||||
$a = new authzgroups ();
|
$a = new Authzgroups ();
|
||||||
$a->connect ($dbconfig["dsn"], $dbconfig["username"],
|
$a->connect ($dbconfig["dsn"], $dbconfig["username"],
|
||||||
$dbconfig["password"], $dbconfig["driver_options"]);
|
$dbconfig["password"], $dbconfig["driver_options"]);
|
||||||
$n = new dblayerauthzgroups ($dbconfig["dsn"], $dbconfig["username"],
|
$n = new Dblayerauthzgroups ($dbconfig["dsn"], $dbconfig["username"],
|
||||||
$dbconfig["password"],
|
$dbconfig["password"],
|
||||||
$dbconfig["driver_options"]);
|
$dbconfig["driver_options"]);
|
||||||
$n->tableSet ("dns zones")
|
$n->tableSet ("dns zones")
|
||||||
@@ -399,7 +402,7 @@ class dblayerauthzgroupsTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function test_delAuthzgroups ()
|
public function test_delAuthzgroups ()
|
||||||
{
|
{
|
||||||
$dbconfig = $this->confs["sqlite"];
|
$dbconfig = $this->confs["sqlite"];
|
||||||
$a = new authzgroups ();
|
$a = new Authzgroups ();
|
||||||
$a->connect ($dbconfig["dsn"], $dbconfig["username"],
|
$a->connect ($dbconfig["dsn"], $dbconfig["username"],
|
||||||
$dbconfig["password"], $dbconfig["driver_options"]);
|
$dbconfig["password"], $dbconfig["driver_options"]);
|
||||||
$res = $a->objectRead ("modTest", "/article/base/poub/1");
|
$res = $a->objectRead ("modTest", "/article/base/poub/1");
|
||||||
@@ -411,10 +414,10 @@ class dblayerauthzgroupsTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function test_read3 ()
|
public function test_read3 ()
|
||||||
{
|
{
|
||||||
$dbconfig = $this->confs["sqlite"];
|
$dbconfig = $this->confs["sqlite"];
|
||||||
$a = new authzgroups ();
|
$a = new Authzgroups ();
|
||||||
$a->connect ($dbconfig["dsn"], $dbconfig["username"],
|
$a->connect ($dbconfig["dsn"], $dbconfig["username"],
|
||||||
$dbconfig["password"], $dbconfig["driver_options"]);
|
$dbconfig["password"], $dbconfig["driver_options"]);
|
||||||
$n = new dblayerauthzgroups ($dbconfig["dsn"], $dbconfig["username"],
|
$n = new Dblayerauthzgroups ($dbconfig["dsn"], $dbconfig["username"],
|
||||||
$dbconfig["password"],
|
$dbconfig["password"],
|
||||||
$dbconfig["driver_options"]);
|
$dbconfig["driver_options"]);
|
||||||
$n->tableSet ("dns zones")
|
$n->tableSet ("dns zones")
|
||||||
|
|||||||
@@ -7,7 +7,9 @@
|
|||||||
|
|
||||||
namespace Domframework\Tests;
|
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 column name 'group', 'object', 'where', 'with space'
|
||||||
// Test with table 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 ()
|
private function tbl1 ()
|
||||||
{
|
{
|
||||||
$dbconfig = $this->confs["{ENGINE}"];
|
$dbconfig = $this->confs["{ENGINE}"];
|
||||||
$tbl1 = new dblayeroo ($dbconfig["dsn"], $dbconfig["username"],
|
$tbl1 = new Dblayeroo ($dbconfig["dsn"], $dbconfig["username"],
|
||||||
$dbconfig["password"], $dbconfig["driver_options"]);
|
$dbconfig["password"], $dbconfig["driver_options"]);
|
||||||
$tbl1->table ("groupedoo");
|
$tbl1->table ("groupedoo");
|
||||||
$tbl1->fields (array ("group"=>array ("varchar(255)", "not null"),
|
$tbl1->fields (array ("group"=>array ("varchar(255)", "not null"),
|
||||||
@@ -57,7 +59,7 @@ class dblayerooTest{ENGINE} extends PHPUnit_Framework_TestCase
|
|||||||
private function tbl2 ()
|
private function tbl2 ()
|
||||||
{
|
{
|
||||||
$dbconfig = $this->confs["{ENGINE}"];
|
$dbconfig = $this->confs["{ENGINE}"];
|
||||||
$tbl2 = new dblayeroo ($dbconfig["dsn"], $dbconfig["username"],
|
$tbl2 = new Dblayeroo ($dbconfig["dsn"], $dbconfig["username"],
|
||||||
$dbconfig["password"], $dbconfig["driver_options"]);
|
$dbconfig["password"], $dbconfig["driver_options"]);
|
||||||
$tbl2->table ("usersoo");
|
$tbl2->table ("usersoo");
|
||||||
$tbl2->fields (array ("uid"=>array ("integer", "not null", "autoincrement"),
|
$tbl2->fields (array ("uid"=>array ("integer", "not null", "autoincrement"),
|
||||||
@@ -75,7 +77,7 @@ class dblayerooTest{ENGINE} extends PHPUnit_Framework_TestCase
|
|||||||
private function tbl3 ()
|
private function tbl3 ()
|
||||||
{
|
{
|
||||||
$dbconfig = $this->confs["{ENGINE}"];
|
$dbconfig = $this->confs["{ENGINE}"];
|
||||||
$tbl3 = new dblayeroo ($dbconfig["dsn"], $dbconfig["username"],
|
$tbl3 = new Dblayeroo ($dbconfig["dsn"], $dbconfig["username"],
|
||||||
$dbconfig["password"], $dbconfig["driver_options"]);
|
$dbconfig["password"], $dbconfig["driver_options"]);
|
||||||
return $tbl3;
|
return $tbl3;
|
||||||
}
|
}
|
||||||
@@ -83,7 +85,7 @@ class dblayerooTest{ENGINE} extends PHPUnit_Framework_TestCase
|
|||||||
private function tbl4 ()
|
private function tbl4 ()
|
||||||
{
|
{
|
||||||
$dbconfig = $this->confs["{ENGINE}"];
|
$dbconfig = $this->confs["{ENGINE}"];
|
||||||
$tbl4 = new dblayeroo ($dbconfig["dsn"], $dbconfig["username"],
|
$tbl4 = new Dblayeroo ($dbconfig["dsn"], $dbconfig["username"],
|
||||||
$dbconfig["password"], $dbconfig["driver_options"]);
|
$dbconfig["password"], $dbconfig["driver_options"]);
|
||||||
$tbl4->table ("rightsoo");
|
$tbl4->table ("rightsoo");
|
||||||
$tbl4->fields (array ("id"=>array ("integer", "not null", "autoincrement"),
|
$tbl4->fields (array ("id"=>array ("integer", "not null", "autoincrement"),
|
||||||
@@ -100,7 +102,7 @@ class dblayerooTest{ENGINE} extends PHPUnit_Framework_TestCase
|
|||||||
public function test_dropTable ()
|
public function test_dropTable ()
|
||||||
{
|
{
|
||||||
$dbconfig = $this->confs["{ENGINE}"];
|
$dbconfig = $this->confs["{ENGINE}"];
|
||||||
$db = new dblayeroo ($dbconfig["dsn"], $dbconfig["username"],
|
$db = new Dblayeroo ($dbconfig["dsn"], $dbconfig["username"],
|
||||||
$dbconfig["password"], $dbconfig["driver_options"]);
|
$dbconfig["password"], $dbconfig["driver_options"]);
|
||||||
foreach (array ("rightsoo", "usersoo", "groupedoo",
|
foreach (array ("rightsoo", "usersoo", "groupedoo",
|
||||||
"multipleoo", "multiple2oo", "users3oo",
|
"multipleoo", "multiple2oo", "users3oo",
|
||||||
@@ -112,7 +114,7 @@ class dblayerooTest{ENGINE} extends PHPUnit_Framework_TestCase
|
|||||||
{
|
{
|
||||||
$res = $db->dropTable();
|
$res = $db->dropTable();
|
||||||
}
|
}
|
||||||
catch (Exception $e)
|
catch (\Exception $e)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,14 +4,18 @@
|
|||||||
* @author Dominique Fournier <dominique@fournier38.fr>
|
* @author Dominique Fournier <dominique@fournier38.fr>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** Test the encrypt.php file */
|
namespace Domframework\Tests;
|
||||||
class encryptTest extends \PHPUnit_Framework_TestCase
|
|
||||||
|
use Domframework\Encrypt;
|
||||||
|
|
||||||
|
/** Test the Encrypt.php file */
|
||||||
|
class EncryptTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
/** Check the length of the otken with cipher
|
/** Check the length of the otken with cipher
|
||||||
*/
|
*/
|
||||||
public function testEncrypt1 ()
|
public function testEncrypt1 ()
|
||||||
{
|
{
|
||||||
$encrypt = new encrypt ();
|
$encrypt = new Encrypt ();
|
||||||
$res = $encrypt->encrypt ("TextToEncode",
|
$res = $encrypt->encrypt ("TextToEncode",
|
||||||
"123456789012345678901234");
|
"123456789012345678901234");
|
||||||
$this->assertSame (strlen ($res), 24);
|
$this->assertSame (strlen ($res), 24);
|
||||||
@@ -21,7 +25,7 @@ class encryptTest extends \PHPUnit_Framework_TestCase
|
|||||||
*/
|
*/
|
||||||
public function testEncrypt2 ()
|
public function testEncrypt2 ()
|
||||||
{
|
{
|
||||||
$encrypt = new encrypt ();
|
$encrypt = new Encrypt ();
|
||||||
$payload = "TextToEncode";
|
$payload = "TextToEncode";
|
||||||
$ckey = "123456789012345678901234";
|
$ckey = "123456789012345678901234";
|
||||||
$token = $encrypt->encrypt ($payload, $ckey);
|
$token = $encrypt->encrypt ($payload, $ckey);
|
||||||
@@ -33,7 +37,7 @@ class encryptTest extends \PHPUnit_Framework_TestCase
|
|||||||
*/
|
*/
|
||||||
public function testEncrypt3 ()
|
public function testEncrypt3 ()
|
||||||
{
|
{
|
||||||
$encrypt = new encrypt ();
|
$encrypt = new Encrypt ();
|
||||||
$payload = "TextToEncode";
|
$payload = "TextToEncode";
|
||||||
$token = $encrypt->encrypt ($payload, "123456789012345678901234");
|
$token = $encrypt->encrypt ($payload, "123456789012345678901234");
|
||||||
$res = strpos ($token, "Text");
|
$res = strpos ($token, "Text");
|
||||||
@@ -47,7 +51,7 @@ class encryptTest extends \PHPUnit_Framework_TestCase
|
|||||||
$this->expectException ("Exception",
|
$this->expectException ("Exception",
|
||||||
"Invalid cipher provided to encrypt method : doesn't exists in OpenSSL",
|
"Invalid cipher provided to encrypt method : doesn't exists in OpenSSL",
|
||||||
500);
|
500);
|
||||||
$encrypt = new encrypt ();
|
$encrypt = new Encrypt ();
|
||||||
$payload = "TextToEncode";
|
$payload = "TextToEncode";
|
||||||
$token = $encrypt->encrypt ($payload, "123456789012345678901234", "TOTO");
|
$token = $encrypt->encrypt ($payload, "123456789012345678901234", "TOTO");
|
||||||
}
|
}
|
||||||
@@ -59,7 +63,7 @@ class encryptTest extends \PHPUnit_Framework_TestCase
|
|||||||
$this->expectException ("Exception",
|
$this->expectException ("Exception",
|
||||||
"Invalid payload provided to encrypt method : Not a string",
|
"Invalid payload provided to encrypt method : Not a string",
|
||||||
500);
|
500);
|
||||||
$encrypt = new encrypt ();
|
$encrypt = new Encrypt ();
|
||||||
$payload = array ("Invalid");
|
$payload = array ("Invalid");
|
||||||
$token = $encrypt->encrypt ($payload, "123456789012345678901234");
|
$token = $encrypt->encrypt ($payload, "123456789012345678901234");
|
||||||
}
|
}
|
||||||
@@ -71,7 +75,7 @@ class encryptTest extends \PHPUnit_Framework_TestCase
|
|||||||
$this->expectException ("Exception",
|
$this->expectException ("Exception",
|
||||||
"Invalid cipherKey provided to encrypt method : ".
|
"Invalid cipherKey provided to encrypt method : ".
|
||||||
"length different of 24 chars", 500);
|
"length different of 24 chars", 500);
|
||||||
$encrypt = new encrypt ();
|
$encrypt = new Encrypt ();
|
||||||
$payload = "Payload";
|
$payload = "Payload";
|
||||||
$token = $encrypt->encrypt ($payload, "124");
|
$token = $encrypt->encrypt ($payload, "124");
|
||||||
}
|
}
|
||||||
@@ -83,7 +87,7 @@ class encryptTest extends \PHPUnit_Framework_TestCase
|
|||||||
$this->expectException ("Exception",
|
$this->expectException ("Exception",
|
||||||
"Invalid cipherKey provided to decrypt method : ".
|
"Invalid cipherKey provided to decrypt method : ".
|
||||||
"length different of 24 chars", 500);
|
"length different of 24 chars", 500);
|
||||||
$encrypt = new encrypt ();
|
$encrypt = new Encrypt ();
|
||||||
$token = $encrypt->decrypt ("zfz", "124");
|
$token = $encrypt->decrypt ("zfz", "124");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -93,7 +97,7 @@ class encryptTest extends \PHPUnit_Framework_TestCase
|
|||||||
{
|
{
|
||||||
$this->expectException ("Exception",
|
$this->expectException ("Exception",
|
||||||
"Invalid ciphertext provided to decrypt method : empty string", 500);
|
"Invalid ciphertext provided to decrypt method : empty string", 500);
|
||||||
$encrypt = new encrypt ();
|
$encrypt = new Encrypt ();
|
||||||
$token = $encrypt->decrypt ("", "124");
|
$token = $encrypt->decrypt ("", "124");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -103,7 +107,7 @@ class encryptTest extends \PHPUnit_Framework_TestCase
|
|||||||
{
|
{
|
||||||
$this->expectException ("Exception",
|
$this->expectException ("Exception",
|
||||||
"Invalid ciphertext provided to decrypt method : not a string", 500);
|
"Invalid ciphertext provided to decrypt method : not a string", 500);
|
||||||
$encrypt = new encrypt ();
|
$encrypt = new Encrypt ();
|
||||||
$token = $encrypt->decrypt (array (), "124");
|
$token = $encrypt->decrypt (array (), "124");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -113,7 +117,7 @@ class encryptTest extends \PHPUnit_Framework_TestCase
|
|||||||
{
|
{
|
||||||
$this->expectException ("Exception",
|
$this->expectException ("Exception",
|
||||||
"Invalid cipherkey provided to decrypt method : not a string", 500);
|
"Invalid cipherkey provided to decrypt method : not a string", 500);
|
||||||
$encrypt = new encrypt ();
|
$encrypt = new Encrypt ();
|
||||||
$token = $encrypt->decrypt ("1224", array ());
|
$token = $encrypt->decrypt ("1224", array ());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -123,7 +127,7 @@ class encryptTest extends \PHPUnit_Framework_TestCase
|
|||||||
{
|
{
|
||||||
$this->expectException ("Exception",
|
$this->expectException ("Exception",
|
||||||
"Invalid cipherMethod provided to decrypt method : not a string", 500);
|
"Invalid cipherMethod provided to decrypt method : not a string", 500);
|
||||||
$encrypt = new encrypt ();
|
$encrypt = new Encrypt ();
|
||||||
$token = $encrypt->decrypt ("1224", "1234", array ());
|
$token = $encrypt->decrypt ("1224", "1234", array ());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -134,7 +138,7 @@ class encryptTest extends \PHPUnit_Framework_TestCase
|
|||||||
$this->expectException ("Exception",
|
$this->expectException ("Exception",
|
||||||
"Invalid cipherMethod provided to decrypt method : ".
|
"Invalid cipherMethod provided to decrypt method : ".
|
||||||
"doesn't exists in OpenSSL", 500);
|
"doesn't exists in OpenSSL", 500);
|
||||||
$encrypt = new encrypt ();
|
$encrypt = new Encrypt ();
|
||||||
$token = $encrypt->decrypt ("1224", "1234", "unknown");
|
$token = $encrypt->decrypt ("1224", "1234", "unknown");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,16 @@
|
|||||||
<?php
|
<?php
|
||||||
/** DomFramework
|
/** DomFramework - Tests
|
||||||
@package domframework
|
* @package domframework
|
||||||
@author Dominique Fournier <dominique@fournier38.fr> */
|
* @author Dominique Fournier <dominique@fournier38.fr>
|
||||||
|
* @license BSD
|
||||||
|
*/
|
||||||
|
|
||||||
/** Test the domframework file part */
|
namespace Domframework\Tests;
|
||||||
class fileTest extends \PHPUnit_Framework_TestCase
|
|
||||||
|
use Domframework\File;
|
||||||
|
|
||||||
|
/** Test the domframework File part */
|
||||||
|
class FileTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
public function testinit ()
|
public function testinit ()
|
||||||
{
|
{
|
||||||
@@ -13,56 +19,56 @@ class fileTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function testRealPath01 ()
|
public function testRealPath01 ()
|
||||||
{
|
{
|
||||||
$file = new file ();
|
$file = new File ();
|
||||||
$res = $file->realpath ("/tmp");
|
$res = $file->realpath ("/tmp");
|
||||||
$this->assertSame($res, "/tmp");
|
$this->assertSame($res, "/tmp");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testRealPath02 ()
|
public function testRealPath02 ()
|
||||||
{
|
{
|
||||||
$file = new file ();
|
$file = new File ();
|
||||||
$res = $file->realpath ("////tmp");
|
$res = $file->realpath ("////tmp");
|
||||||
$this->assertSame($res, "/tmp");
|
$this->assertSame($res, "/tmp");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testRealPath03 ()
|
public function testRealPath03 ()
|
||||||
{
|
{
|
||||||
$file = new file ();
|
$file = new File ();
|
||||||
$res = $file->realpath ("////tmp////");
|
$res = $file->realpath ("////tmp////");
|
||||||
$this->assertSame($res, "/tmp");
|
$this->assertSame($res, "/tmp");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testRealPath04 ()
|
public function testRealPath04 ()
|
||||||
{
|
{
|
||||||
$file = new file ();
|
$file = new File ();
|
||||||
$res = $file->realpath (".////tmp////");
|
$res = $file->realpath (".////tmp////");
|
||||||
$this->assertSame($res, "./tmp");
|
$this->assertSame($res, "./tmp");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testRealPath05 ()
|
public function testRealPath05 ()
|
||||||
{
|
{
|
||||||
$file = new file ();
|
$file = new File ();
|
||||||
$res = $file->realpath ("../../../../../tmp/file");
|
$res = $file->realpath ("../../../../../tmp/file");
|
||||||
$this->assertSame($res, "/tmp/file");
|
$this->assertSame($res, "/tmp/file");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testRealPath06 ()
|
public function testRealPath06 ()
|
||||||
{
|
{
|
||||||
$file = new file ();
|
$file = new File ();
|
||||||
$res = $file->realpath ("../../../../../tmp/file/../../../..");
|
$res = $file->realpath ("../../../../../tmp/file/../../../..");
|
||||||
$this->assertSame($res, "/");
|
$this->assertSame($res, "/");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testRealPath07 ()
|
public function testRealPath07 ()
|
||||||
{
|
{
|
||||||
$file = new file ();
|
$file = new File ();
|
||||||
$res = $file->realpath (".././././../tmp/file/../././..");
|
$res = $file->realpath (".././././../tmp/file/../././..");
|
||||||
$this->assertSame($res, "/");
|
$this->assertSame($res, "/");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testRealPath11 ()
|
public function testRealPath11 ()
|
||||||
{
|
{
|
||||||
$file = new file ();
|
$file = new File ();
|
||||||
$file->chroot ("/tmp");
|
$file->chroot ("/tmp");
|
||||||
$res = $file->realpath ("/tmp2");
|
$res = $file->realpath ("/tmp2");
|
||||||
$this->assertSame($res, "/tmp/tmp2");
|
$this->assertSame($res, "/tmp/tmp2");
|
||||||
@@ -70,7 +76,7 @@ class fileTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function testRealPath12 ()
|
public function testRealPath12 ()
|
||||||
{
|
{
|
||||||
$file = new file ();
|
$file = new File ();
|
||||||
$file->chroot ("/tmp");
|
$file->chroot ("/tmp");
|
||||||
$res = $file->realpath ("////tmp2");
|
$res = $file->realpath ("////tmp2");
|
||||||
$this->assertSame($res, "/tmp/tmp2");
|
$this->assertSame($res, "/tmp/tmp2");
|
||||||
@@ -78,7 +84,7 @@ class fileTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function testRealPath13 ()
|
public function testRealPath13 ()
|
||||||
{
|
{
|
||||||
$file = new file ();
|
$file = new File ();
|
||||||
$file->chroot ("/tmp");
|
$file->chroot ("/tmp");
|
||||||
$res = $file->realpath ("////tmp2////");
|
$res = $file->realpath ("////tmp2////");
|
||||||
$this->assertSame($res, "/tmp/tmp2");
|
$this->assertSame($res, "/tmp/tmp2");
|
||||||
@@ -86,7 +92,7 @@ class fileTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function testRealPath14 ()
|
public function testRealPath14 ()
|
||||||
{
|
{
|
||||||
$file = new file ();
|
$file = new File ();
|
||||||
$file->chroot ("/tmp");
|
$file->chroot ("/tmp");
|
||||||
$res = $file->realpath (".////tmp2////");
|
$res = $file->realpath (".////tmp2////");
|
||||||
$this->assertSame($res, "/tmp/tmp2");
|
$this->assertSame($res, "/tmp/tmp2");
|
||||||
@@ -94,7 +100,7 @@ class fileTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function testRealPath15 ()
|
public function testRealPath15 ()
|
||||||
{
|
{
|
||||||
$file = new file ();
|
$file = new File ();
|
||||||
$file->chroot ("/tmp");
|
$file->chroot ("/tmp");
|
||||||
$res = $file->realpath ("../../../../../tmp2/file");
|
$res = $file->realpath ("../../../../../tmp2/file");
|
||||||
$this->assertSame($res, "/tmp/tmp2/file");
|
$this->assertSame($res, "/tmp/tmp2/file");
|
||||||
@@ -102,7 +108,7 @@ class fileTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function testRealPath16 ()
|
public function testRealPath16 ()
|
||||||
{
|
{
|
||||||
$file = new file ();
|
$file = new File ();
|
||||||
$file->chroot ("/tmp");
|
$file->chroot ("/tmp");
|
||||||
$res = $file->realpath ("../../../../../tmp2/file/../../../..");
|
$res = $file->realpath ("../../../../../tmp2/file/../../../..");
|
||||||
$this->assertSame($res, "/tmp");
|
$this->assertSame($res, "/tmp");
|
||||||
@@ -110,7 +116,7 @@ class fileTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function testRealPath17 ()
|
public function testRealPath17 ()
|
||||||
{
|
{
|
||||||
$file = new file ();
|
$file = new File ();
|
||||||
$file->chroot ("/tmp");
|
$file->chroot ("/tmp");
|
||||||
$res = $file->realpath (".././././../tmp2/file/../././..");
|
$res = $file->realpath (".././././../tmp2/file/../././..");
|
||||||
$this->assertSame($res, "/tmp");
|
$this->assertSame($res, "/tmp");
|
||||||
@@ -119,14 +125,14 @@ class fileTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function testGetcwd1 ()
|
public function testGetcwd1 ()
|
||||||
{
|
{
|
||||||
$file = new file ();
|
$file = new File ();
|
||||||
$res = $file->getcwd ();
|
$res = $file->getcwd ();
|
||||||
$this->assertSame($res, ".");
|
$this->assertSame($res, ".");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetcwd2 ()
|
public function testGetcwd2 ()
|
||||||
{
|
{
|
||||||
$file = new file ();
|
$file = new File ();
|
||||||
$file->chdir ("/tmp");
|
$file->chdir ("/tmp");
|
||||||
$res = $file->getcwd ();
|
$res = $file->getcwd ();
|
||||||
$this->assertSame($res, "/tmp");
|
$this->assertSame($res, "/tmp");
|
||||||
@@ -135,13 +141,13 @@ class fileTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function testGetcwd3 ()
|
public function testGetcwd3 ()
|
||||||
{
|
{
|
||||||
$this->setExpectedException ("Exception", "Path '/NON EXISTS' not found");
|
$this->setExpectedException ("Exception", "Path '/NON EXISTS' not found");
|
||||||
$file = new file ();
|
$file = new File ();
|
||||||
$file->chdir ("/NON EXISTS");
|
$file->chdir ("/NON EXISTS");
|
||||||
$res = $file->getcwd ();
|
$res = $file->getcwd ();
|
||||||
}
|
}
|
||||||
public function testGetcwd4 ()
|
public function testGetcwd4 ()
|
||||||
{
|
{
|
||||||
$file = new file ();
|
$file = new File ();
|
||||||
$file->chdir ("/../../../tmp");
|
$file->chdir ("/../../../tmp");
|
||||||
$res = $file->getcwd ();
|
$res = $file->getcwd ();
|
||||||
$this->assertSame($res, "/tmp");
|
$this->assertSame($res, "/tmp");
|
||||||
@@ -149,7 +155,7 @@ class fileTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function testGetcwd5 ()
|
public function testGetcwd5 ()
|
||||||
{
|
{
|
||||||
$file = new file ();
|
$file = new File ();
|
||||||
$file->chdir ("../../../../../../tmp");
|
$file->chdir ("../../../../../../tmp");
|
||||||
$res = $file->getcwd ();
|
$res = $file->getcwd ();
|
||||||
$this->assertSame($res, "/tmp");
|
$this->assertSame($res, "/tmp");
|
||||||
@@ -158,7 +164,7 @@ class fileTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function testGetcwd6 ()
|
public function testGetcwd6 ()
|
||||||
{
|
{
|
||||||
$this->setExpectedException ("Exception", "Path './tmp' not found");
|
$this->setExpectedException ("Exception", "Path './tmp' not found");
|
||||||
$file = new file ();
|
$file = new File ();
|
||||||
$file->chdir ("./tmp");
|
$file->chdir ("./tmp");
|
||||||
$res = $file->getcwd ();
|
$res = $file->getcwd ();
|
||||||
}
|
}
|
||||||
@@ -167,7 +173,7 @@ class fileTest extends \PHPUnit_Framework_TestCase
|
|||||||
{
|
{
|
||||||
$this->setExpectedException ("Exception",
|
$this->setExpectedException ("Exception",
|
||||||
"Path '/tmp/NON EXISTS' not found");
|
"Path '/tmp/NON EXISTS' not found");
|
||||||
$file = new file ();
|
$file = new File ();
|
||||||
$file->chdir ("/tmp/NON EXISTS");
|
$file->chdir ("/tmp/NON EXISTS");
|
||||||
$res = $file->getcwd ();
|
$res = $file->getcwd ();
|
||||||
}
|
}
|
||||||
@@ -176,7 +182,7 @@ class fileTest extends \PHPUnit_Framework_TestCase
|
|||||||
{
|
{
|
||||||
$this->setExpectedException ("Exception",
|
$this->setExpectedException ("Exception",
|
||||||
"Parent Path '/NON EXISTS/' not found");
|
"Parent Path '/NON EXISTS/' not found");
|
||||||
$file = new file ();
|
$file = new File ();
|
||||||
$file->chdir ("/NON EXISTS/tmp");
|
$file->chdir ("/NON EXISTS/tmp");
|
||||||
$res = $file->getcwd ();
|
$res = $file->getcwd ();
|
||||||
}
|
}
|
||||||
@@ -184,13 +190,13 @@ class fileTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function testchroot1 ()
|
public function testchroot1 ()
|
||||||
{
|
{
|
||||||
$this->setExpectedException ("Exception");
|
$this->setExpectedException ("Exception");
|
||||||
$file = new file ();
|
$file = new File ();
|
||||||
$res = $file->chroot ("non exists");
|
$res = $file->chroot ("non exists");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testchroot2 ()
|
public function testchroot2 ()
|
||||||
{
|
{
|
||||||
$file = new file ();
|
$file = new File ();
|
||||||
$res = $file->chroot ("/tmp");
|
$res = $file->chroot ("/tmp");
|
||||||
$this->assertSame($res, true);
|
$this->assertSame($res, true);
|
||||||
}
|
}
|
||||||
@@ -198,7 +204,7 @@ class fileTest extends \PHPUnit_Framework_TestCase
|
|||||||
// Without chroot
|
// Without chroot
|
||||||
public function testMkdir1 ()
|
public function testMkdir1 ()
|
||||||
{
|
{
|
||||||
$file = new file ();
|
$file = new File ();
|
||||||
$res = $file->mkdir ("/tmp/testmkdir1-".time());
|
$res = $file->mkdir ("/tmp/testmkdir1-".time());
|
||||||
$this->assertSame($res, true);
|
$this->assertSame($res, true);
|
||||||
}
|
}
|
||||||
@@ -206,7 +212,7 @@ class fileTest extends \PHPUnit_Framework_TestCase
|
|||||||
// With chroot in tmp
|
// With chroot in tmp
|
||||||
public function testMkdir2 ()
|
public function testMkdir2 ()
|
||||||
{
|
{
|
||||||
$file = new file ();
|
$file = new File ();
|
||||||
$res = $file->chroot ("/tmp");
|
$res = $file->chroot ("/tmp");
|
||||||
$res = $file->mkdir ("/testmkdir2-".time());
|
$res = $file->mkdir ("/testmkdir2-".time());
|
||||||
$this->assertSame($res, true);
|
$this->assertSame($res, true);
|
||||||
@@ -215,7 +221,7 @@ class fileTest extends \PHPUnit_Framework_TestCase
|
|||||||
// Without chroot and relative
|
// Without chroot and relative
|
||||||
public function testMkdir3 ()
|
public function testMkdir3 ()
|
||||||
{
|
{
|
||||||
$file = new file ();
|
$file = new File ();
|
||||||
$res = $file->mkdir ("/tmp/testmkdir3-".time());
|
$res = $file->mkdir ("/tmp/testmkdir3-".time());
|
||||||
$this->assertSame($res, true);
|
$this->assertSame($res, true);
|
||||||
}
|
}
|
||||||
@@ -223,7 +229,7 @@ class fileTest extends \PHPUnit_Framework_TestCase
|
|||||||
// With chroot in tmp and in relative
|
// With chroot in tmp and in relative
|
||||||
public function testMkdir4 ()
|
public function testMkdir4 ()
|
||||||
{
|
{
|
||||||
$file = new file ();
|
$file = new File ();
|
||||||
$res = $file->chroot ("/tmp");
|
$res = $file->chroot ("/tmp");
|
||||||
$res = $file->mkdir ("testmkdir4-".time());
|
$res = $file->mkdir ("testmkdir4-".time());
|
||||||
$this->assertSame($res, true);
|
$this->assertSame($res, true);
|
||||||
@@ -232,8 +238,9 @@ class fileTest extends \PHPUnit_Framework_TestCase
|
|||||||
// With chroot in tmp
|
// With chroot in tmp
|
||||||
public function testChdir1 ()
|
public function testChdir1 ()
|
||||||
{
|
{
|
||||||
@rmdir ("/tmp/testDFFileDir");
|
if (file_exists ("/tmp/testDFFileDir"))
|
||||||
$file = new file ();
|
rmdir ("/tmp/testDFFileDir");
|
||||||
|
$file = new File ();
|
||||||
$file->chroot ("/tmp");
|
$file->chroot ("/tmp");
|
||||||
$file->mkdir ("/testDFFileDir");
|
$file->mkdir ("/testDFFileDir");
|
||||||
$file->chdir ("/testDFFileDir");
|
$file->chdir ("/testDFFileDir");
|
||||||
@@ -244,8 +251,9 @@ class fileTest extends \PHPUnit_Framework_TestCase
|
|||||||
// With chroot in tmp
|
// With chroot in tmp
|
||||||
public function testChdir2 ()
|
public function testChdir2 ()
|
||||||
{
|
{
|
||||||
@rmdir ("/tmp/testDFFileDir");
|
if (file_exists ("/tmp/testDFFileDir"))
|
||||||
$file = new file ();
|
rmdir ("/tmp/testDFFileDir");
|
||||||
|
$file = new File ();
|
||||||
$file->chroot ("/tmp");
|
$file->chroot ("/tmp");
|
||||||
$file->mkdir ("/testDFFileDir");
|
$file->mkdir ("/testDFFileDir");
|
||||||
$file->chroot ("/");
|
$file->chroot ("/");
|
||||||
@@ -259,8 +267,9 @@ class fileTest extends \PHPUnit_Framework_TestCase
|
|||||||
{
|
{
|
||||||
$this->setExpectedException ("Exception",
|
$this->setExpectedException ("Exception",
|
||||||
"Path '/tmp/testDFFileDir/NON EXISTS' not found");
|
"Path '/tmp/testDFFileDir/NON EXISTS' not found");
|
||||||
@rmdir ("/tmp/testDFFileDir");
|
if (file_exists ("/tmp/testDFFileDir"))
|
||||||
$file = new file ();
|
rmdir ("/tmp/testDFFileDir");
|
||||||
|
$file = new File ();
|
||||||
$file->chroot ("/tmp");
|
$file->chroot ("/tmp");
|
||||||
$file->mkdir ("/testDFFileDir");
|
$file->mkdir ("/testDFFileDir");
|
||||||
$file->chroot ("/testDFFileDir");
|
$file->chroot ("/testDFFileDir");
|
||||||
@@ -272,8 +281,9 @@ class fileTest extends \PHPUnit_Framework_TestCase
|
|||||||
{
|
{
|
||||||
$this->setExpectedException ("Exception",
|
$this->setExpectedException ("Exception",
|
||||||
"Parent Path '/tmp/tmp/' not found");
|
"Parent Path '/tmp/tmp/' not found");
|
||||||
@rmdir ("/tmp/testDFFileDir");
|
if (file_exists ("/tmp/testDFFileDir"))
|
||||||
$file = new file ();
|
rmdir ("/tmp/testDFFileDir");
|
||||||
|
$file = new File ();
|
||||||
$file->chroot ("/tmp");
|
$file->chroot ("/tmp");
|
||||||
$file->mkdir ("/testDFFileDir");
|
$file->mkdir ("/testDFFileDir");
|
||||||
$file->chroot ("..");
|
$file->chroot ("..");
|
||||||
@@ -284,8 +294,9 @@ class fileTest extends \PHPUnit_Framework_TestCase
|
|||||||
{
|
{
|
||||||
$this->setExpectedException ("Exception",
|
$this->setExpectedException ("Exception",
|
||||||
"File '/tmp/testDFFileDir' is not a file");
|
"File '/tmp/testDFFileDir' is not a file");
|
||||||
@rmdir ("/tmp/testDFFileDir");
|
if (file_exists ("/tmp/testDFFileDir"))
|
||||||
$file = new file ();
|
rmdir ("/tmp/testDFFileDir");
|
||||||
|
$file = new File ();
|
||||||
$file->chroot ("/tmp");
|
$file->chroot ("/tmp");
|
||||||
$file->mkdir ("/testDFFileDir");
|
$file->mkdir ("/testDFFileDir");
|
||||||
$res = $file->file_get_contents ("/testDFFileDir");
|
$res = $file->file_get_contents ("/testDFFileDir");
|
||||||
@@ -293,8 +304,9 @@ class fileTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function testFile_get_contents2 ()
|
public function testFile_get_contents2 ()
|
||||||
{
|
{
|
||||||
@rmdir ("/tmp/testDFFileDir");
|
if (file_exists ("/tmp/testDFFileDir"))
|
||||||
$file = new file ();
|
rmdir ("/tmp/testDFFileDir");
|
||||||
|
$file = new File ();
|
||||||
$file->chroot ("/tmp");
|
$file->chroot ("/tmp");
|
||||||
$file->mkdir ("/testDFFileDir");
|
$file->mkdir ("/testDFFileDir");
|
||||||
$file->touch ("/testDFFileDir/toto");
|
$file->touch ("/testDFFileDir/toto");
|
||||||
@@ -304,7 +316,7 @@ class fileTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function testFile_put_contents1 ()
|
public function testFile_put_contents1 ()
|
||||||
{
|
{
|
||||||
$file = new file ();
|
$file = new File ();
|
||||||
$file->chroot ("/tmp");
|
$file->chroot ("/tmp");
|
||||||
$file->file_put_contents ("/testDFFileDir/toto", "content");
|
$file->file_put_contents ("/testDFFileDir/toto", "content");
|
||||||
$res = $file->file_get_contents ("/testDFFileDir/toto");
|
$res = $file->file_get_contents ("/testDFFileDir/toto");
|
||||||
@@ -315,13 +327,13 @@ class fileTest extends \PHPUnit_Framework_TestCase
|
|||||||
{
|
{
|
||||||
$this->setExpectedException ("Exception",
|
$this->setExpectedException ("Exception",
|
||||||
"File '/tmp/testDFFileDir' is not a file");
|
"File '/tmp/testDFFileDir' is not a file");
|
||||||
$file = new file ();
|
$file = new File ();
|
||||||
$file->file_put_contents ("/tmp/testDFFileDir", "content");
|
$file->file_put_contents ("/tmp/testDFFileDir", "content");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testFile_put_contents3 ()
|
public function testFile_put_contents3 ()
|
||||||
{
|
{
|
||||||
$file = new file ();
|
$file = new File ();
|
||||||
$file->chroot ("/tmp");
|
$file->chroot ("/tmp");
|
||||||
$res = $file->file_put_contents ("/testDFFileDir/toto", "content");
|
$res = $file->file_put_contents ("/testDFFileDir/toto", "content");
|
||||||
$this->assertSame($res, 7);
|
$this->assertSame($res, 7);
|
||||||
@@ -329,14 +341,14 @@ class fileTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function testscandir1 ()
|
public function testscandir1 ()
|
||||||
{
|
{
|
||||||
$file = new file ();
|
$file = new File ();
|
||||||
$res = $file->scandir ("/tmp/testDFFileDir");
|
$res = $file->scandir ("/tmp/testDFFileDir");
|
||||||
$this->assertSame ($res, array ("toto"));
|
$this->assertSame ($res, array ("toto"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testscandir2 ()
|
public function testscandir2 ()
|
||||||
{
|
{
|
||||||
$file = new file ();
|
$file = new File ();
|
||||||
$file->chroot ("/tmp");
|
$file->chroot ("/tmp");
|
||||||
$res = $file->scandir ("/testDFFileDir");
|
$res = $file->scandir ("/testDFFileDir");
|
||||||
$this->assertSame ($res, array ("toto"));
|
$this->assertSame ($res, array ("toto"));
|
||||||
@@ -344,7 +356,7 @@ class fileTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function testscandir3 ()
|
public function testscandir3 ()
|
||||||
{
|
{
|
||||||
$file = new file ();
|
$file = new File ();
|
||||||
$file->chroot ("/tmp");
|
$file->chroot ("/tmp");
|
||||||
$res = $file->scandir ("/testDFFileDir/");
|
$res = $file->scandir ("/testDFFileDir/");
|
||||||
$this->assertSame ($res, array ("toto"));
|
$this->assertSame ($res, array ("toto"));
|
||||||
@@ -353,7 +365,7 @@ class fileTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function testrmdir1 ()
|
public function testrmdir1 ()
|
||||||
{
|
{
|
||||||
// Directory not empty and NOT recursive : return false
|
// Directory not empty and NOT recursive : return false
|
||||||
$file = new file ();
|
$file = new File ();
|
||||||
$res = $file->rmdir ("/tmp/testDFFileDir");
|
$res = $file->rmdir ("/tmp/testDFFileDir");
|
||||||
$this->assertSame ($res, false);
|
$this->assertSame ($res, false);
|
||||||
}
|
}
|
||||||
@@ -361,7 +373,7 @@ class fileTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function testrmdir2 ()
|
public function testrmdir2 ()
|
||||||
{
|
{
|
||||||
// Directory not empty and NOT recursive : return false
|
// Directory not empty and NOT recursive : return false
|
||||||
$file = new file ();
|
$file = new File ();
|
||||||
$file->chroot ("/tmp");
|
$file->chroot ("/tmp");
|
||||||
$res = $file->rmdir ("/testDFFileDir");
|
$res = $file->rmdir ("/testDFFileDir");
|
||||||
$this->assertSame ($res, false);
|
$this->assertSame ($res, false);
|
||||||
@@ -370,7 +382,7 @@ class fileTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function testrmdir3 ()
|
public function testrmdir3 ()
|
||||||
{
|
{
|
||||||
// Directory not empty and recursive : return true
|
// Directory not empty and recursive : return true
|
||||||
$file = new file ();
|
$file = new File ();
|
||||||
$file->chroot ("/tmp");
|
$file->chroot ("/tmp");
|
||||||
$res = $file->rmdir ("/testDFFileDir", true);
|
$res = $file->rmdir ("/testDFFileDir", true);
|
||||||
$this->assertSame ($res, true);
|
$this->assertSame ($res, true);
|
||||||
@@ -378,8 +390,9 @@ class fileTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function testUnlink1 ()
|
public function testUnlink1 ()
|
||||||
{
|
{
|
||||||
@rmdir ("/tmp/testDFFileDir");
|
if (file_exists ("/tmp/testDFFileDir"))
|
||||||
$file = new file ();
|
rmdir ("/tmp/testDFFileDir");
|
||||||
|
$file = new File ();
|
||||||
$file->chroot ("/tmp");
|
$file->chroot ("/tmp");
|
||||||
$file->mkdir ("/testDFFileDir");
|
$file->mkdir ("/testDFFileDir");
|
||||||
$file->touch ("/testDFFileDir/toto");
|
$file->touch ("/testDFFileDir/toto");
|
||||||
@@ -389,7 +402,7 @@ class fileTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function testIsDir1 ()
|
public function testIsDir1 ()
|
||||||
{
|
{
|
||||||
$file = new file ();
|
$file = new File ();
|
||||||
$file->chroot ("/tmp");
|
$file->chroot ("/tmp");
|
||||||
$res = $file->is_dir ("//testDFFileDir");
|
$res = $file->is_dir ("//testDFFileDir");
|
||||||
$this->assertSame ($res, true);
|
$this->assertSame ($res, true);
|
||||||
@@ -397,7 +410,7 @@ class fileTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function testIsDir2 ()
|
public function testIsDir2 ()
|
||||||
{
|
{
|
||||||
$file = new file ();
|
$file = new File ();
|
||||||
$file->chroot ("/tmp");
|
$file->chroot ("/tmp");
|
||||||
$file->touch ("/testDFFileDir/toto");
|
$file->touch ("/testDFFileDir/toto");
|
||||||
$res = $file->is_dir ("//testDFFileDir/toto");
|
$res = $file->is_dir ("//testDFFileDir/toto");
|
||||||
@@ -406,7 +419,7 @@ class fileTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function testIsFile1 ()
|
public function testIsFile1 ()
|
||||||
{
|
{
|
||||||
$file = new file ();
|
$file = new File ();
|
||||||
$file->chroot ("/tmp");
|
$file->chroot ("/tmp");
|
||||||
$file->touch ("/testDFFileDir/toto");
|
$file->touch ("/testDFFileDir/toto");
|
||||||
$res = $file->is_file ("/testDFFileDir/toto");
|
$res = $file->is_file ("/testDFFileDir/toto");
|
||||||
@@ -415,7 +428,7 @@ class fileTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function testIsFile2 ()
|
public function testIsFile2 ()
|
||||||
{
|
{
|
||||||
$file = new file ();
|
$file = new File ();
|
||||||
$file->chroot ("/tmp");
|
$file->chroot ("/tmp");
|
||||||
$file->touch ("/testDFFileDir/toto");
|
$file->touch ("/testDFFileDir/toto");
|
||||||
$res = $file->is_file ("//testDFFileDir");
|
$res = $file->is_file ("//testDFFileDir");
|
||||||
@@ -424,7 +437,7 @@ class fileTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function testMkdir5 ()
|
public function testMkdir5 ()
|
||||||
{
|
{
|
||||||
$file = new file ();
|
$file = new File ();
|
||||||
$file->chroot ("/tmp");
|
$file->chroot ("/tmp");
|
||||||
// The parent doesn't exists and not recursive mode : exception
|
// The parent doesn't exists and not recursive mode : exception
|
||||||
$this->expectException ();
|
$this->expectException ();
|
||||||
@@ -433,7 +446,7 @@ class fileTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function testMkdir6 ()
|
public function testMkdir6 ()
|
||||||
{
|
{
|
||||||
$file = new file ();
|
$file = new File ();
|
||||||
$file->chroot ("/tmp");
|
$file->chroot ("/tmp");
|
||||||
$res = $file->mkdir ("/testDFFileDir/tptp/titi/poo", 0777, true);
|
$res = $file->mkdir ("/testDFFileDir/tptp/titi/poo", 0777, true);
|
||||||
$this->assertSame ($res, true);
|
$this->assertSame ($res, true);
|
||||||
@@ -441,7 +454,7 @@ class fileTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_glob_1 ()
|
public function test_glob_1 ()
|
||||||
{
|
{
|
||||||
$file = new file ();
|
$file = new File ();
|
||||||
$file->chroot ("/tmp");
|
$file->chroot ("/tmp");
|
||||||
$res = $file->glob ("/testDFFileDir/*");
|
$res = $file->glob ("/testDFFileDir/*");
|
||||||
$this->assertSame ($res, array ("/testDFFileDir/toto",
|
$this->assertSame ($res, array ("/testDFFileDir/toto",
|
||||||
@@ -450,7 +463,7 @@ class fileTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_glob_2 ()
|
public function test_glob_2 ()
|
||||||
{
|
{
|
||||||
$file = new file ();
|
$file = new File ();
|
||||||
$file->chroot ("/tmp");
|
$file->chroot ("/tmp");
|
||||||
$file->chdir ("/testDFFileDir");
|
$file->chdir ("/testDFFileDir");
|
||||||
$res = $file->glob ("*");
|
$res = $file->glob ("*");
|
||||||
@@ -460,7 +473,7 @@ class fileTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_glob_3 ()
|
public function test_glob_3 ()
|
||||||
{
|
{
|
||||||
$file = new file ();
|
$file = new File ();
|
||||||
$file->chroot ("/tmp");
|
$file->chroot ("/tmp");
|
||||||
$file->chdir ("/testDFFileDir");
|
$file->chdir ("/testDFFileDir");
|
||||||
$res = $file->glob ("/testDFFileDir/*");
|
$res = $file->glob ("/testDFFileDir/*");
|
||||||
@@ -470,7 +483,7 @@ class fileTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_glob_4 ()
|
public function test_glob_4 ()
|
||||||
{
|
{
|
||||||
$file = new file ();
|
$file = new File ();
|
||||||
$res = $file->glob ("/tmp/testDFFileDir/*");
|
$res = $file->glob ("/tmp/testDFFileDir/*");
|
||||||
$this->assertSame ($res, array ("/tmp/testDFFileDir/toto",
|
$this->assertSame ($res, array ("/tmp/testDFFileDir/toto",
|
||||||
"/tmp/testDFFileDir/tptp"));
|
"/tmp/testDFFileDir/tptp"));
|
||||||
@@ -478,7 +491,7 @@ class fileTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_glob_5 ()
|
public function test_glob_5 ()
|
||||||
{
|
{
|
||||||
$file = new file ();
|
$file = new File ();
|
||||||
$file->chdir ("/tmp/testDFFileDir");
|
$file->chdir ("/tmp/testDFFileDir");
|
||||||
$res = $file->glob ("*");
|
$res = $file->glob ("*");
|
||||||
$this->assertSame ($res, array ("toto",
|
$this->assertSame ($res, array ("toto",
|
||||||
@@ -487,7 +500,7 @@ class fileTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_glob_6 ()
|
public function test_glob_6 ()
|
||||||
{
|
{
|
||||||
$file = new file ();
|
$file = new File ();
|
||||||
$file->chdir ("/tmp/testDFFileDir");
|
$file->chdir ("/tmp/testDFFileDir");
|
||||||
$res = $file->glob ("/tmp/testDFFileDir/*");
|
$res = $file->glob ("/tmp/testDFFileDir/*");
|
||||||
$this->assertSame ($res, array ("/tmp/testDFFileDir/toto",
|
$this->assertSame ($res, array ("/tmp/testDFFileDir/toto",
|
||||||
|
|||||||
@@ -1,12 +1,21 @@
|
|||||||
<?php
|
<?php
|
||||||
|
/** DomFramework - Tests
|
||||||
|
* @package domframework
|
||||||
|
* @author Dominique Fournier <dominique@fournier38.fr>
|
||||||
|
* @license BSD
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Domframework\Tests;
|
||||||
|
|
||||||
|
use Domframework\Fts;
|
||||||
|
|
||||||
/** Test the FTS */
|
/** Test the FTS */
|
||||||
class ftsTest extends \PHPUnit_Framework_TestCase
|
class FtsTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
public function test_tokenizerSearch0 ()
|
public function test_tokenizerSearch0 ()
|
||||||
{
|
{
|
||||||
// Empty
|
// Empty
|
||||||
$fts = new fts ();
|
$fts = new Fts ();
|
||||||
$fts->search ("");
|
$fts->search ("");
|
||||||
$res = $fts->getTokensMin ();
|
$res = $fts->getTokensMin ();
|
||||||
$this->assertSame ($res, array ("tokens"=>array (),
|
$this->assertSame ($res, array ("tokens"=>array (),
|
||||||
@@ -16,7 +25,7 @@ class ftsTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function test_tokenizerSearch1 ()
|
public function test_tokenizerSearch1 ()
|
||||||
{
|
{
|
||||||
// Too small
|
// Too small
|
||||||
$fts = new fts ();
|
$fts = new Fts ();
|
||||||
$fts->search ("X");
|
$fts->search ("X");
|
||||||
$res = $fts->getTokensMin ();
|
$res = $fts->getTokensMin ();
|
||||||
$this->assertSame ($res, array ("tokens"=>array (),
|
$this->assertSame ($res, array ("tokens"=>array (),
|
||||||
@@ -26,7 +35,7 @@ class ftsTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function test_tokenizerSearch2 ()
|
public function test_tokenizerSearch2 ()
|
||||||
{
|
{
|
||||||
// One word
|
// One word
|
||||||
$fts = new fts ();
|
$fts = new Fts ();
|
||||||
$fts->search ("XYZ");
|
$fts->search ("XYZ");
|
||||||
$res = $fts->getTokensMin ();
|
$res = $fts->getTokensMin ();
|
||||||
$this->assertSame ($res, array ("tokens"=>array ("XYZ"),
|
$this->assertSame ($res, array ("tokens"=>array ("XYZ"),
|
||||||
@@ -36,7 +45,7 @@ class ftsTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function test_tokenizerSearch3 ()
|
public function test_tokenizerSearch3 ()
|
||||||
{
|
{
|
||||||
// Two word
|
// Two word
|
||||||
$fts = new fts ();
|
$fts = new Fts ();
|
||||||
$fts->search ("XYZ 123");
|
$fts->search ("XYZ 123");
|
||||||
$res = $fts->getTokensMin ();
|
$res = $fts->getTokensMin ();
|
||||||
$this->assertSame ($res, array ("tokens"=>array ("XYZ", "123"),
|
$this->assertSame ($res, array ("tokens"=>array ("XYZ", "123"),
|
||||||
@@ -46,7 +55,7 @@ class ftsTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function test_tokenizerSearch4 ()
|
public function test_tokenizerSearch4 ()
|
||||||
{
|
{
|
||||||
// Three word
|
// Three word
|
||||||
$fts = new fts ();
|
$fts = new Fts ();
|
||||||
$fts->search ("XYZ 123 ABC");
|
$fts->search ("XYZ 123 ABC");
|
||||||
$res = $fts->getTokensMin ();
|
$res = $fts->getTokensMin ();
|
||||||
$this->assertSame ($res, array ("tokens"=>array ("XYZ", "123", "ABC"),
|
$this->assertSame ($res, array ("tokens"=>array ("XYZ", "123", "ABC"),
|
||||||
@@ -56,7 +65,7 @@ class ftsTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function test_tokenizerSearch5 ()
|
public function test_tokenizerSearch5 ()
|
||||||
{
|
{
|
||||||
// Three word
|
// Three word
|
||||||
$fts = new fts ();
|
$fts = new Fts ();
|
||||||
$fts->search ("XYZ 123 ABC KLM");
|
$fts->search ("XYZ 123 ABC KLM");
|
||||||
$res = $fts->getTokensMin ();
|
$res = $fts->getTokensMin ();
|
||||||
$this->assertSame ($res, array ("tokens"=>array ("XYZ", "123",
|
$this->assertSame ($res, array ("tokens"=>array ("XYZ", "123",
|
||||||
@@ -67,7 +76,7 @@ class ftsTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function test_tokenizerSearch6 ()
|
public function test_tokenizerSearch6 ()
|
||||||
{
|
{
|
||||||
// Three word
|
// Three word
|
||||||
$fts = new fts ();
|
$fts = new Fts ();
|
||||||
$fts->search ("Louis-XYZ 123 -AéBCé KLM");
|
$fts->search ("Louis-XYZ 123 -AéBCé KLM");
|
||||||
$res = $fts->getTokensMin ();
|
$res = $fts->getTokensMin ();
|
||||||
$this->assertSame ($res, array ("tokens"=>array ("Louis-XYZ", "123",
|
$this->assertSame ($res, array ("tokens"=>array ("Louis-XYZ", "123",
|
||||||
@@ -79,7 +88,7 @@ class ftsTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function test_tokenizerSentence0 ()
|
public function test_tokenizerSentence0 ()
|
||||||
{
|
{
|
||||||
// Empty sentence
|
// Empty sentence
|
||||||
$fts = new fts ();
|
$fts = new Fts ();
|
||||||
$fts->search ("\"\"");
|
$fts->search ("\"\"");
|
||||||
$res = $fts->getTokensMin ();
|
$res = $fts->getTokensMin ();
|
||||||
$this->assertSame ($res, array ("tokens"=>array (),
|
$this->assertSame ($res, array ("tokens"=>array (),
|
||||||
@@ -89,7 +98,7 @@ class ftsTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function test_tokenizerSentence1 ()
|
public function test_tokenizerSentence1 ()
|
||||||
{
|
{
|
||||||
// One sentence only
|
// One sentence only
|
||||||
$fts = new fts ();
|
$fts = new Fts ();
|
||||||
$fts->search ("\"XYZ 123\"");
|
$fts->search ("\"XYZ 123\"");
|
||||||
$res = $fts->getTokensMin ();
|
$res = $fts->getTokensMin ();
|
||||||
$this->assertSame ($res, array ("tokens"=>array ("XYZ 123"),
|
$this->assertSame ($res, array ("tokens"=>array ("XYZ 123"),
|
||||||
@@ -99,7 +108,7 @@ class ftsTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function test_tokenizerSentence2 ()
|
public function test_tokenizerSentence2 ()
|
||||||
{
|
{
|
||||||
// Two sentence
|
// Two sentence
|
||||||
$fts = new fts ();
|
$fts = new Fts ();
|
||||||
$fts->search ("\"XYZ 123\" \"ABC KLM\"");
|
$fts->search ("\"XYZ 123\" \"ABC KLM\"");
|
||||||
$res = $fts->getTokensMin ();
|
$res = $fts->getTokensMin ();
|
||||||
$this->assertSame ($res, array ("tokens"=>array ("XYZ 123", "ABC KLM"),
|
$this->assertSame ($res, array ("tokens"=>array ("XYZ 123", "ABC KLM"),
|
||||||
@@ -109,7 +118,7 @@ class ftsTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function test_tokenizerSentence3 ()
|
public function test_tokenizerSentence3 ()
|
||||||
{
|
{
|
||||||
// Three sentence
|
// Three sentence
|
||||||
$fts = new fts ();
|
$fts = new Fts ();
|
||||||
$fts->search ("\"XYZ 123\" -\"ABC KLM\" \"RPO YUI\"");
|
$fts->search ("\"XYZ 123\" -\"ABC KLM\" \"RPO YUI\"");
|
||||||
$res = $fts->getTokensMin ();
|
$res = $fts->getTokensMin ();
|
||||||
$this->assertSame ($res, array ("tokens"=>array ("XYZ 123", "ABC KLM",
|
$this->assertSame ($res, array ("tokens"=>array ("XYZ 123", "ABC KLM",
|
||||||
@@ -120,7 +129,7 @@ class ftsTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function test_tokenizerMixed1 ()
|
public function test_tokenizerMixed1 ()
|
||||||
{
|
{
|
||||||
// One word and one sentence, starting by word
|
// One word and one sentence, starting by word
|
||||||
$fts = new fts ();
|
$fts = new Fts ();
|
||||||
$fts->search ("XYZ \"ABC KLM\"");
|
$fts->search ("XYZ \"ABC KLM\"");
|
||||||
$res = $fts->getTokensMin ();
|
$res = $fts->getTokensMin ();
|
||||||
$this->assertSame ($res, array ("tokens"=>array ("XYZ", "ABC KLM"),
|
$this->assertSame ($res, array ("tokens"=>array ("XYZ", "ABC KLM"),
|
||||||
@@ -130,7 +139,7 @@ class ftsTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function test_tokenizerMixed2 ()
|
public function test_tokenizerMixed2 ()
|
||||||
{
|
{
|
||||||
// One word and one sentence, starting by sentence
|
// One word and one sentence, starting by sentence
|
||||||
$fts = new fts ();
|
$fts = new Fts ();
|
||||||
$fts->search ("\"ABC KLM\" XYZ");
|
$fts->search ("\"ABC KLM\" XYZ");
|
||||||
$res = $fts->getTokensMin ();
|
$res = $fts->getTokensMin ();
|
||||||
$this->assertSame ($res, array ("tokens"=>array ("ABC KLM", "XYZ"),
|
$this->assertSame ($res, array ("tokens"=>array ("ABC KLM", "XYZ"),
|
||||||
@@ -140,7 +149,7 @@ class ftsTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function test_tokenizerMixed3 ()
|
public function test_tokenizerMixed3 ()
|
||||||
{
|
{
|
||||||
// One word and two sentences, starting by sentence
|
// One word and two sentences, starting by sentence
|
||||||
$fts = new fts ();
|
$fts = new Fts ();
|
||||||
$fts->search ("\"ABC KLM\" XYZ \"RPO YUI\"");
|
$fts->search ("\"ABC KLM\" XYZ \"RPO YUI\"");
|
||||||
$res = $fts->getTokensMin ();
|
$res = $fts->getTokensMin ();
|
||||||
$this->assertSame ($res, array ("tokens"=>array ("ABC KLM", "XYZ",
|
$this->assertSame ($res, array ("tokens"=>array ("ABC KLM", "XYZ",
|
||||||
@@ -151,7 +160,7 @@ class ftsTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function test_tokenizerMixed4 ()
|
public function test_tokenizerMixed4 ()
|
||||||
{
|
{
|
||||||
// Two words and two sentences, starting by sentence
|
// Two words and two sentences, starting by sentence
|
||||||
$fts = new fts ();
|
$fts = new Fts ();
|
||||||
$fts->search ("\"ABC KLM\" XYZ \"RPO YUI\" 123");
|
$fts->search ("\"ABC KLM\" XYZ \"RPO YUI\" 123");
|
||||||
$res = $fts->getTokensMin ();
|
$res = $fts->getTokensMin ();
|
||||||
$this->assertSame ($res, array ("tokens"=>array ("ABC KLM", "XYZ",
|
$this->assertSame ($res, array ("tokens"=>array ("ABC KLM", "XYZ",
|
||||||
@@ -162,7 +171,7 @@ class ftsTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function test_tokenizerMixed5 ()
|
public function test_tokenizerMixed5 ()
|
||||||
{
|
{
|
||||||
// Two words and two sentences, starting by a word
|
// Two words and two sentences, starting by a word
|
||||||
$fts = new fts ();
|
$fts = new Fts ();
|
||||||
$fts->search ("123 \"ABC KLM\" XYZ \"RPO YUI\"");
|
$fts->search ("123 \"ABC KLM\" XYZ \"RPO YUI\"");
|
||||||
$res = $fts->getTokensMin ();
|
$res = $fts->getTokensMin ();
|
||||||
$this->assertSame ($res, array ("tokens"=>array ("123", "ABC KLM",
|
$this->assertSame ($res, array ("tokens"=>array ("123", "ABC KLM",
|
||||||
|
|||||||
@@ -7,27 +7,29 @@
|
|||||||
|
|
||||||
namespace Domframework\Tests;
|
namespace Domframework\Tests;
|
||||||
|
|
||||||
|
use Domframework\Getopts;
|
||||||
|
|
||||||
/** Test the GetOpts */
|
/** Test the GetOpts */
|
||||||
class getoptsTest extends \PHPUnit_Framework_TestCase
|
class GetoptsTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
public function test_empty1 ()
|
public function test_empty1 ()
|
||||||
{
|
{
|
||||||
// Empty
|
// Empty
|
||||||
$getopts = new getopts ();
|
$getopts = new Getopts ();
|
||||||
$res = $getopts->help ();
|
$res = $getopts->help ();
|
||||||
$this->assertSame ($res, "No option defined\n");
|
$this->assertSame ($res, "No option defined\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_simu1 ()
|
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");
|
$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);
|
$this->assertSame (is_object ($res), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_add1 ()
|
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");
|
$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");
|
$res = $getopts->add ("Help", "?h", array ("help","help2"), "Help of the software");
|
||||||
$this->assertSame (is_object ($res), true);
|
$this->assertSame (is_object ($res), true);
|
||||||
@@ -35,7 +37,7 @@ class getoptsTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_add2 ()
|
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->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 ("Help", "?h", array ("help","help2"), "Help of the software");
|
||||||
$res = $getopts->add ("Debug", "d", "debug", "Debug", "DebugLevel", 2);
|
$res = $getopts->add ("Debug", "d", "debug", "Debug", "DebugLevel", 2);
|
||||||
@@ -45,7 +47,7 @@ class getoptsTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function test_scan1 ()
|
public function test_scan1 ()
|
||||||
{
|
{
|
||||||
$this->expectException ("Exception", "Provided tokens are not known: -f,-o,-o,-o");
|
$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->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 ("Help", "?h", array ("help","help2"), "Help of the software");
|
||||||
$getopts->add ("Debug", "d", "debug", "Debug", "DebugLevel", 2);
|
$getopts->add ("Debug", "d", "debug", "Debug", "DebugLevel", 2);
|
||||||
@@ -55,7 +57,7 @@ class getoptsTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function test_getShort1 ()
|
public function test_getShort1 ()
|
||||||
{
|
{
|
||||||
// One unique value (-h -> true/false)
|
// One unique value (-h -> true/false)
|
||||||
$getopts = new getopts ();
|
$getopts = new Getopts ();
|
||||||
$getopts->simulate ("sim\ ulate -h -d -d ");
|
$getopts->simulate ("sim\ ulate -h -d -d ");
|
||||||
$getopts->add ("Help", "?h", array ("help","help2"), "Help of the software");
|
$getopts->add ("Help", "?h", array ("help","help2"), "Help of the software");
|
||||||
$getopts->add ("Debug", "d", "debug", "Debug", "DebugLevel", 2);
|
$getopts->add ("Debug", "d", "debug", "Debug", "DebugLevel", 2);
|
||||||
@@ -66,7 +68,7 @@ class getoptsTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function test_getShort2 ()
|
public function test_getShort2 ()
|
||||||
{
|
{
|
||||||
// Multiple values, two set (-d -d)
|
// Multiple values, two set (-d -d)
|
||||||
$getopts = new getopts ();
|
$getopts = new Getopts ();
|
||||||
$getopts->simulate ("sim\ ulate -h -d -d ");
|
$getopts->simulate ("sim\ ulate -h -d -d ");
|
||||||
$getopts->add ("Help", "?h", array ("help","help2"), "Help of the software");
|
$getopts->add ("Help", "?h", array ("help","help2"), "Help of the software");
|
||||||
$getopts->add ("Debug", "d", "debug", "Debug", "DebugLevel", 2);
|
$getopts->add ("Debug", "d", "debug", "Debug", "DebugLevel", 2);
|
||||||
@@ -77,7 +79,7 @@ class getoptsTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function test_getShort3 ()
|
public function test_getShort3 ()
|
||||||
{
|
{
|
||||||
// Multiple values, one set (-d)
|
// Multiple values, one set (-d)
|
||||||
$getopts = new getopts ();
|
$getopts = new Getopts ();
|
||||||
$getopts->simulate ("sim\ ulate -h -d ");
|
$getopts->simulate ("sim\ ulate -h -d ");
|
||||||
$getopts->add ("Help", "?h", array ("help","help2"), "Help of the software");
|
$getopts->add ("Help", "?h", array ("help","help2"), "Help of the software");
|
||||||
$getopts->add ("Debug", "d", "debug", "Debug", "DebugLevel", 2);
|
$getopts->add ("Debug", "d", "debug", "Debug", "DebugLevel", 2);
|
||||||
@@ -88,7 +90,7 @@ class getoptsTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function test_getShort4 ()
|
public function test_getShort4 ()
|
||||||
{
|
{
|
||||||
// Multiple values, None set (-d)
|
// Multiple values, None set (-d)
|
||||||
$getopts = new getopts ();
|
$getopts = new Getopts ();
|
||||||
$getopts->simulate ("sim\ ulate -h ");
|
$getopts->simulate ("sim\ ulate -h ");
|
||||||
$getopts->add ("Help", "?h", array ("help","help2"), "Help of the software");
|
$getopts->add ("Help", "?h", array ("help","help2"), "Help of the software");
|
||||||
$getopts->add ("Debug", "d", "debug", "Debug", "DebugLevel", 2);
|
$getopts->add ("Debug", "d", "debug", "Debug", "DebugLevel", 2);
|
||||||
@@ -99,7 +101,7 @@ class getoptsTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function test_getLong1 ()
|
public function test_getLong1 ()
|
||||||
{
|
{
|
||||||
// One unique value (--help -> true/false)
|
// One unique value (--help -> true/false)
|
||||||
$getopts = new getopts ();
|
$getopts = new Getopts ();
|
||||||
$getopts->simulate ("sim\ ulate --help -d -d ");
|
$getopts->simulate ("sim\ ulate --help -d -d ");
|
||||||
$getopts->add ("Help", "?h", array ("help","help2"), "Help of the software");
|
$getopts->add ("Help", "?h", array ("help","help2"), "Help of the software");
|
||||||
$getopts->add ("Debug", "d", "debug", "Debug", "DebugLevel", 2);
|
$getopts->add ("Debug", "d", "debug", "Debug", "DebugLevel", 2);
|
||||||
@@ -110,7 +112,7 @@ class getoptsTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function test_getLong2 ()
|
public function test_getLong2 ()
|
||||||
{
|
{
|
||||||
// Multiple values, two set (-debug --debug)
|
// Multiple values, two set (-debug --debug)
|
||||||
$getopts = new getopts ();
|
$getopts = new Getopts ();
|
||||||
$getopts->simulate ("sim\ ulate -h --debug --debug ");
|
$getopts->simulate ("sim\ ulate -h --debug --debug ");
|
||||||
$getopts->add ("Help", "?h", array ("help","help2"), "Help of the software");
|
$getopts->add ("Help", "?h", array ("help","help2"), "Help of the software");
|
||||||
$getopts->add ("Debug", "d", "debug", "Debug", "DebugLevel", 2);
|
$getopts->add ("Debug", "d", "debug", "Debug", "DebugLevel", 2);
|
||||||
@@ -121,7 +123,7 @@ class getoptsTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function test_getLong3 ()
|
public function test_getLong3 ()
|
||||||
{
|
{
|
||||||
// Multiple values, one set (-d)
|
// Multiple values, one set (-d)
|
||||||
$getopts = new getopts ();
|
$getopts = new Getopts ();
|
||||||
$getopts->simulate ("sim\ ulate --help -d ");
|
$getopts->simulate ("sim\ ulate --help -d ");
|
||||||
$getopts->add ("Help", "?h", array ("help","help2"), "Help of the software");
|
$getopts->add ("Help", "?h", array ("help","help2"), "Help of the software");
|
||||||
$getopts->add ("Debug", "d", "debug", "Debug", "DebugLevel", 2);
|
$getopts->add ("Debug", "d", "debug", "Debug", "DebugLevel", 2);
|
||||||
@@ -132,7 +134,7 @@ class getoptsTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function test_getLong4 ()
|
public function test_getLong4 ()
|
||||||
{
|
{
|
||||||
// Multiple values, None set (-d)
|
// Multiple values, None set (-d)
|
||||||
$getopts = new getopts ();
|
$getopts = new Getopts ();
|
||||||
$getopts->simulate ("sim\ ulate -h");
|
$getopts->simulate ("sim\ ulate -h");
|
||||||
$getopts->add ("Help", "?h", array ("help","help2"), "Help of the software");
|
$getopts->add ("Help", "?h", array ("help","help2"), "Help of the software");
|
||||||
$getopts->add ("Debug", "d", "debug", "Debug", "DebugLevel", 2);
|
$getopts->add ("Debug", "d", "debug", "Debug", "DebugLevel", 2);
|
||||||
@@ -142,7 +144,7 @@ class getoptsTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_restOfLine1 ()
|
public function test_restOfLine1 ()
|
||||||
{
|
{
|
||||||
$getopts = new getopts ();
|
$getopts = new Getopts ();
|
||||||
$getopts->simulate ("sim\ ulate -h -d -d -- -bla final");
|
$getopts->simulate ("sim\ ulate -h -d -d -- -bla final");
|
||||||
$getopts->add ("Help", "?h", array ("help","help2"), "Help of the software");
|
$getopts->add ("Help", "?h", array ("help","help2"), "Help of the software");
|
||||||
$getopts->add ("Debug", "d", "debug", "Debug", "DebugLevel", 2);
|
$getopts->add ("Debug", "d", "debug", "Debug", "DebugLevel", 2);
|
||||||
@@ -152,7 +154,7 @@ class getoptsTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_restOfLine2 ()
|
public function test_restOfLine2 ()
|
||||||
{
|
{
|
||||||
$getopts = new getopts ();
|
$getopts = new Getopts ();
|
||||||
$getopts->simulate ("sim\ ulate bla final");
|
$getopts->simulate ("sim\ ulate bla final");
|
||||||
$getopts->add ("Help", "?h", array ("help","help2"), "Help of the software");
|
$getopts->add ("Help", "?h", array ("help","help2"), "Help of the software");
|
||||||
$getopts->add ("Debug", "d", "debug", "Debug", "DebugLevel", 2);
|
$getopts->add ("Debug", "d", "debug", "Debug", "DebugLevel", 2);
|
||||||
@@ -162,7 +164,7 @@ class getoptsTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_restOfLine3 ()
|
public function test_restOfLine3 ()
|
||||||
{
|
{
|
||||||
$getopts = new getopts ();
|
$getopts = new Getopts ();
|
||||||
$getopts->simulate ("sim\ ulate -- -bla final");
|
$getopts->simulate ("sim\ ulate -- -bla final");
|
||||||
$getopts->add ("Help", "?h", array ("help","help2"), "Help of the software");
|
$getopts->add ("Help", "?h", array ("help","help2"), "Help of the software");
|
||||||
$getopts->add ("Debug", "d", "debug", "Debug", "DebugLevel", 2);
|
$getopts->add ("Debug", "d", "debug", "Debug", "DebugLevel", 2);
|
||||||
@@ -172,7 +174,7 @@ class getoptsTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_programName1 ()
|
public function test_programName1 ()
|
||||||
{
|
{
|
||||||
$getopts = new getopts ();
|
$getopts = new Getopts ();
|
||||||
$getopts->simulate ("sim\ ulate -h -d -d -- -bla final");
|
$getopts->simulate ("sim\ ulate -h -d -d -- -bla final");
|
||||||
$getopts->add ("Help", "?h", array ("help","help2"), "Help of the software");
|
$getopts->add ("Help", "?h", array ("help","help2"), "Help of the software");
|
||||||
$getopts->add ("Debug", "d", "debug", "Debug", "DebugLevel", 2);
|
$getopts->add ("Debug", "d", "debug", "Debug", "DebugLevel", 2);
|
||||||
|
|||||||
@@ -7,14 +7,16 @@
|
|||||||
|
|
||||||
namespace Domframework\Tests;
|
namespace Domframework\Tests;
|
||||||
|
|
||||||
/** Test the http.php file */
|
use Domframework\Http;
|
||||||
class httpTest extends \PHPUnit_Framework_TestCase
|
|
||||||
|
/** Test the Http.php file */
|
||||||
|
class HttpTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
/** bestChoice : exact existing entry
|
/** bestChoice : exact existing entry
|
||||||
*/
|
*/
|
||||||
public function testBestChoice1 ()
|
public function testBestChoice1 ()
|
||||||
{
|
{
|
||||||
$http = new http ();
|
$http = new Http ();
|
||||||
$res = $http->bestChoice (
|
$res = $http->bestChoice (
|
||||||
"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
|
"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
|
||||||
array ("application/xml"), "text/html");
|
array ("application/xml"), "text/html");
|
||||||
@@ -26,7 +28,7 @@ class httpTest extends \PHPUnit_Framework_TestCase
|
|||||||
*/
|
*/
|
||||||
public function testBestChoice2 ()
|
public function testBestChoice2 ()
|
||||||
{
|
{
|
||||||
$http = new http ();
|
$http = new Http ();
|
||||||
$res = $http->bestChoice (
|
$res = $http->bestChoice (
|
||||||
"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
|
"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
|
||||||
array ("text/plain"), "text/html");
|
array ("text/plain"), "text/html");
|
||||||
@@ -37,7 +39,7 @@ class httpTest extends \PHPUnit_Framework_TestCase
|
|||||||
*/
|
*/
|
||||||
public function testBestChoice3 ()
|
public function testBestChoice3 ()
|
||||||
{
|
{
|
||||||
$http = new http ();
|
$http = new Http ();
|
||||||
$res = $http->bestChoice (
|
$res = $http->bestChoice (
|
||||||
"text/html,application/xhtml+xml,application/xml;q=0.9",
|
"text/html,application/xhtml+xml,application/xml;q=0.9",
|
||||||
array ("text/plain"), "text/html");
|
array ("text/plain"), "text/html");
|
||||||
@@ -49,7 +51,7 @@ class httpTest extends \PHPUnit_Framework_TestCase
|
|||||||
*/
|
*/
|
||||||
public function testBestChoice4 ()
|
public function testBestChoice4 ()
|
||||||
{
|
{
|
||||||
$http = new http ();
|
$http = new Http ();
|
||||||
$res = $http->bestChoice (
|
$res = $http->bestChoice (
|
||||||
"text/html,application/xhtml+xml,application/xml;q=0.9,",
|
"text/html,application/xhtml+xml,application/xml;q=0.9,",
|
||||||
array ("text/plain"), "text/html");
|
array ("text/plain"), "text/html");
|
||||||
|
|||||||
@@ -7,19 +7,21 @@
|
|||||||
|
|
||||||
namespace Domframework\Tests;
|
namespace Domframework\Tests;
|
||||||
|
|
||||||
/** Test the outputjson.php file */
|
use Domframework\Inifile;
|
||||||
class inifileTest extends \PHPUnit_Framework_TestCase
|
|
||||||
|
/** Test the Inifile.php file */
|
||||||
|
class InifileTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
public function testsetString001 ()
|
public function testsetString001 ()
|
||||||
{
|
{
|
||||||
$this->setExpectedException ("Exception");
|
$this->setExpectedException ("Exception");
|
||||||
$inifile = new inifile ();
|
$inifile = new Inifile ();
|
||||||
$res = $inifile->setString (1, TRUE);
|
$res = $inifile->setString (1, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testsetString002 ()
|
public function testsetString002 ()
|
||||||
{
|
{
|
||||||
$inifile = new inifile ();
|
$inifile = new Inifile ();
|
||||||
$res = $inifile->setString (array (), TRUE);
|
$res = $inifile->setString (array (), TRUE);
|
||||||
$this->assertSame("", $res);
|
$this->assertSame("", $res);
|
||||||
}
|
}
|
||||||
@@ -28,41 +30,41 @@ class inifileTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function testsetString103 ()
|
public function testsetString103 ()
|
||||||
{
|
{
|
||||||
$this->setExpectedException ("Exception");
|
$this->setExpectedException ("Exception");
|
||||||
$inifile = new inifile ();
|
$inifile = new Inifile ();
|
||||||
$res = $inifile->setString (array ("section1"), TRUE);
|
$res = $inifile->setString (array ("section1"), TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testsetString104 ()
|
public function testsetString104 ()
|
||||||
{
|
{
|
||||||
$inifile = new inifile ();
|
$inifile = new Inifile ();
|
||||||
$res = $inifile->setString (array ("section1"=>array ()), TRUE);
|
$res = $inifile->setString (array ("section1"=>array ()), TRUE);
|
||||||
$this->assertSame("[section1]\n\n", $res);
|
$this->assertSame("[section1]\n\n", $res);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testsetString105 ()
|
public function testsetString105 ()
|
||||||
{
|
{
|
||||||
$inifile = new inifile ();
|
$inifile = new Inifile ();
|
||||||
$res = $inifile->setString (array ("section1"=>array (0)), TRUE);
|
$res = $inifile->setString (array ("section1"=>array (0)), TRUE);
|
||||||
$this->assertSame("[section1]\n0 = \"0\"\n\n", $res);
|
$this->assertSame("[section1]\n0 = \"0\"\n\n", $res);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testsetString106 ()
|
public function testsetString106 ()
|
||||||
{
|
{
|
||||||
$inifile = new inifile ();
|
$inifile = new Inifile ();
|
||||||
$res = $inifile->setString (array ("section1"=>array (0=>1)), TRUE);
|
$res = $inifile->setString (array ("section1"=>array (0=>1)), TRUE);
|
||||||
$this->assertSame("[section1]\n0 = \"1\"\n\n", $res);
|
$this->assertSame("[section1]\n0 = \"1\"\n\n", $res);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testsetString107 ()
|
public function testsetString107 ()
|
||||||
{
|
{
|
||||||
$inifile = new inifile ();
|
$inifile = new Inifile ();
|
||||||
$res = $inifile->setString (array ("section1"=>array (0=>null)), TRUE);
|
$res = $inifile->setString (array ("section1"=>array (0=>null)), TRUE);
|
||||||
$this->assertSame("[section1]\n0 = \"null\"\n\n", $res);
|
$this->assertSame("[section1]\n0 = \"null\"\n\n", $res);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testsetString108 ()
|
public function testsetString108 ()
|
||||||
{
|
{
|
||||||
$inifile = new inifile ();
|
$inifile = new Inifile ();
|
||||||
$res = $inifile->setString (array ("section1"=>array (0=>null, 1=>1)),
|
$res = $inifile->setString (array ("section1"=>array (0=>null, 1=>1)),
|
||||||
TRUE);
|
TRUE);
|
||||||
$this->assertSame("[section1]\n0 = \"null\"\n1 = \"1\"\n\n", $res);
|
$this->assertSame("[section1]\n0 = \"null\"\n1 = \"1\"\n\n", $res);
|
||||||
@@ -70,7 +72,7 @@ class inifileTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function testsetString109 ()
|
public function testsetString109 ()
|
||||||
{
|
{
|
||||||
$inifile = new inifile ();
|
$inifile = new Inifile ();
|
||||||
$res = $inifile->setString (array ("section1"=>array (0=>null,
|
$res = $inifile->setString (array ("section1"=>array (0=>null,
|
||||||
1=>1, 2=>"str")),
|
1=>1, 2=>"str")),
|
||||||
TRUE);
|
TRUE);
|
||||||
@@ -80,7 +82,7 @@ class inifileTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function testsetString110 ()
|
public function testsetString110 ()
|
||||||
{
|
{
|
||||||
$inifile = new inifile ();
|
$inifile = new Inifile ();
|
||||||
$res = $inifile->setString (array ("section1"=>array (0=>null,
|
$res = $inifile->setString (array ("section1"=>array (0=>null,
|
||||||
1=>1, 2=>"str",
|
1=>1, 2=>"str",
|
||||||
3=>array (1,2,3))),
|
3=>array (1,2,3))),
|
||||||
@@ -92,7 +94,7 @@ class inifileTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function testsetString111 ()
|
public function testsetString111 ()
|
||||||
{
|
{
|
||||||
$inifile = new inifile ();
|
$inifile = new Inifile ();
|
||||||
$res = $inifile->setString (array ("section1"=>array (0=>null,
|
$res = $inifile->setString (array ("section1"=>array (0=>null,
|
||||||
1=>1, 2=>"str",
|
1=>1, 2=>"str",
|
||||||
3=>array ())),
|
3=>array ())),
|
||||||
@@ -103,7 +105,7 @@ class inifileTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function testsetString112 ()
|
public function testsetString112 ()
|
||||||
{
|
{
|
||||||
$inifile = new inifile ();
|
$inifile = new Inifile ();
|
||||||
$res = $inifile->setString (array ("section1"=>array (0=>null,
|
$res = $inifile->setString (array ("section1"=>array (0=>null,
|
||||||
1=>1, 2=>"str",
|
1=>1, 2=>"str",
|
||||||
"chain"=>array ("key"=>1,2))),
|
"chain"=>array ("key"=>1,2))),
|
||||||
@@ -116,42 +118,42 @@ class inifileTest extends \PHPUnit_Framework_TestCase
|
|||||||
//// TEST OF THE NOT SECTION PART ////
|
//// TEST OF THE NOT SECTION PART ////
|
||||||
public function testsetString203 ()
|
public function testsetString203 ()
|
||||||
{
|
{
|
||||||
$inifile = new inifile ();
|
$inifile = new Inifile ();
|
||||||
$res = $inifile->setString (array ("section1"), FALSE);
|
$res = $inifile->setString (array ("section1"), FALSE);
|
||||||
$this->assertSame("0 = \"section1\"\n\n", $res);
|
$this->assertSame("0 = \"section1\"\n\n", $res);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testsetString204 ()
|
public function testsetString204 ()
|
||||||
{
|
{
|
||||||
$inifile = new inifile ();
|
$inifile = new Inifile ();
|
||||||
$res = $inifile->setString (array ("section1"=>array ()), FALSE);
|
$res = $inifile->setString (array ("section1"=>array ()), FALSE);
|
||||||
$this->assertSame("\n", $res);
|
$this->assertSame("\n", $res);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testsetString205 ()
|
public function testsetString205 ()
|
||||||
{
|
{
|
||||||
$inifile = new inifile ();
|
$inifile = new Inifile ();
|
||||||
$res = $inifile->setString (array ("section1"=>array (0)), FALSE);
|
$res = $inifile->setString (array ("section1"=>array (0)), FALSE);
|
||||||
$this->assertSame("section1[0] = \"0\"\n\n", $res);
|
$this->assertSame("section1[0] = \"0\"\n\n", $res);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testsetString206 ()
|
public function testsetString206 ()
|
||||||
{
|
{
|
||||||
$inifile = new inifile ();
|
$inifile = new Inifile ();
|
||||||
$res = $inifile->setString (array ("section1"=>array (0=>1)), FALSE);
|
$res = $inifile->setString (array ("section1"=>array (0=>1)), FALSE);
|
||||||
$this->assertSame("section1[0] = \"1\"\n\n", $res);
|
$this->assertSame("section1[0] = \"1\"\n\n", $res);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testsetString207 ()
|
public function testsetString207 ()
|
||||||
{
|
{
|
||||||
$inifile = new inifile ();
|
$inifile = new Inifile ();
|
||||||
$res = $inifile->setString (array ("section1"=>array (0=>null)), FALSE);
|
$res = $inifile->setString (array ("section1"=>array (0=>null)), FALSE);
|
||||||
$this->assertSame("section1[0] = \"null\"\n\n", $res);
|
$this->assertSame("section1[0] = \"null\"\n\n", $res);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testsetString208 ()
|
public function testsetString208 ()
|
||||||
{
|
{
|
||||||
$inifile = new inifile ();
|
$inifile = new Inifile ();
|
||||||
$res = $inifile->setString (array ("section1"=>array (0=>null, 1=>1)),
|
$res = $inifile->setString (array ("section1"=>array (0=>null, 1=>1)),
|
||||||
FALSE);
|
FALSE);
|
||||||
$this->assertSame("section1[0] = \"null\"\nsection1[1] = \"1\"\n\n",
|
$this->assertSame("section1[0] = \"null\"\nsection1[1] = \"1\"\n\n",
|
||||||
@@ -160,7 +162,7 @@ class inifileTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function testsetString209 ()
|
public function testsetString209 ()
|
||||||
{
|
{
|
||||||
$inifile = new inifile ();
|
$inifile = new Inifile ();
|
||||||
$res = $inifile->setString (array ("section1"=>array (0=>null,
|
$res = $inifile->setString (array ("section1"=>array (0=>null,
|
||||||
1=>1, 2=>"str")),
|
1=>1, 2=>"str")),
|
||||||
FALSE);
|
FALSE);
|
||||||
@@ -172,7 +174,7 @@ class inifileTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function testsetString210 ()
|
public function testsetString210 ()
|
||||||
{
|
{
|
||||||
$this->setExpectedException ("Exception");
|
$this->setExpectedException ("Exception");
|
||||||
$inifile = new inifile ();
|
$inifile = new Inifile ();
|
||||||
$res = $inifile->setString (array ("section1"=>array (0=>null,
|
$res = $inifile->setString (array ("section1"=>array (0=>null,
|
||||||
1=>1, 2=>"str",
|
1=>1, 2=>"str",
|
||||||
3=>array (1,2,3))),
|
3=>array (1,2,3))),
|
||||||
@@ -182,7 +184,7 @@ class inifileTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function testsetString211 ()
|
public function testsetString211 ()
|
||||||
{
|
{
|
||||||
$this->setExpectedException ("Exception");
|
$this->setExpectedException ("Exception");
|
||||||
$inifile = new inifile ();
|
$inifile = new Inifile ();
|
||||||
$res = $inifile->setString (array ("section1"=>array (0=>null,
|
$res = $inifile->setString (array ("section1"=>array (0=>null,
|
||||||
1=>1, 2=>"str",
|
1=>1, 2=>"str",
|
||||||
3=>array ())),
|
3=>array ())),
|
||||||
@@ -193,7 +195,7 @@ class inifileTest extends \PHPUnit_Framework_TestCase
|
|||||||
//// LOOP TEST : CREATE AN INI STRING AND PARSE IT ////
|
//// LOOP TEST : CREATE AN INI STRING AND PARSE IT ////
|
||||||
public function testLoop406 ()
|
public function testLoop406 ()
|
||||||
{
|
{
|
||||||
$inifile = new inifile ();
|
$inifile = new Inifile ();
|
||||||
$loop = $inifile->setString (array ("section1"=>array (0=>1)), FALSE);
|
$loop = $inifile->setString (array ("section1"=>array (0=>1)), FALSE);
|
||||||
var_dump ($loop);
|
var_dump ($loop);
|
||||||
$res = $inifile->getString ($loop, FALSE);
|
$res = $inifile->getString ($loop, FALSE);
|
||||||
@@ -203,7 +205,7 @@ var_dump ($res);
|
|||||||
|
|
||||||
public function testLoop407 ()
|
public function testLoop407 ()
|
||||||
{
|
{
|
||||||
$inifile = new inifile ();
|
$inifile = new Inifile ();
|
||||||
$loop = $inifile->setString (array ("section1"=>array (0=>null)), FALSE);
|
$loop = $inifile->setString (array ("section1"=>array (0=>null)), FALSE);
|
||||||
$res = $inifile->getString ($loop, FALSE);
|
$res = $inifile->getString ($loop, FALSE);
|
||||||
$this->assertSame(array ("section1"=>array (0=>null)), $res);
|
$this->assertSame(array ("section1"=>array (0=>null)), $res);
|
||||||
@@ -211,7 +213,7 @@ var_dump ($res);
|
|||||||
|
|
||||||
public function testLoop408 ()
|
public function testLoop408 ()
|
||||||
{
|
{
|
||||||
$inifile = new inifile ();
|
$inifile = new Inifile ();
|
||||||
$loop = $inifile->setString (array ("section1"=>array (0=>"toto")), FALSE);
|
$loop = $inifile->setString (array ("section1"=>array (0=>"toto")), FALSE);
|
||||||
var_dump ($loop);
|
var_dump ($loop);
|
||||||
$res = $inifile->getString ($loop, FALSE);
|
$res = $inifile->getString ($loop, FALSE);
|
||||||
|
|||||||
@@ -7,235 +7,237 @@
|
|||||||
|
|
||||||
namespace Domframework\Tests;
|
namespace Domframework\Tests;
|
||||||
|
|
||||||
/** Test the ipaddresses.php file */
|
use Domframework\Ipaddresses;
|
||||||
class ipaddressesTest extends \PHPUnit_Framework_TestCase
|
|
||||||
|
/** Test the Ipaddresses.php file */
|
||||||
|
class IpaddressesTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
public function test_validIPAddress1 ()
|
public function test_validIPAddress1 ()
|
||||||
{
|
{
|
||||||
$i = new ipaddresses ();
|
$i = new Ipaddresses ();
|
||||||
$res = $i->validIPAddress ("::");
|
$res = $i->validIPAddress ("::");
|
||||||
$this->assertSame (true, $res);
|
$this->assertSame (true, $res);
|
||||||
}
|
}
|
||||||
public function test_validIPAddress2 ()
|
public function test_validIPAddress2 ()
|
||||||
{
|
{
|
||||||
$i = new ipaddresses ();
|
$i = new Ipaddresses ();
|
||||||
$res = $i->validIPAddress ("1::");
|
$res = $i->validIPAddress ("1::");
|
||||||
$this->assertSame (true, $res);
|
$this->assertSame (true, $res);
|
||||||
}
|
}
|
||||||
public function test_validIPAddress3 ()
|
public function test_validIPAddress3 ()
|
||||||
{
|
{
|
||||||
$i = new ipaddresses ();
|
$i = new Ipaddresses ();
|
||||||
$res = $i->validIPAddress ("::1");
|
$res = $i->validIPAddress ("::1");
|
||||||
$this->assertSame (true, $res);
|
$this->assertSame (true, $res);
|
||||||
}
|
}
|
||||||
public function test_validIPAddress4 ()
|
public function test_validIPAddress4 ()
|
||||||
{
|
{
|
||||||
$i = new ipaddresses ();
|
$i = new Ipaddresses ();
|
||||||
$res = $i->validIPAddress ("2001::1");
|
$res = $i->validIPAddress ("2001::1");
|
||||||
$this->assertSame (true, $res);
|
$this->assertSame (true, $res);
|
||||||
}
|
}
|
||||||
public function test_validIPAddress5 ()
|
public function test_validIPAddress5 ()
|
||||||
{
|
{
|
||||||
$i = new ipaddresses ();
|
$i = new Ipaddresses ();
|
||||||
$res = $i->validIPAddress ("1.2.3.4");
|
$res = $i->validIPAddress ("1.2.3.4");
|
||||||
$this->assertSame (true, $res);
|
$this->assertSame (true, $res);
|
||||||
}
|
}
|
||||||
public function test_validIPAddress6 ()
|
public function test_validIPAddress6 ()
|
||||||
{
|
{
|
||||||
$this->setExpectedException ("Exception");
|
$this->setExpectedException ("Exception");
|
||||||
$i = new ipaddresses ();
|
$i = new Ipaddresses ();
|
||||||
$res = $i->validIPAddress ("");
|
$res = $i->validIPAddress ("");
|
||||||
}
|
}
|
||||||
public function test_validIPAddress7 ()
|
public function test_validIPAddress7 ()
|
||||||
{
|
{
|
||||||
$this->setExpectedException ("Exception");
|
$this->setExpectedException ("Exception");
|
||||||
$i = new ipaddresses ();
|
$i = new Ipaddresses ();
|
||||||
$res = $i->validIPAddress (array ());
|
$res = $i->validIPAddress (array ());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_validIPv4Address1 ()
|
public function test_validIPv4Address1 ()
|
||||||
{
|
{
|
||||||
$i = new ipaddresses ();
|
$i = new Ipaddresses ();
|
||||||
$res = $i->validIPv4Address ("::");
|
$res = $i->validIPv4Address ("::");
|
||||||
$this->assertSame (false, $res);
|
$this->assertSame (false, $res);
|
||||||
}
|
}
|
||||||
public function test_validIPv4Address2 ()
|
public function test_validIPv4Address2 ()
|
||||||
{
|
{
|
||||||
$i = new ipaddresses ();
|
$i = new Ipaddresses ();
|
||||||
$res = $i->validIPv4Address ("1.2.3.4");
|
$res = $i->validIPv4Address ("1.2.3.4");
|
||||||
$this->assertSame (true, $res);
|
$this->assertSame (true, $res);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_validIPv6Address1 ()
|
public function test_validIPv6Address1 ()
|
||||||
{
|
{
|
||||||
$i = new ipaddresses ();
|
$i = new Ipaddresses ();
|
||||||
$res = $i->validIPv6Address ("1.2.3.4");
|
$res = $i->validIPv6Address ("1.2.3.4");
|
||||||
$this->assertSame (false, $res);
|
$this->assertSame (false, $res);
|
||||||
}
|
}
|
||||||
public function test_validIPv6Address2 ()
|
public function test_validIPv6Address2 ()
|
||||||
{
|
{
|
||||||
$i = new ipaddresses ();
|
$i = new Ipaddresses ();
|
||||||
$res = $i->validIPv6Address ("::");
|
$res = $i->validIPv6Address ("::");
|
||||||
$this->assertSame (true, $res);
|
$this->assertSame (true, $res);
|
||||||
}
|
}
|
||||||
public function test_validIPv6Address3 ()
|
public function test_validIPv6Address3 ()
|
||||||
{
|
{
|
||||||
$i = new ipaddresses ();
|
$i = new Ipaddresses ();
|
||||||
$res = $i->validIPv6Address ("1::");
|
$res = $i->validIPv6Address ("1::");
|
||||||
$this->assertSame (true, $res);
|
$this->assertSame (true, $res);
|
||||||
}
|
}
|
||||||
public function test_validIPv6Address4 ()
|
public function test_validIPv6Address4 ()
|
||||||
{
|
{
|
||||||
$i = new ipaddresses ();
|
$i = new Ipaddresses ();
|
||||||
$res = $i->validIPv6Address ("::1");
|
$res = $i->validIPv6Address ("::1");
|
||||||
$this->assertSame (true, $res);
|
$this->assertSame (true, $res);
|
||||||
}
|
}
|
||||||
public function test_validIPv6Address5 ()
|
public function test_validIPv6Address5 ()
|
||||||
{
|
{
|
||||||
$i = new ipaddresses ();
|
$i = new Ipaddresses ();
|
||||||
$res = $i->validIPv6Address ("1::1");
|
$res = $i->validIPv6Address ("1::1");
|
||||||
$this->assertSame (true, $res);
|
$this->assertSame (true, $res);
|
||||||
}
|
}
|
||||||
public function test_validIPv6Address6 ()
|
public function test_validIPv6Address6 ()
|
||||||
{
|
{
|
||||||
$i = new ipaddresses ();
|
$i = new Ipaddresses ();
|
||||||
$res = $i->validIPv6Address ("1:1:1");
|
$res = $i->validIPv6Address ("1:1:1");
|
||||||
$this->assertSame (false, $res);
|
$this->assertSame (false, $res);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_validCIDR1 ()
|
public function test_validCIDR1 ()
|
||||||
{
|
{
|
||||||
$i = new ipaddresses ();
|
$i = new Ipaddresses ();
|
||||||
$res = $i->validCIDR (-1);
|
$res = $i->validCIDR (-1);
|
||||||
$this->assertSame (false, $res);
|
$this->assertSame (false, $res);
|
||||||
}
|
}
|
||||||
public function test_validCIDR2 ()
|
public function test_validCIDR2 ()
|
||||||
{
|
{
|
||||||
$i = new ipaddresses ();
|
$i = new Ipaddresses ();
|
||||||
$res = $i->validCIDR (129);
|
$res = $i->validCIDR (129);
|
||||||
$this->assertSame (false, $res);
|
$this->assertSame (false, $res);
|
||||||
}
|
}
|
||||||
public function test_validCIDR3 ()
|
public function test_validCIDR3 ()
|
||||||
{
|
{
|
||||||
$i = new ipaddresses ();
|
$i = new Ipaddresses ();
|
||||||
$res = $i->validCIDR (128);
|
$res = $i->validCIDR (128);
|
||||||
$this->assertSame (true, $res);
|
$this->assertSame (true, $res);
|
||||||
}
|
}
|
||||||
public function test_validCIDR4 ()
|
public function test_validCIDR4 ()
|
||||||
{
|
{
|
||||||
$i = new ipaddresses ();
|
$i = new Ipaddresses ();
|
||||||
$res = $i->validCIDR (0);
|
$res = $i->validCIDR (0);
|
||||||
$this->assertSame (true, $res);
|
$this->assertSame (true, $res);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_validIPv4CIDR1 ()
|
public function test_validIPv4CIDR1 ()
|
||||||
{
|
{
|
||||||
$i = new ipaddresses ();
|
$i = new Ipaddresses ();
|
||||||
$res = $i->validIPv4CIDR (-1);
|
$res = $i->validIPv4CIDR (-1);
|
||||||
$this->assertSame (false, $res);
|
$this->assertSame (false, $res);
|
||||||
}
|
}
|
||||||
public function test_validIPv4CIDR2 ()
|
public function test_validIPv4CIDR2 ()
|
||||||
{
|
{
|
||||||
$i = new ipaddresses ();
|
$i = new Ipaddresses ();
|
||||||
$res = $i->validIPv4CIDR (33);
|
$res = $i->validIPv4CIDR (33);
|
||||||
$this->assertSame (false, $res);
|
$this->assertSame (false, $res);
|
||||||
}
|
}
|
||||||
public function test_validIPv4CIDR3 ()
|
public function test_validIPv4CIDR3 ()
|
||||||
{
|
{
|
||||||
$i = new ipaddresses ();
|
$i = new Ipaddresses ();
|
||||||
$res = $i->validIPv4CIDR (32);
|
$res = $i->validIPv4CIDR (32);
|
||||||
$this->assertSame (true, $res);
|
$this->assertSame (true, $res);
|
||||||
}
|
}
|
||||||
public function test_validIPv4CIDR4 ()
|
public function test_validIPv4CIDR4 ()
|
||||||
{
|
{
|
||||||
$i = new ipaddresses ();
|
$i = new Ipaddresses ();
|
||||||
$res = $i->validIPv4CIDR (0);
|
$res = $i->validIPv4CIDR (0);
|
||||||
$this->assertSame (true, $res);
|
$this->assertSame (true, $res);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_validIPv6CIDR1 ()
|
public function test_validIPv6CIDR1 ()
|
||||||
{
|
{
|
||||||
$i = new ipaddresses ();
|
$i = new Ipaddresses ();
|
||||||
$res = $i->validIPv6CIDR (-1);
|
$res = $i->validIPv6CIDR (-1);
|
||||||
$this->assertSame (false, $res);
|
$this->assertSame (false, $res);
|
||||||
}
|
}
|
||||||
public function test_validIPv6CIDR2 ()
|
public function test_validIPv6CIDR2 ()
|
||||||
{
|
{
|
||||||
$i = new ipaddresses ();
|
$i = new Ipaddresses ();
|
||||||
$res = $i->validIPv6CIDR (129);
|
$res = $i->validIPv6CIDR (129);
|
||||||
$this->assertSame (false, $res);
|
$this->assertSame (false, $res);
|
||||||
}
|
}
|
||||||
public function test_validIPv6CIDR3 ()
|
public function test_validIPv6CIDR3 ()
|
||||||
{
|
{
|
||||||
$i = new ipaddresses ();
|
$i = new Ipaddresses ();
|
||||||
$res = $i->validIPv6CIDR (128);
|
$res = $i->validIPv6CIDR (128);
|
||||||
$this->assertSame (true, $res);
|
$this->assertSame (true, $res);
|
||||||
}
|
}
|
||||||
public function test_validIPv6CIDR4 ()
|
public function test_validIPv6CIDR4 ()
|
||||||
{
|
{
|
||||||
$i = new ipaddresses ();
|
$i = new Ipaddresses ();
|
||||||
$res = $i->validIPv6CIDR (0);
|
$res = $i->validIPv6CIDR (0);
|
||||||
$this->assertSame (true, $res);
|
$this->assertSame (true, $res);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_compressIP1 ()
|
public function test_compressIP1 ()
|
||||||
{
|
{
|
||||||
$i = new ipaddresses ();
|
$i = new Ipaddresses ();
|
||||||
$res = $i->compressIP ("::");
|
$res = $i->compressIP ("::");
|
||||||
$this->assertSame ("::", $res);
|
$this->assertSame ("::", $res);
|
||||||
}
|
}
|
||||||
public function test_compressIP2 ()
|
public function test_compressIP2 ()
|
||||||
{
|
{
|
||||||
$i = new ipaddresses ();
|
$i = new Ipaddresses ();
|
||||||
$res = $i->compressIP ("::1");
|
$res = $i->compressIP ("::1");
|
||||||
$this->assertSame ("::1", $res);
|
$this->assertSame ("::1", $res);
|
||||||
}
|
}
|
||||||
public function test_compressIP3 ()
|
public function test_compressIP3 ()
|
||||||
{
|
{
|
||||||
$i = new ipaddresses ();
|
$i = new Ipaddresses ();
|
||||||
$res = $i->compressIP ("2::1");
|
$res = $i->compressIP ("2::1");
|
||||||
$this->assertSame ("2::1", $res);
|
$this->assertSame ("2::1", $res);
|
||||||
}
|
}
|
||||||
public function test_compressIP4 ()
|
public function test_compressIP4 ()
|
||||||
{
|
{
|
||||||
$i = new ipaddresses ();
|
$i = new Ipaddresses ();
|
||||||
$res = $i->compressIP ("2::");
|
$res = $i->compressIP ("2::");
|
||||||
$this->assertSame ("2::", $res);
|
$this->assertSame ("2::", $res);
|
||||||
}
|
}
|
||||||
public function test_compressIP5 ()
|
public function test_compressIP5 ()
|
||||||
{
|
{
|
||||||
$i = new ipaddresses ();
|
$i = new Ipaddresses ();
|
||||||
$res = $i->compressIP ("2:1:0:3::0:1");
|
$res = $i->compressIP ("2:1:0:3::0:1");
|
||||||
$this->assertSame ("2:1:0:3::1", $res);
|
$this->assertSame ("2:1:0:3::1", $res);
|
||||||
}
|
}
|
||||||
public function test_compressIP6 ()
|
public function test_compressIP6 ()
|
||||||
{
|
{
|
||||||
$i = new ipaddresses ();
|
$i = new Ipaddresses ();
|
||||||
$res = $i->compressIP ("2:1:0:3:0000::1");
|
$res = $i->compressIP ("2:1:0:3:0000::1");
|
||||||
$this->assertSame ("2:1:0:3::1", $res);
|
$this->assertSame ("2:1:0:3::1", $res);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_uncompressIPv6a ()
|
public function test_uncompressIPv6a ()
|
||||||
{
|
{
|
||||||
$i = new ipaddresses ();
|
$i = new Ipaddresses ();
|
||||||
$res = $i->uncompressIPv6 ("1::1");
|
$res = $i->uncompressIPv6 ("1::1");
|
||||||
$this->assertSame ("1:0:0:0:0:0:0:1", $res);
|
$this->assertSame ("1:0:0:0:0:0:0:1", $res);
|
||||||
}
|
}
|
||||||
public function test_uncompressIPv6b ()
|
public function test_uncompressIPv6b ()
|
||||||
{
|
{
|
||||||
$i = new ipaddresses ();
|
$i = new Ipaddresses ();
|
||||||
$res = $i->uncompressIPv6 ("1::");
|
$res = $i->uncompressIPv6 ("1::");
|
||||||
$this->assertSame ("1:0:0:0:0:0:0:0", $res);
|
$this->assertSame ("1:0:0:0:0:0:0:0", $res);
|
||||||
}
|
}
|
||||||
public function test_uncompressIPv6c ()
|
public function test_uncompressIPv6c ()
|
||||||
{
|
{
|
||||||
$i = new ipaddresses ();
|
$i = new Ipaddresses ();
|
||||||
$res = $i->uncompressIPv6 ("::");
|
$res = $i->uncompressIPv6 ("::");
|
||||||
$this->assertSame ("0:0:0:0:0:0:0:0", $res);
|
$this->assertSame ("0:0:0:0:0:0:0:0", $res);
|
||||||
}
|
}
|
||||||
public function test_uncompressIPv6d ()
|
public function test_uncompressIPv6d ()
|
||||||
{
|
{
|
||||||
$i = new ipaddresses ();
|
$i = new Ipaddresses ();
|
||||||
$res = $i->uncompressIPv6 ("1.2.3.4");
|
$res = $i->uncompressIPv6 ("1.2.3.4");
|
||||||
$this->assertSame ("1.2.3.4", $res);
|
$this->assertSame ("1.2.3.4", $res);
|
||||||
}
|
}
|
||||||
@@ -243,12 +245,12 @@ class ipaddressesTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function test_groupIPv6a ()
|
public function test_groupIPv6a ()
|
||||||
{
|
{
|
||||||
$this->setExpectedException ("Exception");
|
$this->setExpectedException ("Exception");
|
||||||
$i = new ipaddresses ();
|
$i = new Ipaddresses ();
|
||||||
$res = $i->groupIPv6 ("1.2.3.4");
|
$res = $i->groupIPv6 ("1.2.3.4");
|
||||||
}
|
}
|
||||||
public function test_groupIPv6b ()
|
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.".
|
$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");
|
"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);
|
$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 ()
|
public function test_completeAddressWithZero1 ()
|
||||||
{
|
{
|
||||||
$i = new ipaddresses ();
|
$i = new Ipaddresses ();
|
||||||
$res = $i->completeAddressWithZero ("::");
|
$res = $i->completeAddressWithZero ("::");
|
||||||
$this->assertSame ("0000:0000:0000:0000:0000:0000:0000:0000", $res);
|
$this->assertSame ("0000:0000:0000:0000:0000:0000:0000:0000", $res);
|
||||||
}
|
}
|
||||||
public function test_completeAddressWithZero2 ()
|
public function test_completeAddressWithZero2 ()
|
||||||
{
|
{
|
||||||
$i = new ipaddresses ();
|
$i = new Ipaddresses ();
|
||||||
$res = $i->completeAddressWithZero ("::1");
|
$res = $i->completeAddressWithZero ("::1");
|
||||||
$this->assertSame ("0000:0000:0000:0000:0000:0000:0000:0001", $res);
|
$this->assertSame ("0000:0000:0000:0000:0000:0000:0000:0001", $res);
|
||||||
}
|
}
|
||||||
public function test_completeAddressWithZero3 ()
|
public function test_completeAddressWithZero3 ()
|
||||||
{
|
{
|
||||||
$i = new ipaddresses ();
|
$i = new Ipaddresses ();
|
||||||
$res = $i->completeAddressWithZero ("1::");
|
$res = $i->completeAddressWithZero ("1::");
|
||||||
$this->assertSame ("0001:0000:0000:0000:0000:0000:0000:0000", $res);
|
$this->assertSame ("0001:0000:0000:0000:0000:0000:0000:0000", $res);
|
||||||
}
|
}
|
||||||
public function test_completeAddressWithZero4 ()
|
public function test_completeAddressWithZero4 ()
|
||||||
{
|
{
|
||||||
$i = new ipaddresses ();
|
$i = new Ipaddresses ();
|
||||||
$res = $i->completeAddressWithZero ("1::1");
|
$res = $i->completeAddressWithZero ("1::1");
|
||||||
$this->assertSame ("0001:0000:0000:0000:0000:0000:0000:0001", $res);
|
$this->assertSame ("0001:0000:0000:0000:0000:0000:0000:0001", $res);
|
||||||
}
|
}
|
||||||
public function test_completeAddressWithZero5 ()
|
public function test_completeAddressWithZero5 ()
|
||||||
{
|
{
|
||||||
$i = new ipaddresses ();
|
$i = new Ipaddresses ();
|
||||||
$res = $i->completeAddressWithZero ("1:222::1");
|
$res = $i->completeAddressWithZero ("1:222::1");
|
||||||
$this->assertSame ("0001:0222:0000:0000:0000:0000:0000:0001", $res);
|
$this->assertSame ("0001:0222:0000:0000:0000:0000:0000:0001", $res);
|
||||||
}
|
}
|
||||||
public function test_completeAddressWithZero6 ()
|
public function test_completeAddressWithZero6 ()
|
||||||
{
|
{
|
||||||
$i = new ipaddresses ();
|
$i = new Ipaddresses ();
|
||||||
$res = $i->completeAddressWithZero ("1.2.3.4");
|
$res = $i->completeAddressWithZero ("1.2.3.4");
|
||||||
$this->assertSame ("1.2.3.4", $res);
|
$this->assertSame ("1.2.3.4", $res);
|
||||||
}
|
}
|
||||||
@@ -296,31 +298,31 @@ class ipaddressesTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_reverseIPAddress1 ()
|
public function test_reverseIPAddress1 ()
|
||||||
{
|
{
|
||||||
$i = new ipaddresses ();
|
$i = new Ipaddresses ();
|
||||||
$res = $i->reverseIPAddress ("1.2.3.4");
|
$res = $i->reverseIPAddress ("1.2.3.4");
|
||||||
$this->assertSame ("4.3.2.1", $res);
|
$this->assertSame ("4.3.2.1", $res);
|
||||||
}
|
}
|
||||||
public function test_reverseIPAddress2 ()
|
public function test_reverseIPAddress2 ()
|
||||||
{
|
{
|
||||||
$i = new ipaddresses ();
|
$i = new Ipaddresses ();
|
||||||
$res = $i->reverseIPAddress ("::");
|
$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);
|
$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 ()
|
public function test_reverseIPAddress3 ()
|
||||||
{
|
{
|
||||||
$i = new ipaddresses ();
|
$i = new Ipaddresses ();
|
||||||
$res = $i->reverseIPAddress ("::1");
|
$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);
|
$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 ()
|
public function test_reverseIPAddress4 ()
|
||||||
{
|
{
|
||||||
$i = new ipaddresses ();
|
$i = new Ipaddresses ();
|
||||||
$res = $i->reverseIPAddress ("2::1");
|
$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);
|
$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 ()
|
public function test_reverseIPAddress5 ()
|
||||||
{
|
{
|
||||||
$i = new ipaddresses ();
|
$i = new Ipaddresses ();
|
||||||
$res = $i->reverseIPAddress ("2::abcd:1");
|
$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);
|
$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 ()
|
public function test_netmask2cidr1 ()
|
||||||
{
|
{
|
||||||
$this->setExpectedException ("Exception");
|
$this->setExpectedException ("Exception");
|
||||||
$i = new ipaddresses ();
|
$i = new Ipaddresses ();
|
||||||
$res = $i->netmask2cidr (0);
|
$res = $i->netmask2cidr (0);
|
||||||
}
|
}
|
||||||
public function test_netmask2cidr2 ()
|
public function test_netmask2cidr2 ()
|
||||||
{
|
{
|
||||||
$i = new ipaddresses ();
|
$i = new Ipaddresses ();
|
||||||
$res = $i->netmask2cidr ("255.255.255.0");
|
$res = $i->netmask2cidr ("255.255.255.0");
|
||||||
$this->assertSame (24, $res);
|
$this->assertSame (24, $res);
|
||||||
}
|
}
|
||||||
public function test_netmask2cidr3 ()
|
public function test_netmask2cidr3 ()
|
||||||
{
|
{
|
||||||
$i = new ipaddresses ();
|
$i = new Ipaddresses ();
|
||||||
$res = $i->netmask2cidr ("255.255.255.255");
|
$res = $i->netmask2cidr ("255.255.255.255");
|
||||||
$this->assertSame (32, $res);
|
$this->assertSame (32, $res);
|
||||||
}
|
}
|
||||||
public function test_netmask2cidr4 ()
|
public function test_netmask2cidr4 ()
|
||||||
{
|
{
|
||||||
$i = new ipaddresses ();
|
$i = new Ipaddresses ();
|
||||||
$res = $i->netmask2cidr ("255.255.255.255");
|
$res = $i->netmask2cidr ("255.255.255.255");
|
||||||
$this->assertSame (32, $res);
|
$this->assertSame (32, $res);
|
||||||
}
|
}
|
||||||
public function test_netmask2cidr5 ()
|
public function test_netmask2cidr5 ()
|
||||||
{
|
{
|
||||||
$i = new ipaddresses ();
|
$i = new Ipaddresses ();
|
||||||
$res = $i->netmask2cidr ("255.0.0.0");
|
$res = $i->netmask2cidr ("255.0.0.0");
|
||||||
$this->assertSame (8, $res);
|
$this->assertSame (8, $res);
|
||||||
}
|
}
|
||||||
public function test_netmask2cidr6 ()
|
public function test_netmask2cidr6 ()
|
||||||
{
|
{
|
||||||
$i = new ipaddresses ();
|
$i = new Ipaddresses ();
|
||||||
$res = $i->netmask2cidr ("127.0.0.0");
|
$res = $i->netmask2cidr ("127.0.0.0");
|
||||||
$this->assertSame (false, $res);
|
$this->assertSame (false, $res);
|
||||||
}
|
}
|
||||||
public function test_netmask2cidr7 ()
|
public function test_netmask2cidr7 ()
|
||||||
{
|
{
|
||||||
$i = new ipaddresses ();
|
$i = new Ipaddresses ();
|
||||||
$res = $i->netmask2cidr ("63.0.0.0");
|
$res = $i->netmask2cidr ("63.0.0.0");
|
||||||
$this->assertSame (false, $res);
|
$this->assertSame (false, $res);
|
||||||
}
|
}
|
||||||
public function test_netmask2cidr8 ()
|
public function test_netmask2cidr8 ()
|
||||||
{
|
{
|
||||||
$i = new ipaddresses ();
|
$i = new Ipaddresses ();
|
||||||
$res = $i->netmask2cidr ("155.0.0.0");
|
$res = $i->netmask2cidr ("155.0.0.0");
|
||||||
$this->assertSame (false, $res);
|
$this->assertSame (false, $res);
|
||||||
}
|
}
|
||||||
public function test_netmask2cidr9 ()
|
public function test_netmask2cidr9 ()
|
||||||
{
|
{
|
||||||
$i = new ipaddresses ();
|
$i = new Ipaddresses ();
|
||||||
$res = $i->netmask2cidr ("0.0.0.255");
|
$res = $i->netmask2cidr ("0.0.0.255");
|
||||||
$this->assertSame (false, $res);
|
$this->assertSame (false, $res);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_netmask2cidrWildcard_1 ()
|
public function test_netmask2cidrWildcard_1 ()
|
||||||
{
|
{
|
||||||
$i = new ipaddresses ();
|
$i = new Ipaddresses ();
|
||||||
$res = $i->netmask2cidr ("255.255.255.0", false);
|
$res = $i->netmask2cidr ("255.255.255.0", false);
|
||||||
$this->assertSame (false, $res);
|
$this->assertSame (false, $res);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_netmask2cidrWildcard_2 ()
|
public function test_netmask2cidrWildcard_2 ()
|
||||||
{
|
{
|
||||||
$i = new ipaddresses ();
|
$i = new Ipaddresses ();
|
||||||
$res = $i->netmask2cidr ("0.0.0.0", false);
|
$res = $i->netmask2cidr ("0.0.0.0", false);
|
||||||
$this->assertSame (32, $res);
|
$this->assertSame (32, $res);
|
||||||
}
|
}
|
||||||
public function test_netmask2cidrWildcard_3 ()
|
public function test_netmask2cidrWildcard_3 ()
|
||||||
{
|
{
|
||||||
$i = new ipaddresses ();
|
$i = new Ipaddresses ();
|
||||||
$res = $i->netmask2cidr ("255.255.255.255", false);
|
$res = $i->netmask2cidr ("255.255.255.255", false);
|
||||||
$this->assertSame (0, $res);
|
$this->assertSame (0, $res);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_cidr2netmask_1 ()
|
public function test_cidr2netmask_1 ()
|
||||||
{
|
{
|
||||||
$i = new ipaddresses ();
|
$i = new Ipaddresses ();
|
||||||
$res = $i->cidr2netmask (0, true);
|
$res = $i->cidr2netmask (0, true);
|
||||||
$this->assertSame ("0.0.0.0", $res);
|
$this->assertSame ("0.0.0.0", $res);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_cidr2netmask_2 ()
|
public function test_cidr2netmask_2 ()
|
||||||
{
|
{
|
||||||
$i = new ipaddresses ();
|
$i = new Ipaddresses ();
|
||||||
$res = $i->cidr2netmask (24, true);
|
$res = $i->cidr2netmask (24, true);
|
||||||
$this->assertSame ("255.255.255.0", $res);
|
$this->assertSame ("255.255.255.0", $res);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_cidr2netmask_3 ()
|
public function test_cidr2netmask_3 ()
|
||||||
{
|
{
|
||||||
$i = new ipaddresses ();
|
$i = new Ipaddresses ();
|
||||||
$res = $i->cidr2netmask (25, true);
|
$res = $i->cidr2netmask (25, true);
|
||||||
$this->assertSame ("255.255.255.128", $res);
|
$this->assertSame ("255.255.255.128", $res);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_cidr2netmask_4 ()
|
public function test_cidr2netmask_4 ()
|
||||||
{
|
{
|
||||||
$i = new ipaddresses ();
|
$i = new Ipaddresses ();
|
||||||
$res = $i->cidr2netmask (32, true);
|
$res = $i->cidr2netmask (32, true);
|
||||||
$this->assertSame ("255.255.255.255", $res);
|
$this->assertSame ("255.255.255.255", $res);
|
||||||
}
|
}
|
||||||
public function test_cidr2netmask_5 ()
|
public function test_cidr2netmask_5 ()
|
||||||
{
|
{
|
||||||
$i = new ipaddresses ();
|
$i = new Ipaddresses ();
|
||||||
$res = $i->cidr2netmask (1, true);
|
$res = $i->cidr2netmask (1, true);
|
||||||
$this->assertSame ("128.0.0.0", $res);
|
$this->assertSame ("128.0.0.0", $res);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_ipInNetwork1 ()
|
public function test_ipInNetwork1 ()
|
||||||
{
|
{
|
||||||
$i = new ipaddresses ();
|
$i = new Ipaddresses ();
|
||||||
$res = $i->ipInNetwork ("127.0.0.1", "127.1.0.0", 8);
|
$res = $i->ipInNetwork ("127.0.0.1", "127.1.0.0", 8);
|
||||||
$this->assertSame (true, $res);
|
$this->assertSame (true, $res);
|
||||||
}
|
}
|
||||||
public function test_ipInNetwork2 ()
|
public function test_ipInNetwork2 ()
|
||||||
{
|
{
|
||||||
$i = new ipaddresses ();
|
$i = new Ipaddresses ();
|
||||||
$res = $i->ipInNetwork ("192.168.1.1", "127.1.0.0", 8);
|
$res = $i->ipInNetwork ("192.168.1.1", "127.1.0.0", 8);
|
||||||
$this->assertSame (false, $res);
|
$this->assertSame (false, $res);
|
||||||
}
|
}
|
||||||
public function test_ipInNetwork3 ()
|
public function test_ipInNetwork3 ()
|
||||||
{
|
{
|
||||||
$i = new ipaddresses ();
|
$i = new Ipaddresses ();
|
||||||
$res = $i->ipInNetwork ("2001:660:530d:201::1", "2001:660:530d:201::", 64);
|
$res = $i->ipInNetwork ("2001:660:530d:201::1", "2001:660:530d:201::", 64);
|
||||||
$this->assertSame (true, $res);
|
$this->assertSame (true, $res);
|
||||||
}
|
}
|
||||||
public function test_ipInNetwork4 ()
|
public function test_ipInNetwork4 ()
|
||||||
{
|
{
|
||||||
$i = new ipaddresses ();
|
$i = new Ipaddresses ();
|
||||||
$res = $i->ipInNetwork ("2001:660:530d:203::1", "2001:660:530d:201::", 64);
|
$res = $i->ipInNetwork ("2001:660:530d:203::1", "2001:660:530d:201::", 64);
|
||||||
$this->assertSame (false, $res);
|
$this->assertSame (false, $res);
|
||||||
}
|
}
|
||||||
public function test_ipInNetwork5 ()
|
public function test_ipInNetwork5 ()
|
||||||
{
|
{
|
||||||
$i = new ipaddresses ();
|
$i = new Ipaddresses ();
|
||||||
$res = $i->ipInNetwork ("2001:660:530d:203::1", "2001::", 0);
|
$res = $i->ipInNetwork ("2001:660:530d:203::1", "2001::", 0);
|
||||||
$this->assertSame (true, $res);
|
$this->assertSame (true, $res);
|
||||||
}
|
}
|
||||||
public function test_ipInNetwork6 ()
|
public function test_ipInNetwork6 ()
|
||||||
{
|
{
|
||||||
$i = new ipaddresses ();
|
$i = new Ipaddresses ();
|
||||||
$res = $i->ipInNetwork ("192.168.1.1", "127.0.0.0", 0);
|
$res = $i->ipInNetwork ("192.168.1.1", "127.0.0.0", 0);
|
||||||
$this->assertSame (true, $res);
|
$this->assertSame (true, $res);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_networkFirstIP1 ()
|
public function test_networkFirstIP1 ()
|
||||||
{
|
{
|
||||||
$i = new ipaddresses ();
|
$i = new Ipaddresses ();
|
||||||
$res = $i->networkFirstIP ("192.168.1.21", 24);
|
$res = $i->networkFirstIP ("192.168.1.21", 24);
|
||||||
$this->assertSame ($res, "192.168.1.0");
|
$this->assertSame ($res, "192.168.1.0");
|
||||||
}
|
}
|
||||||
public function test_networkFirstIP2 ()
|
public function test_networkFirstIP2 ()
|
||||||
{
|
{
|
||||||
$i = new ipaddresses ();
|
$i = new Ipaddresses ();
|
||||||
$res = $i->networkFirstIP ("192.168.1.21", 0);
|
$res = $i->networkFirstIP ("192.168.1.21", 0);
|
||||||
$this->assertSame ($res, "0.0.0.0");
|
$this->assertSame ($res, "0.0.0.0");
|
||||||
}
|
}
|
||||||
public function test_networkFirstIP3 ()
|
public function test_networkFirstIP3 ()
|
||||||
{
|
{
|
||||||
$i = new ipaddresses ();
|
$i = new Ipaddresses ();
|
||||||
$res = $i->networkFirstIP ("192.168.1.21", 32);
|
$res = $i->networkFirstIP ("192.168.1.21", 32);
|
||||||
$this->assertSame ($res, "192.168.1.21");
|
$this->assertSame ($res, "192.168.1.21");
|
||||||
}
|
}
|
||||||
public function test_networkFirstIP4 ()
|
public function test_networkFirstIP4 ()
|
||||||
{
|
{
|
||||||
$i = new ipaddresses ();
|
$i = new Ipaddresses ();
|
||||||
$res = $i->networkFirstIP ("192.168.1.21", 31);
|
$res = $i->networkFirstIP ("192.168.1.21", 31);
|
||||||
$this->assertSame ($res, "192.168.1.20");
|
$this->assertSame ($res, "192.168.1.20");
|
||||||
}
|
}
|
||||||
public function test_networkFirstIP5 ()
|
public function test_networkFirstIP5 ()
|
||||||
{
|
{
|
||||||
$i = new ipaddresses ();
|
$i = new Ipaddresses ();
|
||||||
$res = $i->networkFirstIP ("2001:660:530d:201::125", 64);
|
$res = $i->networkFirstIP ("2001:660:530d:201::125", 64);
|
||||||
$this->assertSame ($res, "2001:660:530d:201::");
|
$this->assertSame ($res, "2001:660:530d:201::");
|
||||||
}
|
}
|
||||||
public function test_networkFirstIP6 ()
|
public function test_networkFirstIP6 ()
|
||||||
{
|
{
|
||||||
$i = new ipaddresses ();
|
$i = new Ipaddresses ();
|
||||||
$res = $i->networkFirstIP ("2001:660:530d:201::125", 0);
|
$res = $i->networkFirstIP ("2001:660:530d:201::125", 0);
|
||||||
$this->assertSame ($res, "::");
|
$this->assertSame ($res, "::");
|
||||||
}
|
}
|
||||||
public function test_networkFirstIP7 ()
|
public function test_networkFirstIP7 ()
|
||||||
{
|
{
|
||||||
$i = new ipaddresses ();
|
$i = new Ipaddresses ();
|
||||||
$res = $i->networkFirstIP ("2001:660:530d:201::125", 128);
|
$res = $i->networkFirstIP ("2001:660:530d:201::125", 128);
|
||||||
$this->assertSame ($res, "2001:660:530d:201::125");
|
$this->assertSame ($res, "2001:660:530d:201::125");
|
||||||
}
|
}
|
||||||
public function test_networkFirstIP8 ()
|
public function test_networkFirstIP8 ()
|
||||||
{
|
{
|
||||||
$i = new ipaddresses ();
|
$i = new Ipaddresses ();
|
||||||
$res = $i->networkFirstIP ("2001:660:530d:201::125", 127);
|
$res = $i->networkFirstIP ("2001:660:530d:201::125", 127);
|
||||||
$this->assertSame ($res, "2001:660:530d:201::124");
|
$this->assertSame ($res, "2001:660:530d:201::124");
|
||||||
}
|
}
|
||||||
public function test_networkLastIP1 ()
|
public function test_networkLastIP1 ()
|
||||||
{
|
{
|
||||||
$i = new ipaddresses ();
|
$i = new Ipaddresses ();
|
||||||
$res = $i->networkLastIP ("192.168.1.21", 24);
|
$res = $i->networkLastIP ("192.168.1.21", 24);
|
||||||
$this->assertSame ($res, "192.168.1.255");
|
$this->assertSame ($res, "192.168.1.255");
|
||||||
}
|
}
|
||||||
public function test_networkLastIP2 ()
|
public function test_networkLastIP2 ()
|
||||||
{
|
{
|
||||||
$i = new ipaddresses ();
|
$i = new Ipaddresses ();
|
||||||
$res = $i->networkLastIP ("192.168.1.21", 0);
|
$res = $i->networkLastIP ("192.168.1.21", 0);
|
||||||
$this->assertSame ($res, "255.255.255.255");
|
$this->assertSame ($res, "255.255.255.255");
|
||||||
}
|
}
|
||||||
public function test_networkLastIP3 ()
|
public function test_networkLastIP3 ()
|
||||||
{
|
{
|
||||||
$i = new ipaddresses ();
|
$i = new Ipaddresses ();
|
||||||
$res = $i->networkLastIP ("192.168.1.21", 32);
|
$res = $i->networkLastIP ("192.168.1.21", 32);
|
||||||
$this->assertSame ($res, "192.168.1.21");
|
$this->assertSame ($res, "192.168.1.21");
|
||||||
}
|
}
|
||||||
public function test_networkLastIP4 ()
|
public function test_networkLastIP4 ()
|
||||||
{
|
{
|
||||||
$i = new ipaddresses ();
|
$i = new Ipaddresses ();
|
||||||
$res = $i->networkLastIP ("192.168.1.21", 31);
|
$res = $i->networkLastIP ("192.168.1.21", 31);
|
||||||
$this->assertSame ($res, "192.168.1.21");
|
$this->assertSame ($res, "192.168.1.21");
|
||||||
}
|
}
|
||||||
public function test_networkLastIP5 ()
|
public function test_networkLastIP5 ()
|
||||||
{
|
{
|
||||||
$i = new ipaddresses ();
|
$i = new Ipaddresses ();
|
||||||
$res = $i->networkLastIP ("2001:660:530d:201::125", 64);
|
$res = $i->networkLastIP ("2001:660:530d:201::125", 64);
|
||||||
$this->assertSame ($res, "2001:660:530d:201:ffff:ffff:ffff:ffff");
|
$this->assertSame ($res, "2001:660:530d:201:ffff:ffff:ffff:ffff");
|
||||||
}
|
}
|
||||||
public function test_networkLastIP6 ()
|
public function test_networkLastIP6 ()
|
||||||
{
|
{
|
||||||
$i = new ipaddresses ();
|
$i = new Ipaddresses ();
|
||||||
$res = $i->networkLastIP ("2001:660:530d:201::125", 0);
|
$res = $i->networkLastIP ("2001:660:530d:201::125", 0);
|
||||||
$this->assertSame ($res, "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff");
|
$this->assertSame ($res, "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff");
|
||||||
}
|
}
|
||||||
public function test_networkLastIP7 ()
|
public function test_networkLastIP7 ()
|
||||||
{
|
{
|
||||||
$i = new ipaddresses ();
|
$i = new Ipaddresses ();
|
||||||
$res = $i->networkLastIP ("2001:660:530d:201::125", 128);
|
$res = $i->networkLastIP ("2001:660:530d:201::125", 128);
|
||||||
$this->assertSame ($res, "2001:660:530d:201::125");
|
$this->assertSame ($res, "2001:660:530d:201::125");
|
||||||
}
|
}
|
||||||
public function test_networkLastIP8 ()
|
public function test_networkLastIP8 ()
|
||||||
{
|
{
|
||||||
$i = new ipaddresses ();
|
$i = new Ipaddresses ();
|
||||||
$res = $i->networkLastIP ("2001:660:530d:201::125", 127);
|
$res = $i->networkLastIP ("2001:660:530d:201::125", 127);
|
||||||
$this->assertSame ($res, "2001:660:530d:201::125");
|
$this->assertSame ($res, "2001:660:530d:201::125");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,19 +7,21 @@
|
|||||||
|
|
||||||
namespace Domframework\Tests;
|
namespace Domframework\Tests;
|
||||||
|
|
||||||
/** Test the jwt.php file */
|
use Domframework\Jwt;
|
||||||
class jwtTest extends \PHPUnit_Framework_TestCase
|
|
||||||
|
/** Test the Jwt.php file */
|
||||||
|
class JwtTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
public function test_createKey_1 ()
|
public function test_createKey_1 ()
|
||||||
{
|
{
|
||||||
$jwt = new jwt ();
|
$jwt = new Jwt ();
|
||||||
$res = $jwt->createKey ();
|
$res = $jwt->createKey ();
|
||||||
$this->assertSame (40, strlen ($res));
|
$this->assertSame (40, strlen ($res));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_sign_1 ()
|
public function test_sign_1 ()
|
||||||
{
|
{
|
||||||
$jwt = new jwt ();
|
$jwt = new Jwt ();
|
||||||
$res = $this->invokeMethod ($jwt, "sign", "TEXT TO SIGN", "KEY TO USE",
|
$res = $this->invokeMethod ($jwt, "sign", "TEXT TO SIGN", "KEY TO USE",
|
||||||
"HS384");
|
"HS384");
|
||||||
$this->assertSame (
|
$this->assertSame (
|
||||||
@@ -29,7 +31,7 @@ class jwtTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_sign_2 ()
|
public function test_sign_2 ()
|
||||||
{
|
{
|
||||||
$jwt = new jwt ();
|
$jwt = new Jwt ();
|
||||||
$res = $this->invokeMethod ($jwt, "sign", "text to sign", "KEY TO USE",
|
$res = $this->invokeMethod ($jwt, "sign", "text to sign", "KEY TO USE",
|
||||||
"HS384");
|
"HS384");
|
||||||
$this->assertSame (
|
$this->assertSame (
|
||||||
@@ -39,7 +41,7 @@ class jwtTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_sign_3 ()
|
public function test_sign_3 ()
|
||||||
{
|
{
|
||||||
$jwt = new jwt ();
|
$jwt = new Jwt ();
|
||||||
$res = $this->invokeMethod ($jwt, "sign", "text to sign", "key to use",
|
$res = $this->invokeMethod ($jwt, "sign", "text to sign", "key to use",
|
||||||
"HS384");
|
"HS384");
|
||||||
$this->assertSame (
|
$this->assertSame (
|
||||||
@@ -49,7 +51,7 @@ class jwtTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_encode_1 ()
|
public function test_encode_1 ()
|
||||||
{
|
{
|
||||||
$jwt = new jwt ();
|
$jwt = new Jwt ();
|
||||||
$res = $jwt->encode (array ("payload" => "value"), "key to use", "HS384");
|
$res = $jwt->encode (array ("payload" => "value"), "key to use", "HS384");
|
||||||
$this->assertSame (
|
$this->assertSame (
|
||||||
"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzM4NCJ9.".
|
"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzM4NCJ9.".
|
||||||
@@ -59,7 +61,7 @@ class jwtTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_decode_1 ()
|
public function test_decode_1 ()
|
||||||
{
|
{
|
||||||
$jwt = new jwt ();
|
$jwt = new Jwt ();
|
||||||
$res = $jwt->decode (
|
$res = $jwt->decode (
|
||||||
"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzM4NCJ9.".
|
"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzM4NCJ9.".
|
||||||
"eyJwYXlsb2FkIjoidmFsdWUifQ.".
|
"eyJwYXlsb2FkIjoidmFsdWUifQ.".
|
||||||
@@ -71,7 +73,7 @@ class jwtTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function test_decode_2 ()
|
public function test_decode_2 ()
|
||||||
{
|
{
|
||||||
$GLOBALS["hash_equals"] = false;
|
$GLOBALS["hash_equals"] = false;
|
||||||
$jwt = new jwt ();
|
$jwt = new Jwt ();
|
||||||
$res = $jwt->decode (
|
$res = $jwt->decode (
|
||||||
"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzM4NCJ9.".
|
"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzM4NCJ9.".
|
||||||
"eyJwYXlsb2FkIjoidmFsdWUifQ.".
|
"eyJwYXlsb2FkIjoidmFsdWUifQ.".
|
||||||
@@ -82,7 +84,7 @@ class jwtTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_decode_3 ()
|
public function test_decode_3 ()
|
||||||
{
|
{
|
||||||
$jwt = new jwt ();
|
$jwt = new Jwt ();
|
||||||
$this->expectException ("Exception", "JWT with Empty algorithm");
|
$this->expectException ("Exception", "JWT with Empty algorithm");
|
||||||
$res = $jwt->decode (
|
$res = $jwt->decode (
|
||||||
"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUXXXXXJ9.".
|
"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUXXXXXJ9.".
|
||||||
@@ -93,7 +95,7 @@ class jwtTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_decode_4 ()
|
public function test_decode_4 ()
|
||||||
{
|
{
|
||||||
$jwt = new jwt ();
|
$jwt = new Jwt ();
|
||||||
$this->expectException ("Exception", "JWT Payload not readable");
|
$this->expectException ("Exception", "JWT Payload not readable");
|
||||||
$res = $jwt->decode (
|
$res = $jwt->decode (
|
||||||
"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzM4NCJ9.".
|
"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzM4NCJ9.".
|
||||||
@@ -104,7 +106,7 @@ class jwtTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_decode_5 ()
|
public function test_decode_5 ()
|
||||||
{
|
{
|
||||||
$jwt = new jwt ();
|
$jwt = new Jwt ();
|
||||||
$this->expectException ("Exception",
|
$this->expectException ("Exception",
|
||||||
"JWT Signature verification failed");
|
"JWT Signature verification failed");
|
||||||
$res = $jwt->decode (
|
$res = $jwt->decode (
|
||||||
@@ -116,7 +118,7 @@ class jwtTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_decode_6 ()
|
public function test_decode_6 ()
|
||||||
{
|
{
|
||||||
$jwt = new jwt ();
|
$jwt = new Jwt ();
|
||||||
$this->expectException ("Exception",
|
$this->expectException ("Exception",
|
||||||
"JWT Signature not readable");
|
"JWT Signature not readable");
|
||||||
$res = $jwt->decode (
|
$res = $jwt->decode (
|
||||||
@@ -128,7 +130,7 @@ class jwtTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_decode_7 ()
|
public function test_decode_7 ()
|
||||||
{
|
{
|
||||||
$jwt = new jwt ();
|
$jwt = new Jwt ();
|
||||||
$this->expectException ("Exception",
|
$this->expectException ("Exception",
|
||||||
"Malformed JWT Token");
|
"Malformed JWT Token");
|
||||||
$res = $jwt->decode (
|
$res = $jwt->decode (
|
||||||
@@ -144,7 +146,7 @@ class jwtTest extends \PHPUnit_Framework_TestCase
|
|||||||
*/
|
*/
|
||||||
public function testEncrypt1 ()
|
public function testEncrypt1 ()
|
||||||
{
|
{
|
||||||
$jwt = new jwt ();
|
$jwt = new Jwt ();
|
||||||
$key = $jwt->createKey ();
|
$key = $jwt->createKey ();
|
||||||
$res = $jwt->encode (
|
$res = $jwt->encode (
|
||||||
["email" => "toto@example.com", "password" => "ToTo"],
|
["email" => "toto@example.com", "password" => "ToTo"],
|
||||||
@@ -156,7 +158,7 @@ class jwtTest extends \PHPUnit_Framework_TestCase
|
|||||||
*/
|
*/
|
||||||
public function testEncrypyt2 ()
|
public function testEncrypyt2 ()
|
||||||
{
|
{
|
||||||
$jwt = new jwt ();
|
$jwt = new Jwt ();
|
||||||
$key = $jwt->createKey ();
|
$key = $jwt->createKey ();
|
||||||
$payload = (object)["email" => "toto@example.com", "password" => "ToTo"];
|
$payload = (object)["email" => "toto@example.com", "password" => "ToTo"];
|
||||||
$token = $jwt->encode ($payload, $key, "HS256", "123456789012345678901234");
|
$token = $jwt->encode ($payload, $key, "HS256", "123456789012345678901234");
|
||||||
@@ -168,7 +170,7 @@ class jwtTest extends \PHPUnit_Framework_TestCase
|
|||||||
*/
|
*/
|
||||||
public function testEncrypt3 ()
|
public function testEncrypt3 ()
|
||||||
{
|
{
|
||||||
$jwt = new jwt ();
|
$jwt = new Jwt ();
|
||||||
$key = $jwt->createKey ();
|
$key = $jwt->createKey ();
|
||||||
$payload = (object)["email" => "toto@example.com", "password" => "ToTo"];
|
$payload = (object)["email" => "toto@example.com", "password" => "ToTo"];
|
||||||
$token = $jwt->encode ($payload, $key, "HS256", "123456789012345678901234");
|
$token = $jwt->encode ($payload, $key, "HS256", "123456789012345678901234");
|
||||||
|
|||||||
@@ -7,103 +7,105 @@
|
|||||||
|
|
||||||
namespace Domframework\Tests;
|
namespace Domframework\Tests;
|
||||||
|
|
||||||
/** Test the macaddresses.php file */
|
use Domframework\Macaddresses;
|
||||||
class macaddressesTest extends \PHPUnit_Framework_TestCase
|
|
||||||
|
/** Test the Macaddresses.php file */
|
||||||
|
class MacaddressesTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
public function test_isMACAddress_1 ()
|
public function test_isMACAddress_1 ()
|
||||||
{
|
{
|
||||||
$macaddresses = new macaddresses ();
|
$macaddresses = new Macaddresses ();
|
||||||
$res = $macaddresses->isMACAddress ("");
|
$res = $macaddresses->isMACAddress ("");
|
||||||
$this->assertSame (false, $res);
|
$this->assertSame (false, $res);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_isMACAddress_2 ()
|
public function test_isMACAddress_2 ()
|
||||||
{
|
{
|
||||||
$macaddresses = new macaddresses ();
|
$macaddresses = new Macaddresses ();
|
||||||
$res = $macaddresses->isMACAddress ("INVALID");
|
$res = $macaddresses->isMACAddress ("INVALID");
|
||||||
$this->assertSame (false, $res);
|
$this->assertSame (false, $res);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_isMACAddress_3 ()
|
public function test_isMACAddress_3 ()
|
||||||
{
|
{
|
||||||
$macaddresses = new macaddresses ();
|
$macaddresses = new Macaddresses ();
|
||||||
$res = $macaddresses->isMACAddress ("de:ad:be:af:aa:bb");
|
$res = $macaddresses->isMACAddress ("de:ad:be:af:aa:bb");
|
||||||
$this->assertSame (true, $res);
|
$this->assertSame (true, $res);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_isMACAddress_4 ()
|
public function test_isMACAddress_4 ()
|
||||||
{
|
{
|
||||||
$macaddresses = new macaddresses ();
|
$macaddresses = new Macaddresses ();
|
||||||
$res = $macaddresses->isMACAddress ("de-ad-be-af-aa-bb");
|
$res = $macaddresses->isMACAddress ("de-ad-be-af-aa-bb");
|
||||||
$this->assertSame (true, $res);
|
$this->assertSame (true, $res);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_isMACAddress_5 ()
|
public function test_isMACAddress_5 ()
|
||||||
{
|
{
|
||||||
$macaddresses = new macaddresses ();
|
$macaddresses = new Macaddresses ();
|
||||||
$res = $macaddresses->isMACAddress ("0005.313B.9080");
|
$res = $macaddresses->isMACAddress ("0005.313B.9080");
|
||||||
$this->assertSame (true, $res);
|
$this->assertSame (true, $res);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_isMACAddress_6 ()
|
public function test_isMACAddress_6 ()
|
||||||
{
|
{
|
||||||
$macaddresses = new macaddresses ();
|
$macaddresses = new Macaddresses ();
|
||||||
$res = $macaddresses->isMACAddress ("0005313B9080");
|
$res = $macaddresses->isMACAddress ("0005313B9080");
|
||||||
$this->assertSame (true, $res);
|
$this->assertSame (true, $res);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_isMACAddress_7 ()
|
public function test_isMACAddress_7 ()
|
||||||
{
|
{
|
||||||
$macaddresses = new macaddresses ();
|
$macaddresses = new Macaddresses ();
|
||||||
$res = $macaddresses->isMACAddress ("a0005313B9080a");
|
$res = $macaddresses->isMACAddress ("a0005313B9080a");
|
||||||
$this->assertSame (false, $res);
|
$this->assertSame (false, $res);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_addSeparator_1 ()
|
public function test_addSeparator_1 ()
|
||||||
{
|
{
|
||||||
$res = macaddresses::addSeparator ("0005313B9080");
|
$res = Macaddresses::addSeparator ("0005313B9080");
|
||||||
$this->assertSame ("00:05:31:3B:90:80", $res);
|
$this->assertSame ("00:05:31:3B:90:80", $res);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_addSeparator_2 ()
|
public function test_addSeparator_2 ()
|
||||||
{
|
{
|
||||||
$res = macaddresses::addSeparator ("0005313B9080", "-");
|
$res = Macaddresses::addSeparator ("0005313B9080", "-");
|
||||||
$this->assertSame ("00-05-31-3B-90-80", $res);
|
$this->assertSame ("00-05-31-3B-90-80", $res);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_addSeparator_3 ()
|
public function test_addSeparator_3 ()
|
||||||
{
|
{
|
||||||
$res = macaddresses::addSeparator ("0005313B9080", ".", 4);
|
$res = Macaddresses::addSeparator ("0005313B9080", ".", 4);
|
||||||
$this->assertSame ("0005.313B.9080", $res);
|
$this->assertSame ("0005.313B.9080", $res);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_addSeparator_4 ()
|
public function test_addSeparator_4 ()
|
||||||
{
|
{
|
||||||
$this->expectException ();
|
$this->expectException ();
|
||||||
$res = macaddresses::addSeparator ("INVALID", ".", 4);
|
$res = Macaddresses::addSeparator ("INVALID", ".", 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_removeSeparator_1 ()
|
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);
|
$this->assertSame ("deadbeafaabb", $res);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_removeSeparator_2 ()
|
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);
|
$this->assertSame ("deadbeafaabb", $res);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_removeSeparator_3 ()
|
public function test_removeSeparator_3 ()
|
||||||
{
|
{
|
||||||
$res = macaddresses::removeSeparator("dead.beaf.aabb");
|
$res = Macaddresses::removeSeparator("dead.beaf.aabb");
|
||||||
$this->assertSame ("deadbeafaabb", $res);
|
$this->assertSame ("deadbeafaabb", $res);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_removeSeparator_4 ()
|
public function test_removeSeparator_4 ()
|
||||||
{
|
{
|
||||||
$res = macaddresses::removeSeparator("deadbeafaabb");
|
$res = Macaddresses::removeSeparator("deadbeafaabb");
|
||||||
$this->assertSame ("deadbeafaabb", $res);
|
$this->assertSame ("deadbeafaabb", $res);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,12 +7,14 @@
|
|||||||
|
|
||||||
namespace Domframework\Tests;
|
namespace Domframework\Tests;
|
||||||
|
|
||||||
/** Test the mail.php file */
|
use Domframework\Mail;
|
||||||
class mailTest extends \PHPUnit_Framework_TestCase
|
|
||||||
|
/** Test the Mail.php file */
|
||||||
|
class MailTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
public function test_setBodyText1 ()
|
public function test_setBodyText1 ()
|
||||||
{
|
{
|
||||||
$mail = new mail ();
|
$mail = new Mail ();
|
||||||
$mail->setBodyText ("TEST");
|
$mail->setBodyText ("TEST");
|
||||||
$res = $mail->getMail ();
|
$res = $mail->getMail ();
|
||||||
$this->assertRegExp ("#TEST\n$#", $res);
|
$this->assertRegExp ("#TEST\n$#", $res);
|
||||||
@@ -20,7 +22,7 @@ class mailTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_setBodyHTML1 ()
|
public function test_setBodyHTML1 ()
|
||||||
{
|
{
|
||||||
$mail = new mail ();
|
$mail = new Mail ();
|
||||||
$mail->setBodyHTML ("TEST");
|
$mail->setBodyHTML ("TEST");
|
||||||
$res = $mail->getMail ();
|
$res = $mail->getMail ();
|
||||||
$this->assertRegExp ("#^\r\nTEST\n$#m", $res);
|
$this->assertRegExp ("#^\r\nTEST\n$#m", $res);
|
||||||
@@ -28,7 +30,7 @@ class mailTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_setGetBodyText1 ()
|
public function test_setGetBodyText1 ()
|
||||||
{
|
{
|
||||||
$mail = new mail ();
|
$mail = new Mail ();
|
||||||
$mail->setBodyText ("TEST");
|
$mail->setBodyText ("TEST");
|
||||||
$res = $mail->getBodyText ();
|
$res = $mail->getBodyText ();
|
||||||
$this->assertSame ("TEST\n", $res);
|
$this->assertSame ("TEST\n", $res);
|
||||||
@@ -36,7 +38,7 @@ class mailTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_setGetBodyHtml1 ()
|
public function test_setGetBodyHtml1 ()
|
||||||
{
|
{
|
||||||
$mail = new mail ();
|
$mail = new Mail ();
|
||||||
$mail->setBodyHtml ("TEST");
|
$mail->setBodyHtml ("TEST");
|
||||||
$res = $mail->getBodyHtml ();
|
$res = $mail->getBodyHtml ();
|
||||||
$this->assertSame ("TEST\n", $res);
|
$this->assertSame ("TEST\n", $res);
|
||||||
@@ -44,7 +46,7 @@ class mailTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_setFrom1 ()
|
public function test_setFrom1 ()
|
||||||
{
|
{
|
||||||
$mail = new mail ();
|
$mail = new Mail ();
|
||||||
$mail->setFrom ("test@example.com", "Test Exa1mple Com");
|
$mail->setFrom ("test@example.com", "Test Exa1mple Com");
|
||||||
$res = $mail->getFrom ();
|
$res = $mail->getFrom ();
|
||||||
$this->assertSame ("Test Exa1mple Com <test@example.com>\r\n", $res);
|
$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 ()
|
public function test_addTo1 ()
|
||||||
{
|
{
|
||||||
$mail = new mail ();
|
$mail = new Mail ();
|
||||||
$mail->addTo ("test@example.com", "Test Exa1mple Com");
|
$mail->addTo ("test@example.com", "Test Exa1mple Com");
|
||||||
$res = $mail->getTo ();
|
$res = $mail->getTo ();
|
||||||
$this->assertSame ("Test Exa1mple Com <test@example.com>\r\n", $res);
|
$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 ()
|
public function test_addTo2 ()
|
||||||
{
|
{
|
||||||
$mail = new mail ();
|
$mail = new Mail ();
|
||||||
$mail->addTo ("test@example.com", "Test Exa1mple Com");
|
$mail->addTo ("test@example.com", "Test Exa1mple Com");
|
||||||
$res = $mail->getMail ();
|
$res = $mail->getMail ();
|
||||||
$this->assertRegexp ("#^To: Test Exa1mple Com <test@example.com>\r$#m", $res);
|
$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 ()
|
public function test_setDateTimestamp1 ()
|
||||||
{
|
{
|
||||||
$mail = new mail ();
|
$mail = new Mail ();
|
||||||
$time = time ();
|
$time = time ();
|
||||||
$mail->setDateTimestamp ($time);
|
$mail->setDateTimestamp ($time);
|
||||||
$res = $mail->getDateTimestamp ();
|
$res = $mail->getDateTimestamp ();
|
||||||
@@ -77,7 +79,7 @@ class mailTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_setDateTimestamp2 ()
|
public function test_setDateTimestamp2 ()
|
||||||
{
|
{
|
||||||
$mail = new mail ();
|
$mail = new Mail ();
|
||||||
$time = time ();
|
$time = time ();
|
||||||
$mail->setDateTimestamp ($time);
|
$mail->setDateTimestamp ($time);
|
||||||
$res = $mail->getMail ();
|
$res = $mail->getMail ();
|
||||||
@@ -86,7 +88,7 @@ class mailTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_convertPeopleToArray1 ()
|
public function test_convertPeopleToArray1 ()
|
||||||
{
|
{
|
||||||
$mail = new mail ();
|
$mail = new Mail ();
|
||||||
$res = $mail->convertPeopleToArray ("toto toto <toto@toto.com>");
|
$res = $mail->convertPeopleToArray ("toto toto <toto@toto.com>");
|
||||||
$this->assertSame ($res, array (array ("name"=>"toto toto",
|
$this->assertSame ($res, array (array ("name"=>"toto toto",
|
||||||
"mail"=>"toto@toto.com")));
|
"mail"=>"toto@toto.com")));
|
||||||
@@ -94,7 +96,7 @@ class mailTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_convertPeopleToArray2 ()
|
public function test_convertPeopleToArray2 ()
|
||||||
{
|
{
|
||||||
$mail = new mail ();
|
$mail = new Mail ();
|
||||||
$res = $mail->convertPeopleToArray ("<toto@toto.com>");
|
$res = $mail->convertPeopleToArray ("<toto@toto.com>");
|
||||||
$this->assertSame ($res, array (array ("name"=>"",
|
$this->assertSame ($res, array (array ("name"=>"",
|
||||||
"mail"=>"toto@toto.com")));
|
"mail"=>"toto@toto.com")));
|
||||||
@@ -102,7 +104,7 @@ class mailTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_convertPeopleToArray3 ()
|
public function test_convertPeopleToArray3 ()
|
||||||
{
|
{
|
||||||
$mail = new mail ();
|
$mail = new Mail ();
|
||||||
$res = $mail->convertPeopleToArray ("toto@toto.com,titi@titi.com");
|
$res = $mail->convertPeopleToArray ("toto@toto.com,titi@titi.com");
|
||||||
$this->assertSame ($res, array (array ("name" => "",
|
$this->assertSame ($res, array (array ("name" => "",
|
||||||
"mail" => "toto@toto.com"),
|
"mail" => "toto@toto.com"),
|
||||||
@@ -112,7 +114,7 @@ class mailTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_convertPeopleToArray4 ()
|
public function test_convertPeopleToArray4 ()
|
||||||
{
|
{
|
||||||
$mail = new mail ();
|
$mail = new Mail ();
|
||||||
$res = $mail->convertPeopleToArray ("toto@toto.com");
|
$res = $mail->convertPeopleToArray ("toto@toto.com");
|
||||||
$this->assertSame ($res, array (array ("name"=>"",
|
$this->assertSame ($res, array (array ("name"=>"",
|
||||||
"mail"=>"toto@toto.com")));
|
"mail"=>"toto@toto.com")));
|
||||||
@@ -120,7 +122,7 @@ class mailTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_convertPeopleToArray5 ()
|
public function test_convertPeopleToArray5 ()
|
||||||
{
|
{
|
||||||
$mail = new mail ();
|
$mail = new Mail ();
|
||||||
$res = $mail->convertPeopleToArray (" <toto@toto.com> , <titi@titi.com>");
|
$res = $mail->convertPeopleToArray (" <toto@toto.com> , <titi@titi.com>");
|
||||||
$this->assertSame ($res, array (array ("name" => "",
|
$this->assertSame ($res, array (array ("name" => "",
|
||||||
"mail" => "toto@toto.com"),
|
"mail" => "toto@toto.com"),
|
||||||
@@ -130,7 +132,7 @@ class mailTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_convertPeopleToArray6 ()
|
public function test_convertPeopleToArray6 ()
|
||||||
{
|
{
|
||||||
$mail = new mail ();
|
$mail = new Mail ();
|
||||||
$res = $mail->convertPeopleToArray ("ToTo <toto@toto.com> , <titi@titi.com>");
|
$res = $mail->convertPeopleToArray ("ToTo <toto@toto.com> , <titi@titi.com>");
|
||||||
$this->assertSame ($res, array (array ("name" => "ToTo",
|
$this->assertSame ($res, array (array ("name" => "ToTo",
|
||||||
"mail" => "toto@toto.com"),
|
"mail" => "toto@toto.com"),
|
||||||
@@ -142,7 +144,7 @@ class mailTest extends \PHPUnit_Framework_TestCase
|
|||||||
*/
|
*/
|
||||||
public function testHeadersToJSON1 ()
|
public function testHeadersToJSON1 ()
|
||||||
{
|
{
|
||||||
$mail = new mail ();
|
$mail = new Mail ();
|
||||||
$mail->readMail ( // {{{
|
$mail->readMail ( // {{{
|
||||||
"Return-Path: <dominique.fournier@grenoble.cnrs.fr>
|
"Return-Path: <dominique.fournier@grenoble.cnrs.fr>
|
||||||
Delivered-To: dominique@fournier38.fr
|
Delivered-To: dominique@fournier38.fr
|
||||||
|
|||||||
@@ -7,21 +7,23 @@
|
|||||||
|
|
||||||
namespace Domframework\Tests;
|
namespace Domframework\Tests;
|
||||||
|
|
||||||
/** Test the outputjson.php file */
|
use Domframework\Markdown;
|
||||||
class markdownTest extends \PHPUnit_Framework_TestCase
|
|
||||||
|
/** Test the Markdown.php file */
|
||||||
|
class MarkdownTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
// TitleSeText
|
// TitleSeText
|
||||||
public function testTitleSeText1 ()
|
public function testTitleSeText1 ()
|
||||||
{
|
{
|
||||||
$this->expectOutputString("<h1>test</h1>");
|
$this->expectOutputString("<h1>test</h1>");
|
||||||
$md = new markdown ();
|
$md = new Markdown ();
|
||||||
printf ($md->html ("test\n====\n"), TRUE);
|
printf ($md->html ("test\n====\n"), TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testTitleSeText2 ()
|
public function testTitleSeText2 ()
|
||||||
{
|
{
|
||||||
$this->expectOutputString("<h2>test</h2>");
|
$this->expectOutputString("<h2>test</h2>");
|
||||||
$md = new markdown ();
|
$md = new Markdown ();
|
||||||
printf ($md->html ("test\n----\n"), TRUE);
|
printf ($md->html ("test\n----\n"), TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -29,42 +31,42 @@ class markdownTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function testTitleSharp1 ()
|
public function testTitleSharp1 ()
|
||||||
{
|
{
|
||||||
$this->expectOutputString("<h1>test</h1>");
|
$this->expectOutputString("<h1>test</h1>");
|
||||||
$md = new markdown ();
|
$md = new Markdown ();
|
||||||
printf ($md->html ("# test #"));
|
printf ($md->html ("# test #"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testTitleSharp2 ()
|
public function testTitleSharp2 ()
|
||||||
{
|
{
|
||||||
$this->expectOutputString("<h2>test</h2>");
|
$this->expectOutputString("<h2>test</h2>");
|
||||||
$md = new markdown ();
|
$md = new Markdown ();
|
||||||
printf ($md->html ("## test ##"));
|
printf ($md->html ("## test ##"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testTitleSharp3 ()
|
public function testTitleSharp3 ()
|
||||||
{
|
{
|
||||||
$this->expectOutputString("<h3>test</h3>");
|
$this->expectOutputString("<h3>test</h3>");
|
||||||
$md = new markdown ();
|
$md = new Markdown ();
|
||||||
printf ($md->html ("### test ###"));
|
printf ($md->html ("### test ###"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testTitleSharp4 ()
|
public function testTitleSharp4 ()
|
||||||
{
|
{
|
||||||
$this->expectOutputString("<h4>test</h4>");
|
$this->expectOutputString("<h4>test</h4>");
|
||||||
$md = new markdown ();
|
$md = new Markdown ();
|
||||||
printf ($md->html ("#### test ####"));
|
printf ($md->html ("#### test ####"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testTitleSharp5 ()
|
public function testTitleSharp5 ()
|
||||||
{
|
{
|
||||||
$this->expectOutputString("<h5>test</h5>");
|
$this->expectOutputString("<h5>test</h5>");
|
||||||
$md = new markdown ();
|
$md = new Markdown ();
|
||||||
printf ($md->html ("##### test #####"));
|
printf ($md->html ("##### test #####"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testTitleSharp6 ()
|
public function testTitleSharp6 ()
|
||||||
{
|
{
|
||||||
$this->expectOutputString("<h6>test</h6>");
|
$this->expectOutputString("<h6>test</h6>");
|
||||||
$md = new markdown ();
|
$md = new Markdown ();
|
||||||
printf ($md->html ("###### test #######"));
|
printf ($md->html ("###### test #######"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,42 +74,42 @@ class markdownTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function testSeparator1 ()
|
public function testSeparator1 ()
|
||||||
{
|
{
|
||||||
$this->expectOutputString("<hr/>");
|
$this->expectOutputString("<hr/>");
|
||||||
$md = new markdown ();
|
$md = new Markdown ();
|
||||||
printf ($md->html ("---\n"), TRUE);
|
printf ($md->html ("---\n"), TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSeparator2 ()
|
public function testSeparator2 ()
|
||||||
{
|
{
|
||||||
$this->expectOutputString("<hr/>");
|
$this->expectOutputString("<hr/>");
|
||||||
$md = new markdown ();
|
$md = new Markdown ();
|
||||||
printf ($md->html ("___\n"), TRUE);
|
printf ($md->html ("___\n"), TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSeparator3 ()
|
public function testSeparator3 ()
|
||||||
{
|
{
|
||||||
$this->expectOutputString("<hr/>");
|
$this->expectOutputString("<hr/>");
|
||||||
$md = new markdown ();
|
$md = new Markdown ();
|
||||||
printf ($md->html ("***\n"), TRUE);
|
printf ($md->html ("***\n"), TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSeparator4 ()
|
public function testSeparator4 ()
|
||||||
{
|
{
|
||||||
$this->expectOutputString("<hr/>");
|
$this->expectOutputString("<hr/>");
|
||||||
$md = new markdown ();
|
$md = new Markdown ();
|
||||||
printf ($md->html ("- - -\n"), TRUE);
|
printf ($md->html ("- - -\n"), TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSeparator5 ()
|
public function testSeparator5 ()
|
||||||
{
|
{
|
||||||
$this->expectOutputString("<hr/>");
|
$this->expectOutputString("<hr/>");
|
||||||
$md = new markdown ();
|
$md = new Markdown ();
|
||||||
printf ($md->html ("_ _ _\n"), TRUE);
|
printf ($md->html ("_ _ _\n"), TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSeparator6 ()
|
public function testSeparator6 ()
|
||||||
{
|
{
|
||||||
$this->expectOutputString("<hr/>");
|
$this->expectOutputString("<hr/>");
|
||||||
$md = new markdown ();
|
$md = new Markdown ();
|
||||||
printf ($md->html ("* * *\n"), TRUE);
|
printf ($md->html ("* * *\n"), TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -115,7 +117,7 @@ class markdownTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function testSimpleText ()
|
public function testSimpleText ()
|
||||||
{
|
{
|
||||||
$this->expectOutputString("<p>text</p>");
|
$this->expectOutputString("<p>text</p>");
|
||||||
$md = new markdown ();
|
$md = new Markdown ();
|
||||||
printf ($md->html ("text"), TRUE);
|
printf ($md->html ("text"), TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -123,42 +125,42 @@ class markdownTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function testEmphasisStrong1 ()
|
public function testEmphasisStrong1 ()
|
||||||
{
|
{
|
||||||
$this->expectOutputString("<p><strong>text</strong></p>");
|
$this->expectOutputString("<p><strong>text</strong></p>");
|
||||||
$md = new markdown ();
|
$md = new Markdown ();
|
||||||
printf ($md->html ("__text__"));
|
printf ($md->html ("__text__"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testEmphasisStrong2 ()
|
public function testEmphasisStrong2 ()
|
||||||
{
|
{
|
||||||
$this->expectOutputString("<p><strong>text</strong></p>");
|
$this->expectOutputString("<p><strong>text</strong></p>");
|
||||||
$md = new markdown ();
|
$md = new Markdown ();
|
||||||
printf ($md->html ("**text**"));
|
printf ($md->html ("**text**"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testEmphasisEM1 ()
|
public function testEmphasisEM1 ()
|
||||||
{
|
{
|
||||||
$this->expectOutputString("<p><em>text</em></p>");
|
$this->expectOutputString("<p><em>text</em></p>");
|
||||||
$md = new markdown ();
|
$md = new Markdown ();
|
||||||
printf ($md->html ("_text_"));
|
printf ($md->html ("_text_"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testEmphasisEM2 ()
|
public function testEmphasisEM2 ()
|
||||||
{
|
{
|
||||||
$this->expectOutputString("<p><em>file1.php</em> or <em>file2.php</em></p>");
|
$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_"));
|
printf ($md->html ("_file1.php_ or _file2.php_"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testEmphasisEM3 ()
|
public function testEmphasisEM3 ()
|
||||||
{
|
{
|
||||||
$this->expectOutputString("<p><em>text</em></p>");
|
$this->expectOutputString("<p><em>text</em></p>");
|
||||||
$md = new markdown ();
|
$md = new Markdown ();
|
||||||
printf ($md->html ("*text*"));
|
printf ($md->html ("*text*"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testEmphasisEM4 ()
|
public function testEmphasisEM4 ()
|
||||||
{
|
{
|
||||||
$this->expectOutputString("<p><em>text</em> or <em>text2</em></p>");
|
$this->expectOutputString("<p><em>text</em> or <em>text2</em></p>");
|
||||||
$md = new markdown ();
|
$md = new Markdown ();
|
||||||
printf ($md->html ("*text* or *text2*"));
|
printf ($md->html ("*text* or *text2*"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -170,7 +172,7 @@ class markdownTest extends \PHPUnit_Framework_TestCase
|
|||||||
<li>Case2</li>
|
<li>Case2</li>
|
||||||
<li>Case3</li>
|
<li>Case3</li>
|
||||||
</ul>");
|
</ul>");
|
||||||
$md = new markdown ();
|
$md = new Markdown ();
|
||||||
printf ($md->html ("* Case1\n* Case2\n* Case3"), TRUE);
|
printf ($md->html ("* Case1\n* Case2\n* Case3"), TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -181,7 +183,7 @@ class markdownTest extends \PHPUnit_Framework_TestCase
|
|||||||
<li>Case2</li>
|
<li>Case2</li>
|
||||||
<li>Case3</li>
|
<li>Case3</li>
|
||||||
</ul>");
|
</ul>");
|
||||||
$md = new markdown ();
|
$md = new Markdown ();
|
||||||
printf ($md->html ("- Case1\n- Case2\n- Case3"), TRUE);
|
printf ($md->html ("- Case1\n- Case2\n- Case3"), TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -192,7 +194,7 @@ class markdownTest extends \PHPUnit_Framework_TestCase
|
|||||||
<li>Case2</li>
|
<li>Case2</li>
|
||||||
<li>Case3</li>
|
<li>Case3</li>
|
||||||
</ul>");
|
</ul>");
|
||||||
$md = new markdown ();
|
$md = new Markdown ();
|
||||||
printf ($md->html ("+ Case1\n+ Case2\n+ Case3"), TRUE);
|
printf ($md->html ("+ Case1\n+ Case2\n+ Case3"), TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -202,7 +204,7 @@ class markdownTest extends \PHPUnit_Framework_TestCase
|
|||||||
<li>line1 end</li>
|
<li>line1 end</li>
|
||||||
<li>line2 end</li>
|
<li>line2 end</li>
|
||||||
</ul>");
|
</ul>");
|
||||||
$md = new markdown ();
|
$md = new Markdown ();
|
||||||
printf ($md->html ("* line1
|
printf ($md->html ("* line1
|
||||||
end
|
end
|
||||||
* line2
|
* line2
|
||||||
@@ -221,7 +223,7 @@ end"));
|
|||||||
</li>
|
</li>
|
||||||
<li>line3</li>
|
<li>line3</li>
|
||||||
</ul>");
|
</ul>");
|
||||||
$md = new markdown ();
|
$md = new Markdown ();
|
||||||
printf ($md->html ("* line1
|
printf ($md->html ("* line1
|
||||||
* line2
|
* line2
|
||||||
* NEW lineA
|
* NEW lineA
|
||||||
@@ -237,7 +239,7 @@ end"));
|
|||||||
<li>Case2</li>
|
<li>Case2</li>
|
||||||
<li>Case3</li>
|
<li>Case3</li>
|
||||||
</ol>");
|
</ol>");
|
||||||
$md = new markdown ();
|
$md = new Markdown ();
|
||||||
printf ($md->html ("1. Case1\n2. Case2\n3. Case3"), TRUE);
|
printf ($md->html ("1. Case1\n2. Case2\n3. Case3"), TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -247,7 +249,7 @@ end"));
|
|||||||
$this->expectOutputString("<pre><code>test
|
$this->expectOutputString("<pre><code>test
|
||||||
indent
|
indent
|
||||||
base</code></pre>");
|
base</code></pre>");
|
||||||
$md = new markdown ();
|
$md = new Markdown ();
|
||||||
printf ($md->html (" test
|
printf ($md->html (" test
|
||||||
indent
|
indent
|
||||||
base"));
|
base"));
|
||||||
@@ -257,7 +259,7 @@ base</code></pre>");
|
|||||||
public function testInlineCode1 ()
|
public function testInlineCode1 ()
|
||||||
{
|
{
|
||||||
$this->expectOutputString("<p><code>code</code></p>");
|
$this->expectOutputString("<p><code>code</code></p>");
|
||||||
$md = new markdown ();
|
$md = new Markdown ();
|
||||||
printf ($md->html ("`code`"));
|
printf ($md->html ("`code`"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -266,7 +268,7 @@ base</code></pre>");
|
|||||||
{
|
{
|
||||||
$this->expectOutputString(
|
$this->expectOutputString(
|
||||||
"<p><a href='http://example.com'>http://example.com</a></p>");
|
"<p><a href='http://example.com'>http://example.com</a></p>");
|
||||||
$md = new markdown ();
|
$md = new Markdown ();
|
||||||
printf ($md->html ("<http://example.com>"));
|
printf ($md->html ("<http://example.com>"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -274,7 +276,7 @@ base</code></pre>");
|
|||||||
{
|
{
|
||||||
$this->expectOutputString(
|
$this->expectOutputString(
|
||||||
"<p><a href='https://example.com'>https://example.com</a></p>");
|
"<p><a href='https://example.com'>https://example.com</a></p>");
|
||||||
$md = new markdown ();
|
$md = new Markdown ();
|
||||||
printf ($md->html ("<https://example.com>"));
|
printf ($md->html ("<https://example.com>"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -282,7 +284,7 @@ base</code></pre>");
|
|||||||
{
|
{
|
||||||
$this->expectOutputString(
|
$this->expectOutputString(
|
||||||
"<p><a href='mailto:test@example.com'>test@example.com</a></p>");
|
"<p><a href='mailto:test@example.com'>test@example.com</a></p>");
|
||||||
$md = new markdown ();
|
$md = new Markdown ();
|
||||||
printf ($md->html ("<test@example.com>"));
|
printf ($md->html ("<test@example.com>"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -290,7 +292,7 @@ base</code></pre>");
|
|||||||
{
|
{
|
||||||
$this->expectOutputString(
|
$this->expectOutputString(
|
||||||
"<p><a href='mailto:test_with_underscore@example.com'>test_with_underscore@example.com</a></p>");
|
"<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>"));
|
printf ($md->html ("<test_with_underscore@example.com>"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -298,7 +300,7 @@ base</code></pre>");
|
|||||||
public function testChain1 ()
|
public function testChain1 ()
|
||||||
{
|
{
|
||||||
$this->expectOutputString("<h1>t1</h1><h2>t2</h2>");
|
$this->expectOutputString("<h1>t1</h1><h2>t2</h2>");
|
||||||
$md = new markdown ();
|
$md = new Markdown ();
|
||||||
printf ($md->html ("# t1\n## t2"));
|
printf ($md->html ("# t1\n## t2"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -306,7 +308,7 @@ base</code></pre>");
|
|||||||
{
|
{
|
||||||
$this->expectOutputString("<pre><code>
|
$this->expectOutputString("<pre><code>
|
||||||
* OK</code></pre>");
|
* OK</code></pre>");
|
||||||
$md = new markdown ();
|
$md = new Markdown ();
|
||||||
printf ($md->html (" \n * OK"));
|
printf ($md->html (" \n * OK"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -314,7 +316,7 @@ base</code></pre>");
|
|||||||
{
|
{
|
||||||
$this->expectOutputString("<pre><code>
|
$this->expectOutputString("<pre><code>
|
||||||
* * * * * www-data OK</code></pre>");
|
* * * * * www-data OK</code></pre>");
|
||||||
$md = new markdown ();
|
$md = new Markdown ();
|
||||||
printf ($md->html (" \n * * * * * www-data OK"));
|
printf ($md->html (" \n * * * * * www-data OK"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -322,7 +324,7 @@ base</code></pre>");
|
|||||||
{
|
{
|
||||||
$this->expectOutputString("<p>To write</p>
|
$this->expectOutputString("<p>To write</p>
|
||||||
<pre><code>* * * * * www-data OK</code></pre>");
|
<pre><code>* * * * * www-data OK</code></pre>");
|
||||||
$md = new markdown ();
|
$md = new Markdown ();
|
||||||
printf ($md->html ("To write
|
printf ($md->html ("To write
|
||||||
|
|
||||||
* * * * * www-data OK"));
|
* * * * * www-data OK"));
|
||||||
@@ -335,7 +337,7 @@ base</code></pre>");
|
|||||||
<li>line1</li>
|
<li>line1</li>
|
||||||
<li>line2 end</li>
|
<li>line2 end</li>
|
||||||
</ul>");
|
</ul>");
|
||||||
$md = new markdown ();
|
$md = new Markdown ();
|
||||||
printf ($md->html ("Hi
|
printf ($md->html ("Hi
|
||||||
* line1
|
* line1
|
||||||
* line2
|
* line2
|
||||||
@@ -345,21 +347,21 @@ end"));
|
|||||||
public function testCarriageReturn1 ()
|
public function testCarriageReturn1 ()
|
||||||
{
|
{
|
||||||
$this->expectOutputString("<p>line1 line2</p>");
|
$this->expectOutputString("<p>line1 line2</p>");
|
||||||
$md = new markdown ();
|
$md = new Markdown ();
|
||||||
printf ($md->html ("line1\nline2\n"));
|
printf ($md->html ("line1\nline2\n"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testCarriageReturn2 ()
|
public function testCarriageReturn2 ()
|
||||||
{
|
{
|
||||||
$this->expectOutputString("<p>line1<br/>line2</p>");
|
$this->expectOutputString("<p>line1<br/>line2</p>");
|
||||||
$md = new markdown ();
|
$md = new Markdown ();
|
||||||
printf ($md->html ("line1 \nline2\n"));
|
printf ($md->html ("line1 \nline2\n"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testCarriageReturn3 ()
|
public function testCarriageReturn3 ()
|
||||||
{
|
{
|
||||||
$this->expectOutputString("<p>line1 line2 line3.</p>");
|
$this->expectOutputString("<p>line1 line2 line3.</p>");
|
||||||
$md = new markdown ();
|
$md = new Markdown ();
|
||||||
printf ($md->html ("line1
|
printf ($md->html ("line1
|
||||||
line2
|
line2
|
||||||
line3."));
|
line3."));
|
||||||
@@ -368,14 +370,14 @@ line3."));
|
|||||||
public function testHTMLSpecialChars1 ()
|
public function testHTMLSpecialChars1 ()
|
||||||
{
|
{
|
||||||
$this->expectOutputString("<p>toto&titi</p>");
|
$this->expectOutputString("<p>toto&titi</p>");
|
||||||
$md = new markdown ();
|
$md = new Markdown ();
|
||||||
printf ($md->html ("toto&titi"));
|
printf ($md->html ("toto&titi"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testHTMLSpecialChars2 ()
|
public function testHTMLSpecialChars2 ()
|
||||||
{
|
{
|
||||||
$this->expectOutputString("<p>totoétiti</p>");
|
$this->expectOutputString("<p>totoétiti</p>");
|
||||||
$md = new markdown ();
|
$md = new Markdown ();
|
||||||
printf ($md->html ("totoétiti"));
|
printf ($md->html ("totoétiti"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,8 +7,10 @@
|
|||||||
|
|
||||||
namespace Domframework\Tests;
|
namespace Domframework\Tests;
|
||||||
|
|
||||||
/** Test the outputdl.php file */
|
use Domframework\Outputdl;
|
||||||
class outputdlTest extends \PHPUnit_Framework_TestCase
|
|
||||||
|
/** Test the Outputdl.php file */
|
||||||
|
class OutputdlTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
public function test_outputdl_init ()
|
public function test_outputdl_init ()
|
||||||
{
|
{
|
||||||
@@ -25,7 +27,7 @@ class outputdlTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function test_outputdl_1 ()
|
public function test_outputdl_1 ()
|
||||||
{
|
{
|
||||||
// Check the full download content
|
// Check the full download content
|
||||||
$outputdl = new outputdl ();
|
$outputdl = new Outputdl ();
|
||||||
$this->expectOutputString (str_repeat (
|
$this->expectOutputString (str_repeat (
|
||||||
"1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\n",
|
"1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\n",
|
||||||
1000));
|
1000));
|
||||||
@@ -35,7 +37,7 @@ class outputdlTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function test_outputdl_Announce_1 ()
|
public function test_outputdl_Announce_1 ()
|
||||||
{
|
{
|
||||||
// Check the announce of Resume mode Enabled
|
// Check the announce of Resume mode Enabled
|
||||||
$outputdl = new outputdl ();
|
$outputdl = new Outputdl ();
|
||||||
$outputdl->downloadFile ("/tmp/testDFWoutputDL");
|
$outputdl->downloadFile ("/tmp/testDFWoutputDL");
|
||||||
$res = $outputdl->headers ();
|
$res = $outputdl->headers ();
|
||||||
$this->assertSame (in_array ("Accept-Ranges: bytes", $res), true);
|
$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 ()
|
public function test_outputdl_Announce_2 ()
|
||||||
{
|
{
|
||||||
// Check the announce of Resume mode Disabled
|
// Check the announce of Resume mode Disabled
|
||||||
$outputdl = new outputdl ();
|
$outputdl = new Outputdl ();
|
||||||
$outputdl->resumeAllow (false);
|
$outputdl->resumeAllow (false);
|
||||||
$outputdl->downloadFile ("/tmp/testDFWoutputDL");
|
$outputdl->downloadFile ("/tmp/testDFWoutputDL");
|
||||||
$res = $outputdl->headers ();
|
$res = $outputdl->headers ();
|
||||||
@@ -54,7 +56,7 @@ class outputdlTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function test_outputdl_Partial_1 ()
|
public function test_outputdl_Partial_1 ()
|
||||||
{
|
{
|
||||||
// Check the content get with provided range
|
// Check the content get with provided range
|
||||||
$outputdl = new outputdl ();
|
$outputdl = new Outputdl ();
|
||||||
$_SERVER["HTTP_RANGE"] = "bytes=3-9";
|
$_SERVER["HTTP_RANGE"] = "bytes=3-9";
|
||||||
$this->expectOutputString ("4567890");
|
$this->expectOutputString ("4567890");
|
||||||
$outputdl->downloadFile ("/tmp/testDFWoutputDL");
|
$outputdl->downloadFile ("/tmp/testDFWoutputDL");
|
||||||
@@ -64,7 +66,7 @@ class outputdlTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function test_outputdl_Partial_2 ()
|
public function test_outputdl_Partial_2 ()
|
||||||
{
|
{
|
||||||
// Check the content get with provided range
|
// Check the content get with provided range
|
||||||
$outputdl = new outputdl ();
|
$outputdl = new Outputdl ();
|
||||||
$_SERVER["HTTP_RANGE"] = "bytes=3-";
|
$_SERVER["HTTP_RANGE"] = "bytes=3-";
|
||||||
$this->expectOutputString (substr (str_repeat (
|
$this->expectOutputString (substr (str_repeat (
|
||||||
"1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\n",
|
"1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\n",
|
||||||
@@ -76,7 +78,7 @@ class outputdlTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function test_outputdl_Partial_3 ()
|
public function test_outputdl_Partial_3 ()
|
||||||
{
|
{
|
||||||
// Check the content get with provided range
|
// Check the content get with provided range
|
||||||
$outputdl = new outputdl ();
|
$outputdl = new Outputdl ();
|
||||||
$_SERVER["HTTP_RANGE"] = "bytes=0-";
|
$_SERVER["HTTP_RANGE"] = "bytes=0-";
|
||||||
$this->expectOutputString (str_repeat (
|
$this->expectOutputString (str_repeat (
|
||||||
"1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\n",
|
"1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\n",
|
||||||
@@ -88,7 +90,7 @@ class outputdlTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function test_outputdl_Partial_4 ()
|
public function test_outputdl_Partial_4 ()
|
||||||
{
|
{
|
||||||
// Check the content get with provided range
|
// Check the content get with provided range
|
||||||
$outputdl = new outputdl ();
|
$outputdl = new Outputdl ();
|
||||||
$_SERVER["HTTP_RANGE"] = "bytes=-5";
|
$_SERVER["HTTP_RANGE"] = "bytes=-5";
|
||||||
$this->expectOutputString ("wxyz\n");
|
$this->expectOutputString ("wxyz\n");
|
||||||
$outputdl->downloadFile ("/tmp/testDFWoutputDL");
|
$outputdl->downloadFile ("/tmp/testDFWoutputDL");
|
||||||
@@ -98,7 +100,7 @@ class outputdlTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function test_outputdl_Partial_5 ()
|
public function test_outputdl_Partial_5 ()
|
||||||
{
|
{
|
||||||
// Check the content get with provided range
|
// Check the content get with provided range
|
||||||
$outputdl = new outputdl ();
|
$outputdl = new Outputdl ();
|
||||||
$_SERVER["HTTP_RANGE"] = "bytes=0-3,6-9";
|
$_SERVER["HTTP_RANGE"] = "bytes=0-3,6-9";
|
||||||
$this->expectOutputString ("--Qm91bmRhcnk=\r
|
$this->expectOutputString ("--Qm91bmRhcnk=\r
|
||||||
Content-Range: bytes 0-3/63000\r
|
Content-Range: bytes 0-3/63000\r
|
||||||
@@ -120,7 +122,7 @@ Content-Type: application/octet-stream\r
|
|||||||
{
|
{
|
||||||
// Check the invalid provided range
|
// Check the invalid provided range
|
||||||
unset ($_SERVER["HTTP_RANGE"]);
|
unset ($_SERVER["HTTP_RANGE"]);
|
||||||
$outputdl = new outputdl ();
|
$outputdl = new Outputdl ();
|
||||||
$_SERVER["HTTP_RANGE"] = "bytes=99999-";
|
$_SERVER["HTTP_RANGE"] = "bytes=99999-";
|
||||||
$this->expectException ("Exception", "Invalid range provided", 416);
|
$this->expectException ("Exception", "Invalid range provided", 416);
|
||||||
$outputdl->downloadFile ("/tmp/testDFWoutputDL");
|
$outputdl->downloadFile ("/tmp/testDFWoutputDL");
|
||||||
@@ -130,7 +132,7 @@ Content-Type: application/octet-stream\r
|
|||||||
{
|
{
|
||||||
// Check the invalid provided range
|
// Check the invalid provided range
|
||||||
unset ($_SERVER["HTTP_RANGE"]);
|
unset ($_SERVER["HTTP_RANGE"]);
|
||||||
$outputdl = new outputdl ();
|
$outputdl = new Outputdl ();
|
||||||
$_SERVER["HTTP_RANGE"] = "bytes=9-3";
|
$_SERVER["HTTP_RANGE"] = "bytes=9-3";
|
||||||
$this->expectException ("Exception", "Invalid range provided", 416);
|
$this->expectException ("Exception", "Invalid range provided", 416);
|
||||||
$outputdl->downloadFile ("/tmp/testDFWoutputDL");
|
$outputdl->downloadFile ("/tmp/testDFWoutputDL");
|
||||||
@@ -140,7 +142,7 @@ Content-Type: application/octet-stream\r
|
|||||||
{
|
{
|
||||||
// Check the invalid provided range
|
// Check the invalid provided range
|
||||||
unset ($_SERVER["HTTP_RANGE"]);
|
unset ($_SERVER["HTTP_RANGE"]);
|
||||||
$outputdl = new outputdl ();
|
$outputdl = new Outputdl ();
|
||||||
$_SERVER["HTTP_RANGE"] = "bytes=9-999999";
|
$_SERVER["HTTP_RANGE"] = "bytes=9-999999";
|
||||||
$this->expectException ("Exception", "Invalid range provided", 416);
|
$this->expectException ("Exception", "Invalid range provided", 416);
|
||||||
$outputdl->downloadFile ("/tmp/testDFWoutputDL");
|
$outputdl->downloadFile ("/tmp/testDFWoutputDL");
|
||||||
@@ -150,7 +152,7 @@ Content-Type: application/octet-stream\r
|
|||||||
{
|
{
|
||||||
// Check the invalid provided range
|
// Check the invalid provided range
|
||||||
unset ($_SERVER["HTTP_RANGE"]);
|
unset ($_SERVER["HTTP_RANGE"]);
|
||||||
$outputdl = new outputdl ();
|
$outputdl = new Outputdl ();
|
||||||
$_SERVER["HTTP_RANGE"] = "bytes=-";
|
$_SERVER["HTTP_RANGE"] = "bytes=-";
|
||||||
$this->expectException ("Exception", "Invalid range provided", 416);
|
$this->expectException ("Exception", "Invalid range provided", 416);
|
||||||
$outputdl->downloadFile ("/tmp/testDFWoutputDL");
|
$outputdl->downloadFile ("/tmp/testDFWoutputDL");
|
||||||
@@ -160,7 +162,7 @@ Content-Type: application/octet-stream\r
|
|||||||
{
|
{
|
||||||
// Check the base comparison : OK
|
// Check the base comparison : OK
|
||||||
unset ($_SERVER["HTTP_RANGE"]);
|
unset ($_SERVER["HTTP_RANGE"]);
|
||||||
$outputdl = new outputdl ();
|
$outputdl = new Outputdl ();
|
||||||
$outputdl->base ("/tmp");
|
$outputdl->base ("/tmp");
|
||||||
$this->expectOutputString (str_repeat (
|
$this->expectOutputString (str_repeat (
|
||||||
"1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\n",
|
"1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\n",
|
||||||
@@ -172,7 +174,7 @@ Content-Type: application/octet-stream\r
|
|||||||
{
|
{
|
||||||
// Check the base comparison : BAD
|
// Check the base comparison : BAD
|
||||||
unset ($_SERVER["HTTP_RANGE"]);
|
unset ($_SERVER["HTTP_RANGE"]);
|
||||||
$outputdl = new outputdl ();
|
$outputdl = new Outputdl ();
|
||||||
$outputdl->base ("/tmp");
|
$outputdl->base ("/tmp");
|
||||||
$this->expectException ("Exception",
|
$this->expectException ("Exception",
|
||||||
"Invalid file to download : out of base", 406);
|
"Invalid file to download : out of base", 406);
|
||||||
@@ -183,7 +185,7 @@ Content-Type: application/octet-stream\r
|
|||||||
{
|
{
|
||||||
// Check the base comparison : BAD Symlink
|
// Check the base comparison : BAD Symlink
|
||||||
unset ($_SERVER["HTTP_RANGE"]);
|
unset ($_SERVER["HTTP_RANGE"]);
|
||||||
$outputdl = new outputdl ();
|
$outputdl = new Outputdl ();
|
||||||
$outputdl->base ("/tmp");
|
$outputdl->base ("/tmp");
|
||||||
$this->expectException ("Exception",
|
$this->expectException ("Exception",
|
||||||
"Invalid file to download : not a file", 406);
|
"Invalid file to download : not a file", 406);
|
||||||
@@ -194,7 +196,7 @@ Content-Type: application/octet-stream\r
|
|||||||
{
|
{
|
||||||
// Check the base comparison : Non existing
|
// Check the base comparison : Non existing
|
||||||
unset ($_SERVER["HTTP_RANGE"]);
|
unset ($_SERVER["HTTP_RANGE"]);
|
||||||
$outputdl = new outputdl ();
|
$outputdl = new Outputdl ();
|
||||||
$outputdl->base ("/tmp");
|
$outputdl->base ("/tmp");
|
||||||
$this->expectException ("Exception",
|
$this->expectException ("Exception",
|
||||||
"Invalid file to download : file doesn't exists", 404);
|
"Invalid file to download : file doesn't exists", 404);
|
||||||
|
|||||||
@@ -7,28 +7,30 @@
|
|||||||
|
|
||||||
namespace Domframework\Tests;
|
namespace Domframework\Tests;
|
||||||
|
|
||||||
/** Test the outputhtml.php file */
|
use Domframework\Outputhtml;
|
||||||
class outputhtmlTest extends \PHPUnit_Framework_TestCase
|
|
||||||
|
/** Test the Outputhtml.php file */
|
||||||
|
class OutputhtmlTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
/** Entry null */
|
/** Entry null */
|
||||||
public function testlayout1 ()
|
public function testlayout1 ()
|
||||||
{
|
{
|
||||||
$this->expectOutputRegex ("#<body>\s+</body>#");
|
$this->expectOutputRegex ("#<body>\s+</body>#");
|
||||||
$output = new outputhtml ();
|
$output = new Outputhtml ();
|
||||||
$res = $output->out ("");
|
$res = $output->out ("");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testlayout2 ()
|
public function testlayout2 ()
|
||||||
{
|
{
|
||||||
$this->expectOutputRegex("#data#");
|
$this->expectOutputRegex("#data#");
|
||||||
$output = new outputhtml ();
|
$output = new Outputhtml ();
|
||||||
$res = $output->out ("data");
|
$res = $output->out ("data");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testlayout3 ()
|
public function testlayout3 ()
|
||||||
{
|
{
|
||||||
$this->expectOutputRegex("#data#");
|
$this->expectOutputRegex("#data#");
|
||||||
$output = new outputhtml ();
|
$output = new Outputhtml ();
|
||||||
$res = $output->out ("data", "title");
|
$res = $output->out ("data", "title");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -39,7 +41,7 @@ class outputhtmlTest extends \PHPUnit_Framework_TestCase
|
|||||||
Text
|
Text
|
||||||
"." "."
|
"." "."
|
||||||
</body></html>\n");
|
</body></html>\n");
|
||||||
$output = new outputhtml ();
|
$output = new Outputhtml ();
|
||||||
$output->out ("data", "title", FALSE, FALSE, "Tests/layout.html" );
|
$output->out ("data", "title", FALSE, FALSE, "Tests/layout.html" );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -50,7 +52,7 @@ class outputhtmlTest extends \PHPUnit_Framework_TestCase
|
|||||||
Text
|
Text
|
||||||
VARIABLE
|
VARIABLE
|
||||||
</body></html>\n");
|
</body></html>\n");
|
||||||
$output = new outputhtml ();
|
$output = new Outputhtml ();
|
||||||
$variable = array ("var"=>"VARIABLE");
|
$variable = array ("var"=>"VARIABLE");
|
||||||
$output->out ("data", "title", FALSE, FALSE, "Tests/layout.html",
|
$output->out ("data", "title", FALSE, FALSE, "Tests/layout.html",
|
||||||
null, $variable);
|
null, $variable);
|
||||||
|
|||||||
@@ -7,14 +7,16 @@
|
|||||||
|
|
||||||
namespace Domframework\Tests;
|
namespace Domframework\Tests;
|
||||||
|
|
||||||
/** Test the outputjson.php file */
|
use Domframework\Outputjson;
|
||||||
class outputjsonTest extends \PHPUnit_Framework_TestCase
|
|
||||||
|
/** Test the Outputjson.php file */
|
||||||
|
class OutputjsonTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
/** Entry null */
|
/** Entry null */
|
||||||
public function testoutputjson1 ()
|
public function testoutputjson1 ()
|
||||||
{
|
{
|
||||||
$this->expectOutputString("\"\"");
|
$this->expectOutputString("\"\"");
|
||||||
$output = new outputjson ();
|
$output = new Outputjson ();
|
||||||
$output->out ("");
|
$output->out ("");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -22,7 +24,7 @@ class outputjsonTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function testoutputjson2 ()
|
public function testoutputjson2 ()
|
||||||
{
|
{
|
||||||
$this->expectOutputString("\"string\"");
|
$this->expectOutputString("\"string\"");
|
||||||
$output = new outputjson ();
|
$output = new Outputjson ();
|
||||||
$output->out ("string");
|
$output->out ("string");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -30,7 +32,7 @@ class outputjsonTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function testoutputjson3 ()
|
public function testoutputjson3 ()
|
||||||
{
|
{
|
||||||
$this->expectOutputString("[1,2,3]");
|
$this->expectOutputString("[1,2,3]");
|
||||||
$output = new outputjson ();
|
$output = new Outputjson ();
|
||||||
$output->out (array (1,2,3));
|
$output->out (array (1,2,3));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,24 +7,26 @@
|
|||||||
|
|
||||||
namespace Domframework\Tests;
|
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 ()
|
public function test_cryptPasswd_1 ()
|
||||||
{
|
{
|
||||||
$res = \password::cryptPasswd ("AAA");
|
$res = Password::cryptPasswd ("AAA");
|
||||||
$this->assertSame ($res[0] == "$" && strlen ($res) > 8, true);
|
$this->assertSame ($res[0] == "$" && strlen ($res) > 8, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_cryptPasswd_2 ()
|
public function test_cryptPasswd_2 ()
|
||||||
{
|
{
|
||||||
// Test the randomization of the salt : must be different each time
|
// Test the randomization of the salt : must be different each time
|
||||||
$res1 = \password::cryptPasswd ("AAA");
|
$res1 = Password::cryptPasswd ("AAA");
|
||||||
echo "RES1=$res1\n";
|
echo "RES1=$res1\n";
|
||||||
$res2 = \password::cryptPasswd ("AAA");
|
$res2 = Password::cryptPasswd ("AAA");
|
||||||
echo "RES2=$res2\n";
|
echo "RES2=$res2\n";
|
||||||
$res3 = \password::cryptPasswd ("AAA");
|
$res3 = Password::cryptPasswd ("AAA");
|
||||||
echo "RES3=$res3\n";
|
echo "RES3=$res3\n";
|
||||||
$this->assertSame (count (array_unique (array ($res1, $res2, $res3))), 3);
|
$this->assertSame (count (array_unique (array ($res1, $res2, $res3))), 3);
|
||||||
// Three passwords : each must have a different result
|
// Three passwords : each must have a different result
|
||||||
@@ -33,7 +35,7 @@ class passwordTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function test_cryptPasswd_3 ()
|
public function test_cryptPasswd_3 ()
|
||||||
{
|
{
|
||||||
$this->expectException ();
|
$this->expectException ();
|
||||||
$res = \password::cryptPasswd (false);
|
$res = Password::cryptPasswd (false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_cryptPassword_MYSQL ()
|
public function test_cryptPassword_MYSQL ()
|
||||||
@@ -127,26 +129,26 @@ class passwordTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_checkPassword_1 ()
|
public function test_checkPassword_1 ()
|
||||||
{
|
{
|
||||||
$res = \password::checkPassword ("AAA", "AAA");
|
$res = Password::checkPassword ("AAA", "AAA");
|
||||||
$this->assertSame ($res, false);
|
$this->assertSame ($res, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_checkPassword_2 ()
|
public function test_checkPassword_2 ()
|
||||||
{
|
{
|
||||||
$crypt = \password::cryptPasswd ("AAA");
|
$crypt = Password::cryptPasswd ("AAA");
|
||||||
$res = \password::checkPassword ("AAA", $crypt);
|
$res = Password::checkPassword ("AAA", $crypt);
|
||||||
$this->assertSame ($res, true);
|
$this->assertSame ($res, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_checkPassword_3 ()
|
public function test_checkPassword_3 ()
|
||||||
{
|
{
|
||||||
$res = \password::checkPassword ("AAA", \password::cryptPasswd ("BBB"));
|
$res = Password::checkPassword ("AAA", Password::cryptPasswd ("BBB"));
|
||||||
$this->assertSame ($res, false);
|
$this->assertSame ($res, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_checkPassword_4 ()
|
public function test_checkPassword_4 ()
|
||||||
{
|
{
|
||||||
$res = \password::checkPassword ("AAA",
|
$res = Password::checkPassword ("AAA",
|
||||||
'$2y$11$Y.E98jbjgDpV61eK..9MT.klzTeg7ulO4WH/B5yA8cAGMIh.zoNXq');
|
'$2y$11$Y.E98jbjgDpV61eK..9MT.klzTeg7ulO4WH/B5yA8cAGMIh.zoNXq');
|
||||||
$this->assertSame ($res, true);
|
$this->assertSame ($res, true);
|
||||||
}
|
}
|
||||||
@@ -154,68 +156,68 @@ class passwordTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function test_checkPassword_invalid1 ()
|
public function test_checkPassword_invalid1 ()
|
||||||
{
|
{
|
||||||
$this->expectException ();
|
$this->expectException ();
|
||||||
$res = \password::checkPassword (false,
|
$res = Password::checkPassword (false,
|
||||||
'$2y$11$Y.E98jbjgDpV61eK..9MT.klzTeg7ulO4WH/B5yA8cAGMIh.zoNXq');
|
'$2y$11$Y.E98jbjgDpV61eK..9MT.klzTeg7ulO4WH/B5yA8cAGMIh.zoNXq');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_checkPassword_invalid2 ()
|
public function test_checkPassword_invalid2 ()
|
||||||
{
|
{
|
||||||
$this->expectException ();
|
$this->expectException ();
|
||||||
$res = \password::checkPassword ("AAA", false);
|
$res = Password::checkPassword ("AAA", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_generateASCII_defaultsize ()
|
public function test_generateASCII_defaultsize ()
|
||||||
{
|
{
|
||||||
$res = \password::generateASCII ();
|
$res = Password::generateASCII ();
|
||||||
$this->assertSame (strlen ($res), 12);
|
$this->assertSame (strlen ($res), 12);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_generateASCII_toobig ()
|
public function test_generateASCII_toobig ()
|
||||||
{
|
{
|
||||||
$this->expectException ();
|
$this->expectException ();
|
||||||
$res = \password::generateASCII (112);
|
$res = Password::generateASCII (112);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_generateASCII_toosmall ()
|
public function test_generateASCII_toosmall ()
|
||||||
{
|
{
|
||||||
$this->expectException ();
|
$this->expectException ();
|
||||||
$res = \password::generateASCII (0);
|
$res = Password::generateASCII (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_generateAlphanum_defaultsize ()
|
public function test_generateAlphanum_defaultsize ()
|
||||||
{
|
{
|
||||||
$res = \password::generateAlphanum ();
|
$res = Password::generateAlphanum ();
|
||||||
$this->assertSame (strlen ($res), 12);
|
$this->assertSame (strlen ($res), 12);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_generateAlphanum_toobig ()
|
public function test_generateAlphanum_toobig ()
|
||||||
{
|
{
|
||||||
$this->expectException ();
|
$this->expectException ();
|
||||||
$res = \password::generateAlphanum (112);
|
$res = Password::generateAlphanum (112);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_generateAlphanum_toosmall ()
|
public function test_generateAlphanum_toosmall ()
|
||||||
{
|
{
|
||||||
$this->expectException ();
|
$this->expectException ();
|
||||||
$res = \password::generateAlphanum (0);
|
$res = Password::generateAlphanum (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_generateAlphabetical_defaultsize ()
|
public function test_generateAlphabetical_defaultsize ()
|
||||||
{
|
{
|
||||||
$res = \password::generateAlphabetical ();
|
$res = Password::generateAlphabetical ();
|
||||||
$this->assertSame (strlen ($res), 12);
|
$this->assertSame (strlen ($res), 12);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_generateAlphabetical_toobig ()
|
public function test_generateAlphabetical_toobig ()
|
||||||
{
|
{
|
||||||
$this->expectException ();
|
$this->expectException ();
|
||||||
$res = \password::generateAlphabetical (112);
|
$res = Password::generateAlphabetical (112);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_generateAlphabetical_toosmall ()
|
public function test_generateAlphabetical_toosmall ()
|
||||||
{
|
{
|
||||||
$this->expectException ();
|
$this->expectException ();
|
||||||
$res = \password::generateAlphabetical (0);
|
$res = Password::generateAlphabetical (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_listMethods_1 ()
|
public function test_listMethods_1 ()
|
||||||
|
|||||||
@@ -7,11 +7,13 @@
|
|||||||
|
|
||||||
namespace Domframework\Tests;
|
namespace Domframework\Tests;
|
||||||
|
|
||||||
/** Test the queue.php file */
|
use Domframework\Queue;
|
||||||
class queueTest extends \PHPUnit_Framework_TestCase
|
|
||||||
|
/** Test the Queue.php file */
|
||||||
|
class QueueTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
public function test ()
|
public function test ()
|
||||||
{
|
{
|
||||||
$queue = new queue ();
|
$queue = new Queue ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,8 +7,10 @@
|
|||||||
|
|
||||||
namespace Domframework\Tests;
|
namespace Domframework\Tests;
|
||||||
|
|
||||||
/** Test the queuefile.php file */
|
use Domframework\Queuefile;
|
||||||
class queuefileTest extends \PHPUnit_Framework_TestCase
|
|
||||||
|
/** Test the Queuefile.php file */
|
||||||
|
class QueuefileTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
public function test_clean ()
|
public function test_clean ()
|
||||||
{
|
{
|
||||||
@@ -18,7 +20,7 @@ class queuefileTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_add1 ()
|
public function test_add1 ()
|
||||||
{
|
{
|
||||||
$queuefile = new queuefile ();
|
$queuefile = new Queuefile ();
|
||||||
$queuefile->connect ("file:///tmp/queuefileTest/queuefileTest.json");
|
$queuefile->connect ("file:///tmp/queuefileTest/queuefileTest.json");
|
||||||
$res = $queuefile->add ("test1");
|
$res = $queuefile->add ("test1");
|
||||||
$this->assertSame (true, is_object ($res));
|
$this->assertSame (true, is_object ($res));
|
||||||
@@ -26,7 +28,7 @@ class queuefileTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_count1 ()
|
public function test_count1 ()
|
||||||
{
|
{
|
||||||
$queuefile = new queuefile ();
|
$queuefile = new Queuefile ();
|
||||||
$queuefile->connect ("file:///tmp/queuefileTest/queuefileTest.json");
|
$queuefile->connect ("file:///tmp/queuefileTest/queuefileTest.json");
|
||||||
$res = $queuefile->count ();
|
$res = $queuefile->count ();
|
||||||
$this->assertSame (1, $res);
|
$this->assertSame (1, $res);
|
||||||
@@ -34,7 +36,7 @@ class queuefileTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_add2 ()
|
public function test_add2 ()
|
||||||
{
|
{
|
||||||
$queuefile = new queuefile ();
|
$queuefile = new Queuefile ();
|
||||||
$queuefile->connect ("file:///tmp/queuefileTest/queuefileTest.json");
|
$queuefile->connect ("file:///tmp/queuefileTest/queuefileTest.json");
|
||||||
$res = $queuefile->add ("test2");
|
$res = $queuefile->add ("test2");
|
||||||
$this->assertSame (true, is_object ($res));
|
$this->assertSame (true, is_object ($res));
|
||||||
@@ -42,7 +44,7 @@ class queuefileTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_count2 ()
|
public function test_count2 ()
|
||||||
{
|
{
|
||||||
$queuefile = new queuefile ();
|
$queuefile = new Queuefile ();
|
||||||
$queuefile->connect ("file:///tmp/queuefileTest/queuefileTest.json");
|
$queuefile->connect ("file:///tmp/queuefileTest/queuefileTest.json");
|
||||||
$res = $queuefile->count ();
|
$res = $queuefile->count ();
|
||||||
$this->assertSame (2, $res);
|
$this->assertSame (2, $res);
|
||||||
@@ -50,7 +52,7 @@ class queuefileTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_getFirst1 ()
|
public function test_getFirst1 ()
|
||||||
{
|
{
|
||||||
$queuefile = new queuefile ();
|
$queuefile = new Queuefile ();
|
||||||
$queuefile->connect ("file:///tmp/queuefileTest/queuefileTest.json");
|
$queuefile->connect ("file:///tmp/queuefileTest/queuefileTest.json");
|
||||||
$res = $queuefile->getFirst ();
|
$res = $queuefile->getFirst ();
|
||||||
$this->assertSame ("test1", $res);
|
$this->assertSame ("test1", $res);
|
||||||
@@ -58,7 +60,7 @@ class queuefileTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_getLast1 ()
|
public function test_getLast1 ()
|
||||||
{
|
{
|
||||||
$queuefile = new queuefile ();
|
$queuefile = new Queuefile ();
|
||||||
$queuefile->connect ("file:///tmp/queuefileTest/queuefileTest.json");
|
$queuefile->connect ("file:///tmp/queuefileTest/queuefileTest.json");
|
||||||
$res = $queuefile->getLast ();
|
$res = $queuefile->getLast ();
|
||||||
$this->assertSame ("test2", $res);
|
$this->assertSame ("test2", $res);
|
||||||
@@ -66,7 +68,7 @@ class queuefileTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_getRange1 ()
|
public function test_getRange1 ()
|
||||||
{
|
{
|
||||||
$queuefile = new queuefile ();
|
$queuefile = new Queuefile ();
|
||||||
$queuefile->connect ("file:///tmp/queuefileTest/queuefileTest.json");
|
$queuefile->connect ("file:///tmp/queuefileTest/queuefileTest.json");
|
||||||
$res = $queuefile->getRange (1, 1);
|
$res = $queuefile->getRange (1, 1);
|
||||||
$this->assertSame (["test2"], $res);
|
$this->assertSame (["test2"], $res);
|
||||||
@@ -74,7 +76,7 @@ class queuefileTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_getRange2 ()
|
public function test_getRange2 ()
|
||||||
{
|
{
|
||||||
$queuefile = new queuefile ();
|
$queuefile = new Queuefile ();
|
||||||
$queuefile->connect ("file:///tmp/queuefileTest/queuefileTest.json");
|
$queuefile->connect ("file:///tmp/queuefileTest/queuefileTest.json");
|
||||||
$res = $queuefile->getRange (0, 2);
|
$res = $queuefile->getRange (0, 2);
|
||||||
$this->assertSame (["test1", "test2"], $res);
|
$this->assertSame (["test1", "test2"], $res);
|
||||||
@@ -82,7 +84,7 @@ class queuefileTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_getRange3 ()
|
public function test_getRange3 ()
|
||||||
{
|
{
|
||||||
$queuefile = new queuefile ();
|
$queuefile = new Queuefile ();
|
||||||
$queuefile->connect ("file:///tmp/queuefileTest/queuefileTest.json");
|
$queuefile->connect ("file:///tmp/queuefileTest/queuefileTest.json");
|
||||||
$this->expectException ();
|
$this->expectException ();
|
||||||
$res = $queuefile->getRange (0, 3);
|
$res = $queuefile->getRange (0, 3);
|
||||||
@@ -90,7 +92,7 @@ class queuefileTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_getAll1 ()
|
public function test_getAll1 ()
|
||||||
{
|
{
|
||||||
$queuefile = new queuefile ();
|
$queuefile = new Queuefile ();
|
||||||
$queuefile->connect ("file:///tmp/queuefileTest/queuefileTest.json");
|
$queuefile->connect ("file:///tmp/queuefileTest/queuefileTest.json");
|
||||||
$res = $queuefile->getAll ();
|
$res = $queuefile->getAll ();
|
||||||
$this->assertSame (["test1", "test2"], $res);
|
$this->assertSame (["test1", "test2"], $res);
|
||||||
@@ -99,7 +101,7 @@ class queuefileTest extends \PHPUnit_Framework_TestCase
|
|||||||
// AFTER THIS TEST THE FILE WILL BE EMPTY
|
// AFTER THIS TEST THE FILE WILL BE EMPTY
|
||||||
public function test_getAll2 ()
|
public function test_getAll2 ()
|
||||||
{
|
{
|
||||||
$queuefile = new queuefile ();
|
$queuefile = new Queuefile ();
|
||||||
$queuefile->connect ("file:///tmp/queuefileTest/queuefileTest.json");
|
$queuefile->connect ("file:///tmp/queuefileTest/queuefileTest.json");
|
||||||
$res = $queuefile->clear ();
|
$res = $queuefile->clear ();
|
||||||
$this->assertSame (true, is_object ($res));
|
$this->assertSame (true, is_object ($res));
|
||||||
@@ -107,7 +109,7 @@ class queuefileTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_count3 ()
|
public function test_count3 ()
|
||||||
{
|
{
|
||||||
$queuefile = new queuefile ();
|
$queuefile = new Queuefile ();
|
||||||
$queuefile->connect ("file:///tmp/queuefileTest/queuefileTest.json");
|
$queuefile->connect ("file:///tmp/queuefileTest/queuefileTest.json");
|
||||||
$res = $queuefile->count ();
|
$res = $queuefile->count ();
|
||||||
$this->assertSame (0, $res);
|
$this->assertSame (0, $res);
|
||||||
@@ -115,7 +117,7 @@ class queuefileTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_getAll3 ()
|
public function test_getAll3 ()
|
||||||
{
|
{
|
||||||
$queuefile = new queuefile ();
|
$queuefile = new Queuefile ();
|
||||||
$queuefile->connect ("file:///tmp/queuefileTest/queuefileTest.json");
|
$queuefile->connect ("file:///tmp/queuefileTest/queuefileTest.json");
|
||||||
$res = $queuefile->getAll ();
|
$res = $queuefile->getAll ();
|
||||||
$this->assertSame ([], $res);
|
$this->assertSame ([], $res);
|
||||||
@@ -123,7 +125,7 @@ class queuefileTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_getFirst2 ()
|
public function test_getFirst2 ()
|
||||||
{
|
{
|
||||||
$queuefile = new queuefile ();
|
$queuefile = new Queuefile ();
|
||||||
$queuefile->connect ("file:///tmp/queuefileTest/queuefileTest.json");
|
$queuefile->connect ("file:///tmp/queuefileTest/queuefileTest.json");
|
||||||
$res = $queuefile->getFirst ();
|
$res = $queuefile->getFirst ();
|
||||||
$this->assertSame (null, $res);
|
$this->assertSame (null, $res);
|
||||||
@@ -131,7 +133,7 @@ class queuefileTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_getLast2 ()
|
public function test_getLast2 ()
|
||||||
{
|
{
|
||||||
$queuefile = new queuefile ();
|
$queuefile = new Queuefile ();
|
||||||
$queuefile->connect ("file:///tmp/queuefileTest/queuefileTest.json");
|
$queuefile->connect ("file:///tmp/queuefileTest/queuefileTest.json");
|
||||||
$res = $queuefile->getLast ();
|
$res = $queuefile->getLast ();
|
||||||
$this->assertSame (null, $res);
|
$this->assertSame (null, $res);
|
||||||
|
|||||||
@@ -7,11 +7,13 @@
|
|||||||
|
|
||||||
namespace Domframework\Tests;
|
namespace Domframework\Tests;
|
||||||
|
|
||||||
/** Test the ratelimit.php file */
|
use Domframework\Ratelimit;
|
||||||
class ratelimitTest extends \PHPUnit_Framework_TestCase
|
|
||||||
|
/** Test the Ratelimit.php file */
|
||||||
|
class RatelimitTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
public function test_ratelimit0 ()
|
public function test_ratelimit0 ()
|
||||||
{
|
{
|
||||||
$ratelimit = new ratelimit ();
|
$ratelimit = new Ratelimit ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,8 +7,10 @@
|
|||||||
|
|
||||||
namespace Domframework\Tests;
|
namespace Domframework\Tests;
|
||||||
|
|
||||||
/** Test the ratelimitfile.php file */
|
use Domframework\Ratelimitfile;
|
||||||
class ratelimitfileTest extends \PHPUnit_Framework_TestCase
|
|
||||||
|
/** Test the Ratelimitfile.php file */
|
||||||
|
class RatelimitfileTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
public function test_ratelimitfile0 ()
|
public function test_ratelimitfile0 ()
|
||||||
{
|
{
|
||||||
@@ -18,7 +20,7 @@ class ratelimitfileTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function test_ratelimitfile1 ()
|
public function test_ratelimitfile1 ()
|
||||||
{
|
{
|
||||||
// Create one non ratelimited entry
|
// Create one non ratelimited entry
|
||||||
$ratelimitfile = new ratelimitfile ();
|
$ratelimitfile = new Ratelimitfile ();
|
||||||
$ratelimitfile->storageDir = "/tmp/testDFWratelimit";
|
$ratelimitfile->storageDir = "/tmp/testDFWratelimit";
|
||||||
$res = $ratelimitfile->set ("TOTO");
|
$res = $ratelimitfile->set ("TOTO");
|
||||||
$this->assertSame (true, $res);
|
$this->assertSame (true, $res);
|
||||||
@@ -27,7 +29,7 @@ class ratelimitfileTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function test_ratelimitfile2 ()
|
public function test_ratelimitfile2 ()
|
||||||
{
|
{
|
||||||
// Too much entries
|
// Too much entries
|
||||||
$ratelimitfile = new ratelimitfile ();
|
$ratelimitfile = new Ratelimitfile ();
|
||||||
$ratelimitfile->storageDir = "/tmp/testDFWratelimit";
|
$ratelimitfile->storageDir = "/tmp/testDFWratelimit";
|
||||||
$ratelimitfile->set ("TOTO");
|
$ratelimitfile->set ("TOTO");
|
||||||
$ratelimitfile->set ("TOTO");
|
$ratelimitfile->set ("TOTO");
|
||||||
@@ -45,7 +47,7 @@ class ratelimitfileTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function test_ratelimitfile3 ()
|
public function test_ratelimitfile3 ()
|
||||||
{
|
{
|
||||||
// Del the ratelimited entry
|
// Del the ratelimited entry
|
||||||
$ratelimitfile = new ratelimitfile ();
|
$ratelimitfile = new Ratelimitfile ();
|
||||||
$ratelimitfile->storageDir = "/tmp/testDFWratelimit";
|
$ratelimitfile->storageDir = "/tmp/testDFWratelimit";
|
||||||
$res = $ratelimitfile->del ("TOTO");
|
$res = $ratelimitfile->del ("TOTO");
|
||||||
$this->assertSame (true, $res);
|
$this->assertSame (true, $res);
|
||||||
@@ -54,7 +56,7 @@ class ratelimitfileTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function test_ratelimitfile4 ()
|
public function test_ratelimitfile4 ()
|
||||||
{
|
{
|
||||||
// Create one non ratelimited entry
|
// Create one non ratelimited entry
|
||||||
$ratelimitfile = new ratelimitfile ();
|
$ratelimitfile = new Ratelimitfile ();
|
||||||
$ratelimitfile->storageDir = "/tmp/testDFWratelimit";
|
$ratelimitfile->storageDir = "/tmp/testDFWratelimit";
|
||||||
$res = $ratelimitfile->set ("TOTO");
|
$res = $ratelimitfile->set ("TOTO");
|
||||||
$this->assertSame (true, $res);
|
$this->assertSame (true, $res);
|
||||||
@@ -64,7 +66,7 @@ class ratelimitfileTest extends \PHPUnit_Framework_TestCase
|
|||||||
{
|
{
|
||||||
// Clean expired entries
|
// Clean expired entries
|
||||||
sleep (2);
|
sleep (2);
|
||||||
$ratelimitfile = new ratelimitfile ();
|
$ratelimitfile = new Ratelimitfile ();
|
||||||
$ratelimitfile->unittime = 1;
|
$ratelimitfile->unittime = 1;
|
||||||
$ratelimitfile->storageDir = "/tmp/testDFWratelimit";
|
$ratelimitfile->storageDir = "/tmp/testDFWratelimit";
|
||||||
$ratelimitfile->clean ();
|
$ratelimitfile->clean ();
|
||||||
|
|||||||
@@ -7,14 +7,16 @@
|
|||||||
|
|
||||||
namespace Domframework\Tests;
|
namespace Domframework\Tests;
|
||||||
|
|
||||||
|
use Domframework\Rest;
|
||||||
|
|
||||||
/** Test the domframework REST part */
|
/** Test the domframework REST part */
|
||||||
class restTest extends \PHPUnit_Framework_TestCase
|
class RestTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
/** No param, JSON by default
|
/** No param, JSON by default
|
||||||
*/
|
*/
|
||||||
public function testChooseType1 ()
|
public function testChooseType1 ()
|
||||||
{
|
{
|
||||||
$rest = new \rest ();
|
$rest = new Rest ();
|
||||||
$res = $rest->chooseType ();
|
$res = $rest->chooseType ();
|
||||||
$this->assertSame ($res, "json");
|
$this->assertSame ($res, "json");
|
||||||
}
|
}
|
||||||
@@ -23,7 +25,7 @@ class restTest extends \PHPUnit_Framework_TestCase
|
|||||||
*/
|
*/
|
||||||
public function testChooseType2 ()
|
public function testChooseType2 ()
|
||||||
{
|
{
|
||||||
$rest = new \rest ();
|
$rest = new Rest ();
|
||||||
$rest->allowedtypes = array ("xml", "csv");
|
$rest->allowedtypes = array ("xml", "csv");
|
||||||
$res = $rest->chooseType ();
|
$res = $rest->chooseType ();
|
||||||
$this->assertSame ($res, "xml");
|
$this->assertSame ($res, "xml");
|
||||||
@@ -33,7 +35,7 @@ class restTest extends \PHPUnit_Framework_TestCase
|
|||||||
*/
|
*/
|
||||||
public function testChooseType3 ()
|
public function testChooseType3 ()
|
||||||
{
|
{
|
||||||
$rest = new \rest ();
|
$rest = new Rest ();
|
||||||
$_SERVER["HTTP_ACCEPT"] = "text/html,application/xml;q=0.9,*/*;q=0.8";
|
$_SERVER["HTTP_ACCEPT"] = "text/html,application/xml;q=0.9,*/*;q=0.8";
|
||||||
$res = $rest->chooseType ();
|
$res = $rest->chooseType ();
|
||||||
$this->assertSame ($res, "xml");
|
$this->assertSame ($res, "xml");
|
||||||
@@ -43,7 +45,7 @@ class restTest extends \PHPUnit_Framework_TestCase
|
|||||||
*/
|
*/
|
||||||
public function testChooseType4 ()
|
public function testChooseType4 ()
|
||||||
{
|
{
|
||||||
$rest = new \rest ();
|
$rest = new Rest ();
|
||||||
$_SERVER["HTTP_ACCEPT"] = "text/html;q=0.9,*/*;q=0.8";
|
$_SERVER["HTTP_ACCEPT"] = "text/html;q=0.9,*/*;q=0.8";
|
||||||
$res = $rest->chooseType ();
|
$res = $rest->chooseType ();
|
||||||
$this->assertSame ($res, "json");
|
$this->assertSame ($res, "json");
|
||||||
@@ -54,7 +56,7 @@ class restTest extends \PHPUnit_Framework_TestCase
|
|||||||
*/
|
*/
|
||||||
public function testChooseType5 ()
|
public function testChooseType5 ()
|
||||||
{
|
{
|
||||||
$rest = new \rest ();
|
$rest = new Rest ();
|
||||||
$rest->allowedtypes = array ("xml", "csv");
|
$rest->allowedtypes = array ("xml", "csv");
|
||||||
$_SERVER["HTTP_ACCEPT"] = "text/html;q=0.9,*/*;q=0.8";
|
$_SERVER["HTTP_ACCEPT"] = "text/html;q=0.9,*/*;q=0.8";
|
||||||
$res = $rest->chooseType ();
|
$res = $rest->chooseType ();
|
||||||
|
|||||||
@@ -7,32 +7,34 @@
|
|||||||
|
|
||||||
namespace Domframework\Tests;
|
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
|
// Empty Robots
|
||||||
public function test_Construct_1 ()
|
public function test_Construct_1 ()
|
||||||
{
|
{
|
||||||
$robotstxt = new robotstxt ("", "domsearch");
|
$robotstxt = new Robotstxt ("", "domsearch");
|
||||||
$res = $robotstxt->allow ();
|
$res = $robotstxt->allow ();
|
||||||
$this->assertSame ($res, ["/"]);
|
$this->assertSame ($res, ["/"]);
|
||||||
}
|
}
|
||||||
public function test_Construct_2 ()
|
public function test_Construct_2 ()
|
||||||
{
|
{
|
||||||
$robotstxt = new robotstxt ("", "domsearch");
|
$robotstxt = new Robotstxt ("", "domsearch");
|
||||||
$res = $robotstxt->disallow ();
|
$res = $robotstxt->disallow ();
|
||||||
$this->assertSame ($res, array ());
|
$this->assertSame ($res, array ());
|
||||||
}
|
}
|
||||||
public function test_Construct_3 ()
|
public function test_Construct_3 ()
|
||||||
{
|
{
|
||||||
$robotstxt = new robotstxt ("", "domsearch");
|
$robotstxt = new Robotstxt ("", "domsearch");
|
||||||
$res = $robotstxt->sitemaps ();
|
$res = $robotstxt->sitemaps ();
|
||||||
$this->assertSame ($res, array ());
|
$this->assertSame ($res, array ());
|
||||||
}
|
}
|
||||||
public function test_Construct_4 ()
|
public function test_Construct_4 ()
|
||||||
{
|
{
|
||||||
$robotstxt = new robotstxt ("", "domsearch");
|
$robotstxt = new Robotstxt ("", "domsearch");
|
||||||
$res = $robotstxt->crawldelay ();
|
$res = $robotstxt->crawldelay ();
|
||||||
$this->assertSame ($res, 3);
|
$this->assertSame ($res, 3);
|
||||||
}
|
}
|
||||||
@@ -40,14 +42,14 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
|
|||||||
// Allow
|
// Allow
|
||||||
public function test_allow_1 ()
|
public function test_allow_1 ()
|
||||||
{
|
{
|
||||||
$robotstxt = new robotstxt (
|
$robotstxt = new Robotstxt (
|
||||||
"User-Agent: *\nDisallow:\n", "domsearch");
|
"User-Agent: *\nDisallow:\n", "domsearch");
|
||||||
$res = $robotstxt->allow ();
|
$res = $robotstxt->allow ();
|
||||||
$this->assertSame ($res, ["/"]);
|
$this->assertSame ($res, ["/"]);
|
||||||
}
|
}
|
||||||
public function test_allow_2 ()
|
public function test_allow_2 ()
|
||||||
{
|
{
|
||||||
$robotstxt = new robotstxt (
|
$robotstxt = new Robotstxt (
|
||||||
"User-Agent: *\nDisallow:\n\nUser-Agent: DomSearch\nDisallow:\n",
|
"User-Agent: *\nDisallow:\n\nUser-Agent: DomSearch\nDisallow:\n",
|
||||||
"domsearch");
|
"domsearch");
|
||||||
$res = $robotstxt->allow ();
|
$res = $robotstxt->allow ();
|
||||||
@@ -55,7 +57,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
|
|||||||
}
|
}
|
||||||
public function test_allow_3 ()
|
public function test_allow_3 ()
|
||||||
{
|
{
|
||||||
$robotstxt = new robotstxt (
|
$robotstxt = new Robotstxt (
|
||||||
"User-Agent: DomSearch\nDisallow:\n\nUser-Agent: *\nDisallow:\n",
|
"User-Agent: DomSearch\nDisallow:\n\nUser-Agent: *\nDisallow:\n",
|
||||||
"domsearch");
|
"domsearch");
|
||||||
$res = $robotstxt->allow ();
|
$res = $robotstxt->allow ();
|
||||||
@@ -63,7 +65,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
|
|||||||
}
|
}
|
||||||
public function test_allow_4 ()
|
public function test_allow_4 ()
|
||||||
{
|
{
|
||||||
$robotstxt = new robotstxt (
|
$robotstxt = new Robotstxt (
|
||||||
"User-Agent: DomSearch\n".
|
"User-Agent: DomSearch\n".
|
||||||
"User-Agent: User1\n".
|
"User-Agent: User1\n".
|
||||||
"User-Agent: User2\n".
|
"User-Agent: User2\n".
|
||||||
@@ -77,14 +79,14 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
|
|||||||
// Disallow
|
// Disallow
|
||||||
public function test_disallow_1 ()
|
public function test_disallow_1 ()
|
||||||
{
|
{
|
||||||
$robotstxt = new robotstxt (
|
$robotstxt = new Robotstxt (
|
||||||
"User-Agent: *\nDisallow: /\n", "domsearch");
|
"User-Agent: *\nDisallow: /\n", "domsearch");
|
||||||
$res = $robotstxt->disallow ();
|
$res = $robotstxt->disallow ();
|
||||||
$this->assertSame ($res, ["/"]);
|
$this->assertSame ($res, ["/"]);
|
||||||
}
|
}
|
||||||
public function test_disallow_2 ()
|
public function test_disallow_2 ()
|
||||||
{
|
{
|
||||||
$robotstxt = new robotstxt (
|
$robotstxt = new Robotstxt (
|
||||||
"User-Agent: *\nDisallow: /\n\nUser-Agent: DomSearch\nDisallow: /\n",
|
"User-Agent: *\nDisallow: /\n\nUser-Agent: DomSearch\nDisallow: /\n",
|
||||||
"domsearch");
|
"domsearch");
|
||||||
$res = $robotstxt->disallow ();
|
$res = $robotstxt->disallow ();
|
||||||
@@ -92,7 +94,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
|
|||||||
}
|
}
|
||||||
public function test_disallow_3 ()
|
public function test_disallow_3 ()
|
||||||
{
|
{
|
||||||
$robotstxt = new robotstxt (
|
$robotstxt = new Robotstxt (
|
||||||
"User-Agent: DomSearch\nDisallow: /\n\nUser-Agent: *\nDisallow: /\n",
|
"User-Agent: DomSearch\nDisallow: /\n\nUser-Agent: *\nDisallow: /\n",
|
||||||
"domsearch");
|
"domsearch");
|
||||||
$res = $robotstxt->disallow ();
|
$res = $robotstxt->disallow ();
|
||||||
@@ -102,7 +104,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
|
|||||||
// Sitemaps
|
// Sitemaps
|
||||||
public function test_sitemaps_1 ()
|
public function test_sitemaps_1 ()
|
||||||
{
|
{
|
||||||
$robotstxt = new robotstxt (
|
$robotstxt = new Robotstxt (
|
||||||
"User-Agent: DomSearch\nDisallow: /\n\nUser-Agent: *\nDisallow: /\n",
|
"User-Agent: DomSearch\nDisallow: /\n\nUser-Agent: *\nDisallow: /\n",
|
||||||
"domsearch");
|
"domsearch");
|
||||||
$res = $robotstxt->sitemaps ();
|
$res = $robotstxt->sitemaps ();
|
||||||
@@ -110,7 +112,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
|
|||||||
}
|
}
|
||||||
public function test_sitemaps_2 ()
|
public function test_sitemaps_2 ()
|
||||||
{
|
{
|
||||||
$robotstxt = new robotstxt (
|
$robotstxt = new Robotstxt (
|
||||||
"User-Agent: *\nDisallow: /\nSitemap: http://example.com/sitemap.xml",
|
"User-Agent: *\nDisallow: /\nSitemap: http://example.com/sitemap.xml",
|
||||||
"domsearch");
|
"domsearch");
|
||||||
$res = $robotstxt->sitemaps ();
|
$res = $robotstxt->sitemaps ();
|
||||||
@@ -118,7 +120,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
|
|||||||
}
|
}
|
||||||
public function test_sitemaps_3 ()
|
public function test_sitemaps_3 ()
|
||||||
{
|
{
|
||||||
$robotstxt = new robotstxt (
|
$robotstxt = new Robotstxt (
|
||||||
"User-Agent: *\nDisallow: /\n".
|
"User-Agent: *\nDisallow: /\n".
|
||||||
"Sitemap: http://example.com/sitemap.xml\n".
|
"Sitemap: http://example.com/sitemap.xml\n".
|
||||||
"Sitemap: http://example.com/SITEMAP.XML", "domsearch");
|
"Sitemap: http://example.com/SITEMAP.XML", "domsearch");
|
||||||
@@ -129,7 +131,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_sitemaps_error_1 ()
|
public function test_sitemaps_error_1 ()
|
||||||
{
|
{
|
||||||
$robotstxt = new robotstxt (
|
$robotstxt = new Robotstxt (
|
||||||
"User-Agent: *\nDisallow: /\nSitemap: URL",
|
"User-Agent: *\nDisallow: /\nSitemap: URL",
|
||||||
"domsearch");
|
"domsearch");
|
||||||
$res = $robotstxt->errors ();
|
$res = $robotstxt->errors ();
|
||||||
@@ -139,28 +141,28 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
|
|||||||
// Host
|
// Host
|
||||||
public function test_host_1 ()
|
public function test_host_1 ()
|
||||||
{
|
{
|
||||||
$robotstxt = new robotstxt (
|
$robotstxt = new Robotstxt (
|
||||||
"User-Agent: *\nDisallow: /\n", "domsearch");
|
"User-Agent: *\nDisallow: /\n", "domsearch");
|
||||||
$res = $robotstxt->host ();
|
$res = $robotstxt->host ();
|
||||||
$this->assertSame ($res, null);
|
$this->assertSame ($res, null);
|
||||||
}
|
}
|
||||||
public function test_host_2 ()
|
public function test_host_2 ()
|
||||||
{
|
{
|
||||||
$robotstxt = new robotstxt (
|
$robotstxt = new Robotstxt (
|
||||||
"User-Agent: *\nDisallow: /\n\nHost: localhost", "domsearch");
|
"User-Agent: *\nDisallow: /\n\nHost: localhost", "domsearch");
|
||||||
$res = $robotstxt->host ();
|
$res = $robotstxt->host ();
|
||||||
$this->assertSame ($res, "localhost");
|
$this->assertSame ($res, "localhost");
|
||||||
}
|
}
|
||||||
public function test_host_error_1 ()
|
public function test_host_error_1 ()
|
||||||
{
|
{
|
||||||
$robotstxt = new robotstxt (
|
$robotstxt = new Robotstxt (
|
||||||
"User-Agent: *\nDisallow: /\n\nHost: localhost\nHoST: toto", "domsearch");
|
"User-Agent: *\nDisallow: /\n\nHost: localhost\nHoST: toto", "domsearch");
|
||||||
$res = $robotstxt->host ();
|
$res = $robotstxt->host ();
|
||||||
$this->assertSame ($res, "localhost");
|
$this->assertSame ($res, "localhost");
|
||||||
}
|
}
|
||||||
public function test_host_error_2 ()
|
public function test_host_error_2 ()
|
||||||
{
|
{
|
||||||
$robotstxt = new robotstxt (
|
$robotstxt = new Robotstxt (
|
||||||
"User-Agent: *\nDisallow: /\n\nHost: localhost\nHoST: toto", "domsearch");
|
"User-Agent: *\nDisallow: /\n\nHost: localhost\nHoST: toto", "domsearch");
|
||||||
$res = $robotstxt->errors ();
|
$res = $robotstxt->errors ();
|
||||||
$this->assertSame ($res, [4 => "Multiple Hosts set"]);
|
$this->assertSame ($res, [4 => "Multiple Hosts set"]);
|
||||||
@@ -169,48 +171,48 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
|
|||||||
// URLAllow
|
// URLAllow
|
||||||
public function test_urlallow_1 ()
|
public function test_urlallow_1 ()
|
||||||
{
|
{
|
||||||
$robotstxt = new robotstxt ("", "domsearch");
|
$robotstxt = new Robotstxt ("", "domsearch");
|
||||||
$res = $robotstxt->URLAllow ("/");
|
$res = $robotstxt->URLAllow ("/");
|
||||||
$this->assertSame ($res, true);
|
$this->assertSame ($res, true);
|
||||||
}
|
}
|
||||||
public function test_urlallow_2 ()
|
public function test_urlallow_2 ()
|
||||||
{
|
{
|
||||||
$robotstxt = new robotstxt (
|
$robotstxt = new Robotstxt (
|
||||||
"User-Agent: *\nDisallow: /", "domsearch");
|
"User-Agent: *\nDisallow: /", "domsearch");
|
||||||
$res = $robotstxt->URLAllow ("/");
|
$res = $robotstxt->URLAllow ("/");
|
||||||
$this->assertSame ($res, false);
|
$this->assertSame ($res, false);
|
||||||
}
|
}
|
||||||
public function test_urlallow_3 ()
|
public function test_urlallow_3 ()
|
||||||
{
|
{
|
||||||
$robotstxt = new robotstxt (
|
$robotstxt = new Robotstxt (
|
||||||
"User-Agent: *\nDisallow: /\nAllow: /allow/", "domsearch");
|
"User-Agent: *\nDisallow: /\nAllow: /allow/", "domsearch");
|
||||||
$res = $robotstxt->URLAllow ("/");
|
$res = $robotstxt->URLAllow ("/");
|
||||||
$this->assertSame ($res, false);
|
$this->assertSame ($res, false);
|
||||||
}
|
}
|
||||||
public function test_urlallow_4 ()
|
public function test_urlallow_4 ()
|
||||||
{
|
{
|
||||||
$robotstxt = new robotstxt (
|
$robotstxt = new Robotstxt (
|
||||||
"User-Agent: *\nDisallow: /\nAllow: /allow/", "domsearch");
|
"User-Agent: *\nDisallow: /\nAllow: /allow/", "domsearch");
|
||||||
$res = $robotstxt->URLAllow ("/allow/file");
|
$res = $robotstxt->URLAllow ("/allow/file");
|
||||||
$this->assertSame ($res, true);
|
$this->assertSame ($res, true);
|
||||||
}
|
}
|
||||||
public function test_urlallow_5 ()
|
public function test_urlallow_5 ()
|
||||||
{
|
{
|
||||||
$robotstxt = new robotstxt (
|
$robotstxt = new Robotstxt (
|
||||||
"User-Agent: *\nDisallow: /\nAllow: /allow/*.gif$", "domsearch");
|
"User-Agent: *\nDisallow: /\nAllow: /allow/*.gif$", "domsearch");
|
||||||
$res = $robotstxt->URLAllow ("/allow/file.gif");
|
$res = $robotstxt->URLAllow ("/allow/file.gif");
|
||||||
$this->assertSame ($res, true);
|
$this->assertSame ($res, true);
|
||||||
}
|
}
|
||||||
public function test_urlallow_6 ()
|
public function test_urlallow_6 ()
|
||||||
{
|
{
|
||||||
$robotstxt = new robotstxt (
|
$robotstxt = new Robotstxt (
|
||||||
"User-Agent: *\nDisallow: /\nAllow: /allow/*.gif$", "domsearch");
|
"User-Agent: *\nDisallow: /\nAllow: /allow/*.gif$", "domsearch");
|
||||||
$res = $robotstxt->URLAllow ("/allow/.gif");
|
$res = $robotstxt->URLAllow ("/allow/.gif");
|
||||||
$this->assertSame ($res, false);
|
$this->assertSame ($res, false);
|
||||||
}
|
}
|
||||||
public function test_urlallow_7 ()
|
public function test_urlallow_7 ()
|
||||||
{
|
{
|
||||||
$robotstxt = new robotstxt (
|
$robotstxt = new Robotstxt (
|
||||||
"User-Agent: *\nDisallow: /\nAllow: /allow/*.gif\$", "domsearch");
|
"User-Agent: *\nDisallow: /\nAllow: /allow/*.gif\$", "domsearch");
|
||||||
$res = $robotstxt->URLAllow ("/allow/file.png");
|
$res = $robotstxt->URLAllow ("/allow/file.png");
|
||||||
$this->assertSame ($res, false);
|
$this->assertSame ($res, false);
|
||||||
@@ -220,7 +222,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function test_rfc_unhipbot_1 ()
|
public function test_rfc_unhipbot_1 ()
|
||||||
{
|
{
|
||||||
// {{{
|
// {{{
|
||||||
$robotstxt = new robotstxt (
|
$robotstxt = new Robotstxt (
|
||||||
"# /robots.txt for http://www.fict.org/
|
"# /robots.txt for http://www.fict.org/
|
||||||
# comments to webmaster@fict.org
|
# comments to webmaster@fict.org
|
||||||
|
|
||||||
@@ -245,7 +247,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function test_rfc_unhipbot_2 ()
|
public function test_rfc_unhipbot_2 ()
|
||||||
{
|
{
|
||||||
// {{{
|
// {{{
|
||||||
$robotstxt = new robotstxt (
|
$robotstxt = new Robotstxt (
|
||||||
"# /robots.txt for http://www.fict.org/
|
"# /robots.txt for http://www.fict.org/
|
||||||
# comments to webmaster@fict.org
|
# comments to webmaster@fict.org
|
||||||
|
|
||||||
@@ -270,7 +272,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function test_rfc_unhipbot_3 ()
|
public function test_rfc_unhipbot_3 ()
|
||||||
{
|
{
|
||||||
// {{{
|
// {{{
|
||||||
$robotstxt = new robotstxt (
|
$robotstxt = new Robotstxt (
|
||||||
"# /robots.txt for http://www.fict.org/
|
"# /robots.txt for http://www.fict.org/
|
||||||
# comments to webmaster@fict.org
|
# comments to webmaster@fict.org
|
||||||
|
|
||||||
@@ -295,7 +297,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function test_rfc_unhipbot_4 ()
|
public function test_rfc_unhipbot_4 ()
|
||||||
{
|
{
|
||||||
// {{{
|
// {{{
|
||||||
$robotstxt = new robotstxt (
|
$robotstxt = new Robotstxt (
|
||||||
"# /robots.txt for http://www.fict.org/
|
"# /robots.txt for http://www.fict.org/
|
||||||
# comments to webmaster@fict.org
|
# comments to webmaster@fict.org
|
||||||
|
|
||||||
@@ -320,7 +322,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function test_rfc_unhipbot_5 ()
|
public function test_rfc_unhipbot_5 ()
|
||||||
{
|
{
|
||||||
// {{{
|
// {{{
|
||||||
$robotstxt = new robotstxt (
|
$robotstxt = new Robotstxt (
|
||||||
"# /robots.txt for http://www.fict.org/
|
"# /robots.txt for http://www.fict.org/
|
||||||
# comments to webmaster@fict.org
|
# comments to webmaster@fict.org
|
||||||
|
|
||||||
@@ -345,7 +347,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function test_rfc_unhipbot_6 ()
|
public function test_rfc_unhipbot_6 ()
|
||||||
{
|
{
|
||||||
// {{{
|
// {{{
|
||||||
$robotstxt = new robotstxt (
|
$robotstxt = new Robotstxt (
|
||||||
"# /robots.txt for http://www.fict.org/
|
"# /robots.txt for http://www.fict.org/
|
||||||
# comments to webmaster@fict.org
|
# comments to webmaster@fict.org
|
||||||
|
|
||||||
@@ -370,7 +372,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function test_rfc_unhipbot_7 ()
|
public function test_rfc_unhipbot_7 ()
|
||||||
{
|
{
|
||||||
// {{{
|
// {{{
|
||||||
$robotstxt = new robotstxt (
|
$robotstxt = new Robotstxt (
|
||||||
"# /robots.txt for http://www.fict.org/
|
"# /robots.txt for http://www.fict.org/
|
||||||
# comments to webmaster@fict.org
|
# comments to webmaster@fict.org
|
||||||
|
|
||||||
@@ -395,7 +397,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function test_rfc_unhipbot_8 ()
|
public function test_rfc_unhipbot_8 ()
|
||||||
{
|
{
|
||||||
// {{{
|
// {{{
|
||||||
$robotstxt = new robotstxt (
|
$robotstxt = new Robotstxt (
|
||||||
"# /robots.txt for http://www.fict.org/
|
"# /robots.txt for http://www.fict.org/
|
||||||
# comments to webmaster@fict.org
|
# comments to webmaster@fict.org
|
||||||
|
|
||||||
@@ -420,7 +422,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function test_rfc_unhipbot_9 ()
|
public function test_rfc_unhipbot_9 ()
|
||||||
{
|
{
|
||||||
// {{{
|
// {{{
|
||||||
$robotstxt = new robotstxt (
|
$robotstxt = new Robotstxt (
|
||||||
"# /robots.txt for http://www.fict.org/
|
"# /robots.txt for http://www.fict.org/
|
||||||
# comments to webmaster@fict.org
|
# comments to webmaster@fict.org
|
||||||
|
|
||||||
@@ -445,7 +447,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function test_rfc_unhipbot_10 ()
|
public function test_rfc_unhipbot_10 ()
|
||||||
{
|
{
|
||||||
// {{{
|
// {{{
|
||||||
$robotstxt = new robotstxt (
|
$robotstxt = new Robotstxt (
|
||||||
"# /robots.txt for http://www.fict.org/
|
"# /robots.txt for http://www.fict.org/
|
||||||
# comments to webmaster@fict.org
|
# comments to webmaster@fict.org
|
||||||
|
|
||||||
@@ -470,7 +472,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function test_rfc_unhipbot_11 ()
|
public function test_rfc_unhipbot_11 ()
|
||||||
{
|
{
|
||||||
// {{{
|
// {{{
|
||||||
$robotstxt = new robotstxt (
|
$robotstxt = new Robotstxt (
|
||||||
"# /robots.txt for http://www.fict.org/
|
"# /robots.txt for http://www.fict.org/
|
||||||
# comments to webmaster@fict.org
|
# comments to webmaster@fict.org
|
||||||
|
|
||||||
@@ -495,7 +497,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function test_rfc_webcrawler_1 ()
|
public function test_rfc_webcrawler_1 ()
|
||||||
{
|
{
|
||||||
// {{{
|
// {{{
|
||||||
$robotstxt = new robotstxt (
|
$robotstxt = new Robotstxt (
|
||||||
"# /robots.txt for http://www.fict.org/
|
"# /robots.txt for http://www.fict.org/
|
||||||
# comments to webmaster@fict.org
|
# comments to webmaster@fict.org
|
||||||
|
|
||||||
@@ -520,7 +522,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function test_rfc_webcrawler_2 ()
|
public function test_rfc_webcrawler_2 ()
|
||||||
{
|
{
|
||||||
// {{{
|
// {{{
|
||||||
$robotstxt = new robotstxt (
|
$robotstxt = new Robotstxt (
|
||||||
"# /robots.txt for http://www.fict.org/
|
"# /robots.txt for http://www.fict.org/
|
||||||
# comments to webmaster@fict.org
|
# comments to webmaster@fict.org
|
||||||
|
|
||||||
@@ -545,7 +547,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function test_rfc_webcrawler_3 ()
|
public function test_rfc_webcrawler_3 ()
|
||||||
{
|
{
|
||||||
// {{{
|
// {{{
|
||||||
$robotstxt = new robotstxt (
|
$robotstxt = new Robotstxt (
|
||||||
"# /robots.txt for http://www.fict.org/
|
"# /robots.txt for http://www.fict.org/
|
||||||
# comments to webmaster@fict.org
|
# comments to webmaster@fict.org
|
||||||
|
|
||||||
@@ -570,7 +572,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function test_rfc_webcrawler_4 ()
|
public function test_rfc_webcrawler_4 ()
|
||||||
{
|
{
|
||||||
// {{{
|
// {{{
|
||||||
$robotstxt = new robotstxt (
|
$robotstxt = new Robotstxt (
|
||||||
"# /robots.txt for http://www.fict.org/
|
"# /robots.txt for http://www.fict.org/
|
||||||
# comments to webmaster@fict.org
|
# comments to webmaster@fict.org
|
||||||
|
|
||||||
@@ -595,7 +597,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function test_rfc_webcrawler_5 ()
|
public function test_rfc_webcrawler_5 ()
|
||||||
{
|
{
|
||||||
// {{{
|
// {{{
|
||||||
$robotstxt = new robotstxt (
|
$robotstxt = new Robotstxt (
|
||||||
"# /robots.txt for http://www.fict.org/
|
"# /robots.txt for http://www.fict.org/
|
||||||
# comments to webmaster@fict.org
|
# comments to webmaster@fict.org
|
||||||
|
|
||||||
@@ -620,7 +622,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function test_rfc_webcrawler_6 ()
|
public function test_rfc_webcrawler_6 ()
|
||||||
{
|
{
|
||||||
// {{{
|
// {{{
|
||||||
$robotstxt = new robotstxt (
|
$robotstxt = new Robotstxt (
|
||||||
"# /robots.txt for http://www.fict.org/
|
"# /robots.txt for http://www.fict.org/
|
||||||
# comments to webmaster@fict.org
|
# comments to webmaster@fict.org
|
||||||
|
|
||||||
@@ -645,7 +647,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function test_rfc_webcrawler_7 ()
|
public function test_rfc_webcrawler_7 ()
|
||||||
{
|
{
|
||||||
// {{{
|
// {{{
|
||||||
$robotstxt = new robotstxt (
|
$robotstxt = new Robotstxt (
|
||||||
"# /robots.txt for http://www.fict.org/
|
"# /robots.txt for http://www.fict.org/
|
||||||
# comments to webmaster@fict.org
|
# comments to webmaster@fict.org
|
||||||
|
|
||||||
@@ -670,7 +672,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function test_rfc_webcrawler_8 ()
|
public function test_rfc_webcrawler_8 ()
|
||||||
{
|
{
|
||||||
// {{{
|
// {{{
|
||||||
$robotstxt = new robotstxt (
|
$robotstxt = new Robotstxt (
|
||||||
"# /robots.txt for http://www.fict.org/
|
"# /robots.txt for http://www.fict.org/
|
||||||
# comments to webmaster@fict.org
|
# comments to webmaster@fict.org
|
||||||
|
|
||||||
@@ -695,7 +697,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function test_rfc_webcrawler_9 ()
|
public function test_rfc_webcrawler_9 ()
|
||||||
{
|
{
|
||||||
// {{{
|
// {{{
|
||||||
$robotstxt = new robotstxt (
|
$robotstxt = new Robotstxt (
|
||||||
"# /robots.txt for http://www.fict.org/
|
"# /robots.txt for http://www.fict.org/
|
||||||
# comments to webmaster@fict.org
|
# comments to webmaster@fict.org
|
||||||
|
|
||||||
@@ -720,7 +722,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function test_rfc_webcrawler_10 ()
|
public function test_rfc_webcrawler_10 ()
|
||||||
{
|
{
|
||||||
// {{{
|
// {{{
|
||||||
$robotstxt = new robotstxt (
|
$robotstxt = new Robotstxt (
|
||||||
"# /robots.txt for http://www.fict.org/
|
"# /robots.txt for http://www.fict.org/
|
||||||
# comments to webmaster@fict.org
|
# comments to webmaster@fict.org
|
||||||
|
|
||||||
@@ -745,7 +747,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function test_rfc_webcrawler_11 ()
|
public function test_rfc_webcrawler_11 ()
|
||||||
{
|
{
|
||||||
// {{{
|
// {{{
|
||||||
$robotstxt = new robotstxt (
|
$robotstxt = new Robotstxt (
|
||||||
"# /robots.txt for http://www.fict.org/
|
"# /robots.txt for http://www.fict.org/
|
||||||
# comments to webmaster@fict.org
|
# comments to webmaster@fict.org
|
||||||
|
|
||||||
@@ -770,7 +772,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function test_rfc_excite_1 ()
|
public function test_rfc_excite_1 ()
|
||||||
{
|
{
|
||||||
// {{{
|
// {{{
|
||||||
$robotstxt = new robotstxt (
|
$robotstxt = new Robotstxt (
|
||||||
"# /robots.txt for http://www.fict.org/
|
"# /robots.txt for http://www.fict.org/
|
||||||
# comments to webmaster@fict.org
|
# comments to webmaster@fict.org
|
||||||
|
|
||||||
@@ -795,7 +797,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function test_rfc_excite_2 ()
|
public function test_rfc_excite_2 ()
|
||||||
{
|
{
|
||||||
// {{{
|
// {{{
|
||||||
$robotstxt = new robotstxt (
|
$robotstxt = new Robotstxt (
|
||||||
"# /robots.txt for http://www.fict.org/
|
"# /robots.txt for http://www.fict.org/
|
||||||
# comments to webmaster@fict.org
|
# comments to webmaster@fict.org
|
||||||
|
|
||||||
@@ -820,7 +822,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function test_rfc_excite_3 ()
|
public function test_rfc_excite_3 ()
|
||||||
{
|
{
|
||||||
// {{{
|
// {{{
|
||||||
$robotstxt = new robotstxt (
|
$robotstxt = new Robotstxt (
|
||||||
"# /robots.txt for http://www.fict.org/
|
"# /robots.txt for http://www.fict.org/
|
||||||
# comments to webmaster@fict.org
|
# comments to webmaster@fict.org
|
||||||
|
|
||||||
@@ -845,7 +847,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function test_rfc_excite_4 ()
|
public function test_rfc_excite_4 ()
|
||||||
{
|
{
|
||||||
// {{{
|
// {{{
|
||||||
$robotstxt = new robotstxt (
|
$robotstxt = new Robotstxt (
|
||||||
"# /robots.txt for http://www.fict.org/
|
"# /robots.txt for http://www.fict.org/
|
||||||
# comments to webmaster@fict.org
|
# comments to webmaster@fict.org
|
||||||
|
|
||||||
@@ -870,7 +872,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function test_rfc_excite_5 ()
|
public function test_rfc_excite_5 ()
|
||||||
{
|
{
|
||||||
// {{{
|
// {{{
|
||||||
$robotstxt = new robotstxt (
|
$robotstxt = new Robotstxt (
|
||||||
"# /robots.txt for http://www.fict.org/
|
"# /robots.txt for http://www.fict.org/
|
||||||
# comments to webmaster@fict.org
|
# comments to webmaster@fict.org
|
||||||
|
|
||||||
@@ -895,7 +897,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function test_rfc_excite_6 ()
|
public function test_rfc_excite_6 ()
|
||||||
{
|
{
|
||||||
// {{{
|
// {{{
|
||||||
$robotstxt = new robotstxt (
|
$robotstxt = new Robotstxt (
|
||||||
"# /robots.txt for http://www.fict.org/
|
"# /robots.txt for http://www.fict.org/
|
||||||
# comments to webmaster@fict.org
|
# comments to webmaster@fict.org
|
||||||
|
|
||||||
@@ -920,7 +922,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function test_rfc_excite_7 ()
|
public function test_rfc_excite_7 ()
|
||||||
{
|
{
|
||||||
// {{{
|
// {{{
|
||||||
$robotstxt = new robotstxt (
|
$robotstxt = new Robotstxt (
|
||||||
"# /robots.txt for http://www.fict.org/
|
"# /robots.txt for http://www.fict.org/
|
||||||
# comments to webmaster@fict.org
|
# comments to webmaster@fict.org
|
||||||
|
|
||||||
@@ -945,7 +947,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function test_rfc_excite_8 ()
|
public function test_rfc_excite_8 ()
|
||||||
{
|
{
|
||||||
// {{{
|
// {{{
|
||||||
$robotstxt = new robotstxt (
|
$robotstxt = new Robotstxt (
|
||||||
"# /robots.txt for http://www.fict.org/
|
"# /robots.txt for http://www.fict.org/
|
||||||
# comments to webmaster@fict.org
|
# comments to webmaster@fict.org
|
||||||
|
|
||||||
@@ -970,7 +972,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function test_rfc_excite_9 ()
|
public function test_rfc_excite_9 ()
|
||||||
{
|
{
|
||||||
// {{{
|
// {{{
|
||||||
$robotstxt = new robotstxt (
|
$robotstxt = new Robotstxt (
|
||||||
"# /robots.txt for http://www.fict.org/
|
"# /robots.txt for http://www.fict.org/
|
||||||
# comments to webmaster@fict.org
|
# comments to webmaster@fict.org
|
||||||
|
|
||||||
@@ -995,7 +997,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function test_rfc_excite_10 ()
|
public function test_rfc_excite_10 ()
|
||||||
{
|
{
|
||||||
// {{{
|
// {{{
|
||||||
$robotstxt = new robotstxt (
|
$robotstxt = new Robotstxt (
|
||||||
"# /robots.txt for http://www.fict.org/
|
"# /robots.txt for http://www.fict.org/
|
||||||
# comments to webmaster@fict.org
|
# comments to webmaster@fict.org
|
||||||
|
|
||||||
@@ -1020,7 +1022,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function test_rfc_excite_11 ()
|
public function test_rfc_excite_11 ()
|
||||||
{
|
{
|
||||||
// {{{
|
// {{{
|
||||||
$robotstxt = new robotstxt (
|
$robotstxt = new Robotstxt (
|
||||||
"# /robots.txt for http://www.fict.org/
|
"# /robots.txt for http://www.fict.org/
|
||||||
# comments to webmaster@fict.org
|
# comments to webmaster@fict.org
|
||||||
|
|
||||||
@@ -1045,7 +1047,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function test_rfc_other_1 ()
|
public function test_rfc_other_1 ()
|
||||||
{
|
{
|
||||||
// {{{
|
// {{{
|
||||||
$robotstxt = new robotstxt (
|
$robotstxt = new Robotstxt (
|
||||||
"# /robots.txt for http://www.fict.org/
|
"# /robots.txt for http://www.fict.org/
|
||||||
# comments to webmaster@fict.org
|
# comments to webmaster@fict.org
|
||||||
|
|
||||||
@@ -1069,7 +1071,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function test_rfc_other_2 ()
|
public function test_rfc_other_2 ()
|
||||||
{
|
{
|
||||||
// {{{
|
// {{{
|
||||||
$robotstxt = new robotstxt (
|
$robotstxt = new Robotstxt (
|
||||||
"# /robots.txt for http://www.fict.org/
|
"# /robots.txt for http://www.fict.org/
|
||||||
# comments to webmaster@fict.org
|
# comments to webmaster@fict.org
|
||||||
|
|
||||||
@@ -1094,7 +1096,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function test_rfc_other_3 ()
|
public function test_rfc_other_3 ()
|
||||||
{
|
{
|
||||||
// {{{
|
// {{{
|
||||||
$robotstxt = new robotstxt (
|
$robotstxt = new Robotstxt (
|
||||||
"# /robots.txt for http://www.fict.org/
|
"# /robots.txt for http://www.fict.org/
|
||||||
# comments to webmaster@fict.org
|
# comments to webmaster@fict.org
|
||||||
|
|
||||||
@@ -1119,7 +1121,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function test_rfc_other_4 ()
|
public function test_rfc_other_4 ()
|
||||||
{
|
{
|
||||||
// {{{
|
// {{{
|
||||||
$robotstxt = new robotstxt (
|
$robotstxt = new Robotstxt (
|
||||||
"# /robots.txt for http://www.fict.org/
|
"# /robots.txt for http://www.fict.org/
|
||||||
# comments to webmaster@fict.org
|
# comments to webmaster@fict.org
|
||||||
|
|
||||||
@@ -1144,7 +1146,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function test_rfc_other_5 ()
|
public function test_rfc_other_5 ()
|
||||||
{
|
{
|
||||||
// {{{
|
// {{{
|
||||||
$robotstxt = new robotstxt (
|
$robotstxt = new Robotstxt (
|
||||||
"# /robots.txt for http://www.fict.org/
|
"# /robots.txt for http://www.fict.org/
|
||||||
# comments to webmaster@fict.org
|
# comments to webmaster@fict.org
|
||||||
|
|
||||||
@@ -1169,7 +1171,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function test_rfc_other_6 ()
|
public function test_rfc_other_6 ()
|
||||||
{
|
{
|
||||||
// {{{
|
// {{{
|
||||||
$robotstxt = new robotstxt (
|
$robotstxt = new Robotstxt (
|
||||||
"# /robots.txt for http://www.fict.org/
|
"# /robots.txt for http://www.fict.org/
|
||||||
# comments to webmaster@fict.org
|
# comments to webmaster@fict.org
|
||||||
|
|
||||||
@@ -1194,7 +1196,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function test_rfc_other_7 ()
|
public function test_rfc_other_7 ()
|
||||||
{
|
{
|
||||||
// {{{
|
// {{{
|
||||||
$robotstxt = new robotstxt (
|
$robotstxt = new Robotstxt (
|
||||||
"# /robots.txt for http://www.fict.org/
|
"# /robots.txt for http://www.fict.org/
|
||||||
# comments to webmaster@fict.org
|
# comments to webmaster@fict.org
|
||||||
|
|
||||||
@@ -1219,7 +1221,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function test_rfc_other_8 ()
|
public function test_rfc_other_8 ()
|
||||||
{
|
{
|
||||||
// {{{
|
// {{{
|
||||||
$robotstxt = new robotstxt (
|
$robotstxt = new Robotstxt (
|
||||||
"# /robots.txt for http://www.fict.org/
|
"# /robots.txt for http://www.fict.org/
|
||||||
# comments to webmaster@fict.org
|
# comments to webmaster@fict.org
|
||||||
|
|
||||||
@@ -1244,7 +1246,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function test_rfc_other_9 ()
|
public function test_rfc_other_9 ()
|
||||||
{
|
{
|
||||||
// {{{
|
// {{{
|
||||||
$robotstxt = new robotstxt (
|
$robotstxt = new Robotstxt (
|
||||||
"# /robots.txt for http://www.fict.org/
|
"# /robots.txt for http://www.fict.org/
|
||||||
# comments to webmaster@fict.org
|
# comments to webmaster@fict.org
|
||||||
|
|
||||||
@@ -1269,7 +1271,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function test_rfc_other_10 ()
|
public function test_rfc_other_10 ()
|
||||||
{
|
{
|
||||||
// {{{
|
// {{{
|
||||||
$robotstxt = new robotstxt (
|
$robotstxt = new Robotstxt (
|
||||||
"# /robots.txt for http://www.fict.org/
|
"# /robots.txt for http://www.fict.org/
|
||||||
# comments to webmaster@fict.org
|
# comments to webmaster@fict.org
|
||||||
|
|
||||||
@@ -1294,7 +1296,7 @@ class robotstxtTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function test_rfc_other_11 ()
|
public function test_rfc_other_11 ()
|
||||||
{
|
{
|
||||||
// {{{
|
// {{{
|
||||||
$robotstxt = new robotstxt (
|
$robotstxt = new Robotstxt (
|
||||||
"# /robots.txt for http://www.fict.org/
|
"# /robots.txt for http://www.fict.org/
|
||||||
# comments to webmaster@fict.org
|
# comments to webmaster@fict.org
|
||||||
|
|
||||||
|
|||||||
@@ -7,14 +7,16 @@
|
|||||||
|
|
||||||
namespace Domframework\Tests;
|
namespace Domframework\Tests;
|
||||||
|
|
||||||
/** Test the route.php file */
|
use Domframework\Route;
|
||||||
class routeTest extends \PHPUnit_Framework_TestCase
|
|
||||||
|
/** Test the Route.php file */
|
||||||
|
class RouteTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
/// RELATIVE ///
|
/// RELATIVE ///
|
||||||
/** Entry null */
|
/** Entry null */
|
||||||
public function test_baseURL_1_relative ()
|
public function test_baseURL_1_relative ()
|
||||||
{
|
{
|
||||||
$route = new route ();
|
$route = new Route ();
|
||||||
$route->baseURL ();
|
$route->baseURL ();
|
||||||
$this->expectOutputString("");
|
$this->expectOutputString("");
|
||||||
}
|
}
|
||||||
@@ -25,7 +27,7 @@ class routeTest extends \PHPUnit_Framework_TestCase
|
|||||||
$_SERVER["SERVER_NAME"] = "localhost";
|
$_SERVER["SERVER_NAME"] = "localhost";
|
||||||
$_SERVER["SERVER_PORT"] = "80";
|
$_SERVER["SERVER_PORT"] = "80";
|
||||||
$_SERVER["SCRIPT_NAME"] = "/index.php";
|
$_SERVER["SCRIPT_NAME"] = "/index.php";
|
||||||
$route = new route ();
|
$route = new Route ();
|
||||||
echo $route->baseURL ();
|
echo $route->baseURL ();
|
||||||
$this->expectOutputString("/");
|
$this->expectOutputString("/");
|
||||||
}
|
}
|
||||||
@@ -38,7 +40,7 @@ class routeTest extends \PHPUnit_Framework_TestCase
|
|||||||
$_SERVER["SERVER_PORT"] = "443";
|
$_SERVER["SERVER_PORT"] = "443";
|
||||||
$_SERVER["HTTPS"] = true;
|
$_SERVER["HTTPS"] = true;
|
||||||
$_SERVER["SCRIPT_NAME"] = "/index.php";
|
$_SERVER["SCRIPT_NAME"] = "/index.php";
|
||||||
$route = new route ();
|
$route = new Route ();
|
||||||
echo $route->baseURL ();
|
echo $route->baseURL ();
|
||||||
$this->expectOutputString("/");
|
$this->expectOutputString("/");
|
||||||
}
|
}
|
||||||
@@ -50,7 +52,7 @@ class routeTest extends \PHPUnit_Framework_TestCase
|
|||||||
$_SERVER["SERVER_NAME"] = "localhost";
|
$_SERVER["SERVER_NAME"] = "localhost";
|
||||||
$_SERVER["SERVER_PORT"] = "888";
|
$_SERVER["SERVER_PORT"] = "888";
|
||||||
$_SERVER["SCRIPT_NAME"] = "/index.php";
|
$_SERVER["SCRIPT_NAME"] = "/index.php";
|
||||||
$route = new route ();
|
$route = new Route ();
|
||||||
echo $route->baseURL ();
|
echo $route->baseURL ();
|
||||||
$this->expectOutputString("/");
|
$this->expectOutputString("/");
|
||||||
}
|
}
|
||||||
@@ -62,7 +64,7 @@ class routeTest extends \PHPUnit_Framework_TestCase
|
|||||||
$_SERVER["SERVER_PORT"] = "888";
|
$_SERVER["SERVER_PORT"] = "888";
|
||||||
$_SERVER["HTTPS"] = true;
|
$_SERVER["HTTPS"] = true;
|
||||||
$_SERVER["SCRIPT_NAME"] = "/index.php";
|
$_SERVER["SCRIPT_NAME"] = "/index.php";
|
||||||
$route = new route ();
|
$route = new Route ();
|
||||||
echo $route->baseURL ();
|
echo $route->baseURL ();
|
||||||
$this->expectOutputString("/");
|
$this->expectOutputString("/");
|
||||||
}
|
}
|
||||||
@@ -74,7 +76,7 @@ class routeTest extends \PHPUnit_Framework_TestCase
|
|||||||
$_SERVER["SERVER_NAME"] = "localhost";
|
$_SERVER["SERVER_NAME"] = "localhost";
|
||||||
$_SERVER["SERVER_PORT"] = "80";
|
$_SERVER["SERVER_PORT"] = "80";
|
||||||
$_SERVER["SCRIPT_NAME"] = "/module/index.php";
|
$_SERVER["SCRIPT_NAME"] = "/module/index.php";
|
||||||
$route = new route ();
|
$route = new Route ();
|
||||||
echo $route->baseURL ("module");
|
echo $route->baseURL ("module");
|
||||||
$this->expectOutputString("/");
|
$this->expectOutputString("/");
|
||||||
}
|
}
|
||||||
@@ -86,7 +88,7 @@ class routeTest extends \PHPUnit_Framework_TestCase
|
|||||||
$_SERVER["SERVER_PORT"] = "443";
|
$_SERVER["SERVER_PORT"] = "443";
|
||||||
$_SERVER["HTTPS"] = true;
|
$_SERVER["HTTPS"] = true;
|
||||||
$_SERVER["SCRIPT_NAME"] = "/module/index.php";
|
$_SERVER["SCRIPT_NAME"] = "/module/index.php";
|
||||||
$route = new route ();
|
$route = new Route ();
|
||||||
echo $route->baseURL ("module");
|
echo $route->baseURL ("module");
|
||||||
$this->expectOutputString("/");
|
$this->expectOutputString("/");
|
||||||
}
|
}
|
||||||
@@ -98,7 +100,7 @@ class routeTest extends \PHPUnit_Framework_TestCase
|
|||||||
$_SERVER["SERVER_NAME"] = "localhost";
|
$_SERVER["SERVER_NAME"] = "localhost";
|
||||||
$_SERVER["SERVER_PORT"] = "888";
|
$_SERVER["SERVER_PORT"] = "888";
|
||||||
$_SERVER["SCRIPT_NAME"] = "/module/index.php";
|
$_SERVER["SCRIPT_NAME"] = "/module/index.php";
|
||||||
$route = new route ();
|
$route = new Route ();
|
||||||
echo $route->baseURL ("module");
|
echo $route->baseURL ("module");
|
||||||
$this->expectOutputString("/");
|
$this->expectOutputString("/");
|
||||||
}
|
}
|
||||||
@@ -110,7 +112,7 @@ class routeTest extends \PHPUnit_Framework_TestCase
|
|||||||
$_SERVER["SERVER_PORT"] = "888";
|
$_SERVER["SERVER_PORT"] = "888";
|
||||||
$_SERVER["HTTPS"] = true;
|
$_SERVER["HTTPS"] = true;
|
||||||
$_SERVER["SCRIPT_NAME"] = "/module/index.php";
|
$_SERVER["SCRIPT_NAME"] = "/module/index.php";
|
||||||
$route = new route ();
|
$route = new Route ();
|
||||||
echo $route->baseURL ("module");
|
echo $route->baseURL ("module");
|
||||||
$this->expectOutputString("/");
|
$this->expectOutputString("/");
|
||||||
}
|
}
|
||||||
@@ -119,7 +121,7 @@ class routeTest extends \PHPUnit_Framework_TestCase
|
|||||||
/** Entry null */
|
/** Entry null */
|
||||||
public function test_baseURL_1_absolute ()
|
public function test_baseURL_1_absolute ()
|
||||||
{
|
{
|
||||||
$route = new route ();
|
$route = new Route ();
|
||||||
$route->baseURL (false, true);
|
$route->baseURL (false, true);
|
||||||
$this->expectOutputString("");
|
$this->expectOutputString("");
|
||||||
}
|
}
|
||||||
@@ -130,7 +132,7 @@ class routeTest extends \PHPUnit_Framework_TestCase
|
|||||||
$_SERVER["SERVER_NAME"] = "localhost";
|
$_SERVER["SERVER_NAME"] = "localhost";
|
||||||
$_SERVER["SERVER_PORT"] = "80";
|
$_SERVER["SERVER_PORT"] = "80";
|
||||||
$_SERVER["SCRIPT_NAME"] = "/index.php";
|
$_SERVER["SCRIPT_NAME"] = "/index.php";
|
||||||
$route = new route ();
|
$route = new Route ();
|
||||||
echo $route->baseURL (false, true);
|
echo $route->baseURL (false, true);
|
||||||
$this->expectOutputString("https://localhost:80/");
|
$this->expectOutputString("https://localhost:80/");
|
||||||
}
|
}
|
||||||
@@ -143,7 +145,7 @@ class routeTest extends \PHPUnit_Framework_TestCase
|
|||||||
$_SERVER["SERVER_PORT"] = "443";
|
$_SERVER["SERVER_PORT"] = "443";
|
||||||
$_SERVER["HTTPS"] = true;
|
$_SERVER["HTTPS"] = true;
|
||||||
$_SERVER["SCRIPT_NAME"] = "/index.php";
|
$_SERVER["SCRIPT_NAME"] = "/index.php";
|
||||||
$route = new route ();
|
$route = new Route ();
|
||||||
echo $route->baseURL (false, true);
|
echo $route->baseURL (false, true);
|
||||||
$this->expectOutputString("https://localhost/");
|
$this->expectOutputString("https://localhost/");
|
||||||
}
|
}
|
||||||
@@ -155,7 +157,7 @@ class routeTest extends \PHPUnit_Framework_TestCase
|
|||||||
$_SERVER["SERVER_NAME"] = "localhost";
|
$_SERVER["SERVER_NAME"] = "localhost";
|
||||||
$_SERVER["SERVER_PORT"] = "888";
|
$_SERVER["SERVER_PORT"] = "888";
|
||||||
$_SERVER["SCRIPT_NAME"] = "/index.php";
|
$_SERVER["SCRIPT_NAME"] = "/index.php";
|
||||||
$route = new route ();
|
$route = new Route ();
|
||||||
echo $route->baseURL (false, true);
|
echo $route->baseURL (false, true);
|
||||||
$this->expectOutputString("http://localhost:888/");
|
$this->expectOutputString("http://localhost:888/");
|
||||||
}
|
}
|
||||||
@@ -167,7 +169,7 @@ class routeTest extends \PHPUnit_Framework_TestCase
|
|||||||
$_SERVER["SERVER_PORT"] = "888";
|
$_SERVER["SERVER_PORT"] = "888";
|
||||||
$_SERVER["HTTPS"] = true;
|
$_SERVER["HTTPS"] = true;
|
||||||
$_SERVER["SCRIPT_NAME"] = "/index.php";
|
$_SERVER["SCRIPT_NAME"] = "/index.php";
|
||||||
$route = new route ();
|
$route = new Route ();
|
||||||
echo $route->baseURL (false, true);
|
echo $route->baseURL (false, true);
|
||||||
$this->expectOutputString("https://localhost:888/");
|
$this->expectOutputString("https://localhost:888/");
|
||||||
}
|
}
|
||||||
@@ -179,7 +181,7 @@ class routeTest extends \PHPUnit_Framework_TestCase
|
|||||||
$_SERVER["SERVER_NAME"] = "localhost";
|
$_SERVER["SERVER_NAME"] = "localhost";
|
||||||
$_SERVER["SERVER_PORT"] = "80";
|
$_SERVER["SERVER_PORT"] = "80";
|
||||||
$_SERVER["SCRIPT_NAME"] = "/module/index.php";
|
$_SERVER["SCRIPT_NAME"] = "/module/index.php";
|
||||||
$route = new route ();
|
$route = new Route ();
|
||||||
echo $route->baseURL ("module", true);
|
echo $route->baseURL ("module", true);
|
||||||
$this->expectOutputString("http://localhost/");
|
$this->expectOutputString("http://localhost/");
|
||||||
}
|
}
|
||||||
@@ -191,7 +193,7 @@ class routeTest extends \PHPUnit_Framework_TestCase
|
|||||||
$_SERVER["SERVER_PORT"] = "443";
|
$_SERVER["SERVER_PORT"] = "443";
|
||||||
$_SERVER["HTTPS"] = true;
|
$_SERVER["HTTPS"] = true;
|
||||||
$_SERVER["SCRIPT_NAME"] = "/module/index.php";
|
$_SERVER["SCRIPT_NAME"] = "/module/index.php";
|
||||||
$route = new route ();
|
$route = new Route ();
|
||||||
echo $route->baseURL ("module", true);
|
echo $route->baseURL ("module", true);
|
||||||
$this->expectOutputString("https://localhost/");
|
$this->expectOutputString("https://localhost/");
|
||||||
}
|
}
|
||||||
@@ -203,7 +205,7 @@ class routeTest extends \PHPUnit_Framework_TestCase
|
|||||||
$_SERVER["SERVER_NAME"] = "localhost";
|
$_SERVER["SERVER_NAME"] = "localhost";
|
||||||
$_SERVER["SERVER_PORT"] = "888";
|
$_SERVER["SERVER_PORT"] = "888";
|
||||||
$_SERVER["SCRIPT_NAME"] = "/module/index.php";
|
$_SERVER["SCRIPT_NAME"] = "/module/index.php";
|
||||||
$route = new route ();
|
$route = new Route ();
|
||||||
echo $route->baseURL ("module", true);
|
echo $route->baseURL ("module", true);
|
||||||
$this->expectOutputString("http://localhost:888/");
|
$this->expectOutputString("http://localhost:888/");
|
||||||
}
|
}
|
||||||
@@ -215,7 +217,7 @@ class routeTest extends \PHPUnit_Framework_TestCase
|
|||||||
$_SERVER["SERVER_PORT"] = "888";
|
$_SERVER["SERVER_PORT"] = "888";
|
||||||
$_SERVER["HTTPS"] = true;
|
$_SERVER["HTTPS"] = true;
|
||||||
$_SERVER["SCRIPT_NAME"] = "/module/index.php";
|
$_SERVER["SCRIPT_NAME"] = "/module/index.php";
|
||||||
$route = new route ();
|
$route = new Route ();
|
||||||
echo $route->baseURL ("module", true);
|
echo $route->baseURL ("module", true);
|
||||||
$this->expectOutputString("https://localhost:888/");
|
$this->expectOutputString("https://localhost:888/");
|
||||||
}
|
}
|
||||||
@@ -229,7 +231,7 @@ class routeTest extends \PHPUnit_Framework_TestCase
|
|||||||
$_SERVER["SERVER_PORT"] = "80";
|
$_SERVER["SERVER_PORT"] = "80";
|
||||||
$_SERVER["SCRIPT_NAME"] = "/index.php";
|
$_SERVER["SCRIPT_NAME"] = "/index.php";
|
||||||
$_SERVER["REQUEST_URI"] = "/index.php?url=bla";
|
$_SERVER["REQUEST_URI"] = "/index.php?url=bla";
|
||||||
$route = new route ();
|
$route = new Route ();
|
||||||
echo $route->requestURL ();
|
echo $route->requestURL ();
|
||||||
$this->expectOutputString("index.php?url=bla");
|
$this->expectOutputString("index.php?url=bla");
|
||||||
}
|
}
|
||||||
@@ -242,7 +244,7 @@ class routeTest extends \PHPUnit_Framework_TestCase
|
|||||||
$_SERVER["HTTPS"] = true;
|
$_SERVER["HTTPS"] = true;
|
||||||
$_SERVER["SCRIPT_NAME"] = "/index.php";
|
$_SERVER["SCRIPT_NAME"] = "/index.php";
|
||||||
$_SERVER["REQUEST_URI"] = "/index.php?var=1";
|
$_SERVER["REQUEST_URI"] = "/index.php?var=1";
|
||||||
$route = new route ();
|
$route = new Route ();
|
||||||
echo $route->requestURL ();
|
echo $route->requestURL ();
|
||||||
$this->expectOutputString("index.php?var=1");
|
$this->expectOutputString("index.php?var=1");
|
||||||
}
|
}
|
||||||
@@ -255,7 +257,7 @@ class routeTest extends \PHPUnit_Framework_TestCase
|
|||||||
$_SERVER["SERVER_PORT"] = "888";
|
$_SERVER["SERVER_PORT"] = "888";
|
||||||
$_SERVER["SCRIPT_NAME"] = "/index.php";
|
$_SERVER["SCRIPT_NAME"] = "/index.php";
|
||||||
$_SERVER["REQUEST_URI"] = "/index.php?var=1";
|
$_SERVER["REQUEST_URI"] = "/index.php?var=1";
|
||||||
$route = new route ();
|
$route = new Route ();
|
||||||
echo $route->requestURL ();
|
echo $route->requestURL ();
|
||||||
$this->expectOutputString("index.php?var=1");
|
$this->expectOutputString("index.php?var=1");
|
||||||
}
|
}
|
||||||
@@ -268,7 +270,7 @@ class routeTest extends \PHPUnit_Framework_TestCase
|
|||||||
$_SERVER["HTTPS"] = true;
|
$_SERVER["HTTPS"] = true;
|
||||||
$_SERVER["SCRIPT_NAME"] = "/index.php";
|
$_SERVER["SCRIPT_NAME"] = "/index.php";
|
||||||
$_SERVER["REQUEST_URI"] = "/index.php?var=1";
|
$_SERVER["REQUEST_URI"] = "/index.php?var=1";
|
||||||
$route = new route ();
|
$route = new Route ();
|
||||||
echo $route->requestURL ();
|
echo $route->requestURL ();
|
||||||
$this->expectOutputString("index.php?var=1");
|
$this->expectOutputString("index.php?var=1");
|
||||||
}
|
}
|
||||||
@@ -281,7 +283,7 @@ class routeTest extends \PHPUnit_Framework_TestCase
|
|||||||
$_SERVER["SERVER_PORT"] = "80";
|
$_SERVER["SERVER_PORT"] = "80";
|
||||||
$_SERVER["SCRIPT_NAME"] = "/index.php";
|
$_SERVER["SCRIPT_NAME"] = "/index.php";
|
||||||
$_SERVER["REQUEST_URI"] = "/bla";
|
$_SERVER["REQUEST_URI"] = "/bla";
|
||||||
$route = new route ();
|
$route = new Route ();
|
||||||
echo $route->requestURL ();
|
echo $route->requestURL ();
|
||||||
$this->expectOutputString("bla");
|
$this->expectOutputString("bla");
|
||||||
}
|
}
|
||||||
@@ -294,7 +296,7 @@ class routeTest extends \PHPUnit_Framework_TestCase
|
|||||||
$_SERVER["HTTPS"] = true;
|
$_SERVER["HTTPS"] = true;
|
||||||
$_SERVER["SCRIPT_NAME"] = "/index.php";
|
$_SERVER["SCRIPT_NAME"] = "/index.php";
|
||||||
$_SERVER["REQUEST_URI"] = "/var=1";
|
$_SERVER["REQUEST_URI"] = "/var=1";
|
||||||
$route = new route ();
|
$route = new Route ();
|
||||||
echo $route->requestURL ();
|
echo $route->requestURL ();
|
||||||
$this->expectOutputString("var=1");
|
$this->expectOutputString("var=1");
|
||||||
}
|
}
|
||||||
@@ -307,7 +309,7 @@ class routeTest extends \PHPUnit_Framework_TestCase
|
|||||||
$_SERVER["SERVER_PORT"] = "888";
|
$_SERVER["SERVER_PORT"] = "888";
|
||||||
$_SERVER["SCRIPT_NAME"] = "/index.php";
|
$_SERVER["SCRIPT_NAME"] = "/index.php";
|
||||||
$_SERVER["REQUEST_URI"] = "/var=1";
|
$_SERVER["REQUEST_URI"] = "/var=1";
|
||||||
$route = new route ();
|
$route = new Route ();
|
||||||
echo $route->requestURL ();
|
echo $route->requestURL ();
|
||||||
$this->expectOutputString("var=1");
|
$this->expectOutputString("var=1");
|
||||||
}
|
}
|
||||||
@@ -320,7 +322,7 @@ class routeTest extends \PHPUnit_Framework_TestCase
|
|||||||
$_SERVER["HTTPS"] = true;
|
$_SERVER["HTTPS"] = true;
|
||||||
$_SERVER["SCRIPT_NAME"] = "/index.php";
|
$_SERVER["SCRIPT_NAME"] = "/index.php";
|
||||||
$_SERVER["REQUEST_URI"] = "/var=1";
|
$_SERVER["REQUEST_URI"] = "/var=1";
|
||||||
$route = new route ();
|
$route = new Route ();
|
||||||
echo $route->requestURL ();
|
echo $route->requestURL ();
|
||||||
$this->expectOutputString("var=1");
|
$this->expectOutputString("var=1");
|
||||||
}
|
}
|
||||||
@@ -328,7 +330,7 @@ class routeTest extends \PHPUnit_Framework_TestCase
|
|||||||
/** Ratelimiting in errors */
|
/** Ratelimiting in errors */
|
||||||
public function test_errorRateLimit1 ()
|
public function test_errorRateLimit1 ()
|
||||||
{
|
{
|
||||||
$route = new route ();
|
$route = new Route ();
|
||||||
$route->ratelimiter->storageDir = "/tmp/ratelimit-".time();
|
$route->ratelimiter->storageDir = "/tmp/ratelimit-".time();
|
||||||
$route->error (new \Exception ("test1", 500));
|
$route->error (new \Exception ("test1", 500));
|
||||||
$route->error (new \Exception ("test2", 500));
|
$route->error (new \Exception ("test2", 500));
|
||||||
|
|||||||
@@ -7,21 +7,23 @@
|
|||||||
|
|
||||||
namespace Domframework\Tests;
|
namespace Domframework\Tests;
|
||||||
|
|
||||||
|
use Domframework\Rss;
|
||||||
|
|
||||||
/** Test the RSS */
|
/** Test the RSS */
|
||||||
class rssTest extends \PHPUnit_Framework_TestCase
|
class RssTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
public function test_empty0 ()
|
public function test_empty0 ()
|
||||||
{
|
{
|
||||||
// Empty
|
// Empty
|
||||||
$this->expectException ("Exception", "No title is provided for this RSS");
|
$this->expectException ("Exception", "No title is provided for this RSS");
|
||||||
$rss = new rss ();
|
$rss = new Rss ();
|
||||||
$res = $rss->asXML ();
|
$res = $rss->asXML ();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_functional1 ()
|
public function test_functional1 ()
|
||||||
{
|
{
|
||||||
// Functionnal 1
|
// Functionnal 1
|
||||||
$rss = new rss ();
|
$rss = new Rss ();
|
||||||
$rss->title ("Global Title")
|
$rss->title ("Global Title")
|
||||||
->link ("http://localhost")
|
->link ("http://localhost")
|
||||||
->language ("fr-fr")
|
->language ("fr-fr")
|
||||||
@@ -62,7 +64,7 @@ class rssTest extends \PHPUnit_Framework_TestCase
|
|||||||
// Missing global description
|
// Missing global description
|
||||||
$this->expectException ("Exception",
|
$this->expectException ("Exception",
|
||||||
"No description is provided for this RSS");
|
"No description is provided for this RSS");
|
||||||
$rss = new rss ();
|
$rss = new Rss ();
|
||||||
$rss->title ("Global Title")
|
$rss->title ("Global Title")
|
||||||
->link ("http://localhost")
|
->link ("http://localhost")
|
||||||
->language ("fr-fr");
|
->language ("fr-fr");
|
||||||
@@ -73,7 +75,7 @@ class rssTest extends \PHPUnit_Framework_TestCase
|
|||||||
{
|
{
|
||||||
// Missing global link
|
// Missing global link
|
||||||
$this->expectException ("Exception", "No link is provided for this RSS");
|
$this->expectException ("Exception", "No link is provided for this RSS");
|
||||||
$rss = new rss ();
|
$rss = new Rss ();
|
||||||
$rss->title ("Global Title")
|
$rss->title ("Global Title")
|
||||||
->language ("fr-fr")
|
->language ("fr-fr")
|
||||||
->description ("The Super Global Description");
|
->description ("The Super Global Description");
|
||||||
@@ -84,7 +86,7 @@ class rssTest extends \PHPUnit_Framework_TestCase
|
|||||||
{
|
{
|
||||||
// Missing global title
|
// Missing global title
|
||||||
$this->expectException ("Exception", "No title is provided for this RSS");
|
$this->expectException ("Exception", "No title is provided for this RSS");
|
||||||
$rss = new rss ();
|
$rss = new Rss ();
|
||||||
$rss->link ("http://localhost")
|
$rss->link ("http://localhost")
|
||||||
->language ("fr-fr")
|
->language ("fr-fr")
|
||||||
->description ("The Super Global Description");
|
->description ("The Super Global Description");
|
||||||
@@ -96,7 +98,7 @@ class rssTest extends \PHPUnit_Framework_TestCase
|
|||||||
// Invalid date provided
|
// Invalid date provided
|
||||||
$this->expectException ("Exception",
|
$this->expectException ("Exception",
|
||||||
"lastBuildDate provided to RSS is not a valid date");
|
"lastBuildDate provided to RSS is not a valid date");
|
||||||
$rss = new rss ();
|
$rss = new Rss ();
|
||||||
$rss->title ("Global Title")
|
$rss->title ("Global Title")
|
||||||
->link ("http://localhost")
|
->link ("http://localhost")
|
||||||
->lastBuildDate ("2017-04-33")
|
->lastBuildDate ("2017-04-33")
|
||||||
@@ -110,7 +112,7 @@ class rssTest extends \PHPUnit_Framework_TestCase
|
|||||||
// Empty Item provided
|
// Empty Item provided
|
||||||
$this->expectException ("Exception",
|
$this->expectException ("Exception",
|
||||||
"No title nor description defined in the RSS item");
|
"No title nor description defined in the RSS item");
|
||||||
$rss = new rss ();
|
$rss = new Rss ();
|
||||||
$rss->title ("Global Title")
|
$rss->title ("Global Title")
|
||||||
->link ("http://localhost")
|
->link ("http://localhost")
|
||||||
->lastBuildDate ("2017-04-30 12:35:32")
|
->lastBuildDate ("2017-04-30 12:35:32")
|
||||||
@@ -125,7 +127,7 @@ class rssTest extends \PHPUnit_Framework_TestCase
|
|||||||
// Item without Title and Description
|
// Item without Title and Description
|
||||||
$this->expectException ("Exception",
|
$this->expectException ("Exception",
|
||||||
"No title nor description defined in the RSS item");
|
"No title nor description defined in the RSS item");
|
||||||
$rss = new rss ();
|
$rss = new Rss ();
|
||||||
$rss->title ("Global Title")
|
$rss->title ("Global Title")
|
||||||
->link ("http://localhost")
|
->link ("http://localhost")
|
||||||
->lastBuildDate ("2017-04-30 12:35:32")
|
->lastBuildDate ("2017-04-30 12:35:32")
|
||||||
@@ -140,7 +142,7 @@ class rssTest extends \PHPUnit_Framework_TestCase
|
|||||||
// Item with invalid date
|
// Item with invalid date
|
||||||
$this->expectException ("Exception",
|
$this->expectException ("Exception",
|
||||||
"pubDate provided to RSS Item is not a valid date");
|
"pubDate provided to RSS Item is not a valid date");
|
||||||
$rss = new rss ();
|
$rss = new Rss ();
|
||||||
$rss->title ("Global Title")
|
$rss->title ("Global Title")
|
||||||
->link ("http://localhost")
|
->link ("http://localhost")
|
||||||
->lastBuildDate ("2017-10-30 12:35:32")
|
->lastBuildDate ("2017-10-30 12:35:32")
|
||||||
|
|||||||
@@ -7,14 +7,16 @@
|
|||||||
|
|
||||||
namespace Domframework\Tests;
|
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
|
// Empty Sitemap
|
||||||
public function test_EmptySitemap_1 ()
|
public function test_EmptySitemap_1 ()
|
||||||
{
|
{
|
||||||
$sitemap = new sitemap ();
|
$sitemap = new Sitemap ();
|
||||||
$res = $sitemap->analyze ("", "http://example.com");
|
$res = $sitemap->analyze ("", "http://example.com");
|
||||||
$this->assertSame ($res, ["urls" => [], "sitemaps" => []]);
|
$this->assertSame ($res, ["urls" => [], "sitemaps" => []]);
|
||||||
}
|
}
|
||||||
@@ -22,7 +24,7 @@ class sitemapTest extends \PHPUnit_Framework_TestCase
|
|||||||
// Empty Sitemap
|
// Empty Sitemap
|
||||||
public function test_EmptySitemap_2 ()
|
public function test_EmptySitemap_2 ()
|
||||||
{
|
{
|
||||||
$sitemap = new sitemap ();
|
$sitemap = new Sitemap ();
|
||||||
$res = $sitemap->analyze (" ", "http://example.com");
|
$res = $sitemap->analyze (" ", "http://example.com");
|
||||||
$this->assertSame ($res, ["urls" => [], "sitemaps" => []]);
|
$this->assertSame ($res, ["urls" => [], "sitemaps" => []]);
|
||||||
}
|
}
|
||||||
@@ -30,7 +32,7 @@ class sitemapTest extends \PHPUnit_Framework_TestCase
|
|||||||
// Textual Sitemap
|
// Textual Sitemap
|
||||||
public function test_TextualSitemap_1 ()
|
public function test_TextualSitemap_1 ()
|
||||||
{
|
{
|
||||||
$sitemap = new sitemap ();
|
$sitemap = new Sitemap ();
|
||||||
$res = $sitemap->analyze ("http://example.com", "http://example.com");
|
$res = $sitemap->analyze ("http://example.com", "http://example.com");
|
||||||
$this->assertSame ($res,
|
$this->assertSame ($res,
|
||||||
["urls" => ["http://example.com" => []],
|
["urls" => ["http://example.com" => []],
|
||||||
@@ -38,7 +40,7 @@ class sitemapTest extends \PHPUnit_Framework_TestCase
|
|||||||
}
|
}
|
||||||
public function test_TextualSitemap_2 ()
|
public function test_TextualSitemap_2 ()
|
||||||
{
|
{
|
||||||
$sitemap = new sitemap ();
|
$sitemap = new Sitemap ();
|
||||||
$res = $sitemap->analyze ("http://example.com\nhttps://www.example.com\n\n",
|
$res = $sitemap->analyze ("http://example.com\nhttps://www.example.com\n\n",
|
||||||
"http://example.com");
|
"http://example.com");
|
||||||
$this->assertSame ($res,
|
$this->assertSame ($res,
|
||||||
@@ -49,7 +51,7 @@ class sitemapTest extends \PHPUnit_Framework_TestCase
|
|||||||
// XML Sitemap
|
// XML Sitemap
|
||||||
public function test_XMLSitemap_1 ()
|
public function test_XMLSitemap_1 ()
|
||||||
{
|
{
|
||||||
$sitemap = new sitemap ();
|
$sitemap = new Sitemap ();
|
||||||
$res = $sitemap->analyze (
|
$res = $sitemap->analyze (
|
||||||
'<?xml version="1.0" encoding="utf-8"?>
|
'<?xml version="1.0" encoding="utf-8"?>
|
||||||
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
|
<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 ()
|
public function test_XMLSitemap_2 ()
|
||||||
{
|
{
|
||||||
$sitemap = new sitemap ();
|
$sitemap = new Sitemap ();
|
||||||
$res = $sitemap->analyze (
|
$res = $sitemap->analyze (
|
||||||
'<?xml version="1.0" encoding="utf-8"?>
|
'<?xml version="1.0" encoding="utf-8"?>
|
||||||
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
||||||
|
|||||||
@@ -7,22 +7,24 @@
|
|||||||
|
|
||||||
namespace Domframework\Tests;
|
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 ()
|
public function test_getRecords_NoSPF ()
|
||||||
{
|
{
|
||||||
$this->expectException ("Exception",
|
$this->expectException ("Exception",
|
||||||
"Can not find a valid SPF TXT entry in DNS for domain ".
|
"Can not find a valid SPF TXT entry in DNS for domain ".
|
||||||
"'notfound.tester.fournier38.fr'", 403);
|
"'notfound.tester.fournier38.fr'", 403);
|
||||||
$spfcheck = new spfcheck ();
|
$spfcheck = new Spfcheck ();
|
||||||
$res = $spfcheck->getRecords ("notfound.tester.fournier38.fr");
|
$res = $spfcheck->getRecords ("notfound.tester.fournier38.fr");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_getRecords_SPFReject ()
|
public function test_getRecords_SPFReject ()
|
||||||
{
|
{
|
||||||
$spfcheck = new spfcheck ();
|
$spfcheck = new Spfcheck ();
|
||||||
$res = $spfcheck->getRecords ("reject.spf.tester.fournier38.fr");
|
$res = $spfcheck->getRecords ("reject.spf.tester.fournier38.fr");
|
||||||
$this->assertSame ($res,
|
$this->assertSame ($res,
|
||||||
array ("reject.spf.tester.fournier38.fr" =>
|
array ("reject.spf.tester.fournier38.fr" =>
|
||||||
@@ -33,14 +35,14 @@ class spfcheckTest extends \PHPUnit_Framework_TestCase
|
|||||||
{
|
{
|
||||||
$this->expectException ("Exception",
|
$this->expectException ("Exception",
|
||||||
"SPFCheck : Too much DNS requests (30 >= 30)", 500);
|
"SPFCheck : Too much DNS requests (30 >= 30)", 500);
|
||||||
$spfcheck = new spfcheck ();
|
$spfcheck = new Spfcheck ();
|
||||||
$res = $spfcheck->getRecords ("loop.spf.tester.fournier38.fr");
|
$res = $spfcheck->getRecords ("loop.spf.tester.fournier38.fr");
|
||||||
$this->assertSame ($res, array ());
|
$this->assertSame ($res, array ());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_getRecords_Include_emptyInclude ()
|
public function test_getRecords_Include_emptyInclude ()
|
||||||
{
|
{
|
||||||
$spfcheck = new spfcheck ();
|
$spfcheck = new Spfcheck ();
|
||||||
$res = $spfcheck->getRecords ("includeempty.spf.tester.fournier38.fr");
|
$res = $spfcheck->getRecords ("includeempty.spf.tester.fournier38.fr");
|
||||||
$this->assertSame ($res,
|
$this->assertSame ($res,
|
||||||
array ("includeempty.spf.tester.fournier38.fr" =>
|
array ("includeempty.spf.tester.fournier38.fr" =>
|
||||||
@@ -49,7 +51,7 @@ class spfcheckTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_getRecords_Redirect_emptyRedirect ()
|
public function test_getRecords_Redirect_emptyRedirect ()
|
||||||
{
|
{
|
||||||
$spfcheck = new spfcheck ();
|
$spfcheck = new Spfcheck ();
|
||||||
$res = $spfcheck->getRecords ("redirectempty.spf.tester.fournier38.fr");
|
$res = $spfcheck->getRecords ("redirectempty.spf.tester.fournier38.fr");
|
||||||
$this->assertSame ($res,
|
$this->assertSame ($res,
|
||||||
array ("redirectempty.spf.tester.fournier38.fr" =>
|
array ("redirectempty.spf.tester.fournier38.fr" =>
|
||||||
@@ -58,7 +60,7 @@ class spfcheckTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_getRecords_MX_emptyMX ()
|
public function test_getRecords_MX_emptyMX ()
|
||||||
{
|
{
|
||||||
$spfcheck = new spfcheck ();
|
$spfcheck = new Spfcheck ();
|
||||||
$res = $spfcheck->getRecords ("mx.spf.tester.fournier38.fr");
|
$res = $spfcheck->getRecords ("mx.spf.tester.fournier38.fr");
|
||||||
$this->assertSame ($res,
|
$this->assertSame ($res,
|
||||||
array ("mx.spf.tester.fournier38.fr" =>
|
array ("mx.spf.tester.fournier38.fr" =>
|
||||||
@@ -67,13 +69,13 @@ class spfcheckTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_getRecords_MX_validMX ()
|
public function test_getRecords_MX_validMX ()
|
||||||
{
|
{
|
||||||
$spfcheck = new spfcheck ();
|
$spfcheck = new Spfcheck ();
|
||||||
$res = $spfcheck->getRecords ("mxvalid.spf.tester.fournier38.fr");
|
$res = $spfcheck->getRecords ("mxvalid.spf.tester.fournier38.fr");
|
||||||
$this->assertSame ($res,
|
$this->assertSame ($res,
|
||||||
array ("mxvalid.spf.tester.fournier38.fr" => array (
|
array ("mxvalid.spf.tester.fournier38.fr" => array (
|
||||||
"mx:tester.fournier38.fr" => array (
|
"mx:tester.fournier38.fr" => array (
|
||||||
"2a01:e0a:234:3931::103",
|
"2a01:e0a:163:38f1::103",
|
||||||
"2a01:e0a:289:3090::206",
|
"2a01:e0a:2a7:9cd0::206",
|
||||||
"82.64.55.197",
|
"82.64.55.197",
|
||||||
"82.64.75.195"),
|
"82.64.75.195"),
|
||||||
"-all" => array ())));
|
"-all" => array ())));
|
||||||
@@ -81,7 +83,7 @@ class spfcheckTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_getRecords_A_emptyA ()
|
public function test_getRecords_A_emptyA ()
|
||||||
{
|
{
|
||||||
$spfcheck = new spfcheck ();
|
$spfcheck = new Spfcheck ();
|
||||||
$res = $spfcheck->getRecords ("a.spf.tester.fournier38.fr");
|
$res = $spfcheck->getRecords ("a.spf.tester.fournier38.fr");
|
||||||
$this->assertSame ($res,
|
$this->assertSame ($res,
|
||||||
array ("a.spf.tester.fournier38.fr" =>
|
array ("a.spf.tester.fournier38.fr" =>
|
||||||
@@ -90,19 +92,19 @@ class spfcheckTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_getRecords_A_validA ()
|
public function test_getRecords_A_validA ()
|
||||||
{
|
{
|
||||||
$spfcheck = new spfcheck ();
|
$spfcheck = new Spfcheck ();
|
||||||
$res = $spfcheck->getRecords ("avalid.spf.tester.fournier38.fr");
|
$res = $spfcheck->getRecords ("avalid.spf.tester.fournier38.fr");
|
||||||
$this->assertSame ($res,
|
$this->assertSame ($res,
|
||||||
array ("avalid.spf.tester.fournier38.fr" => array (
|
array ("avalid.spf.tester.fournier38.fr" => array (
|
||||||
"a:tester.fournier38.fr" => array (
|
"a:tester.fournier38.fr" => array (
|
||||||
"2a01:e0a:234:3931::100",
|
"2a01:e0a:163:38f1::100",
|
||||||
"82.64.55.197",),
|
"82.64.55.197",),
|
||||||
"-all" => array ())));
|
"-all" => array ())));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_getRecords_IP4_emptyIP4 ()
|
public function test_getRecords_IP4_emptyIP4 ()
|
||||||
{
|
{
|
||||||
$spfcheck = new spfcheck ();
|
$spfcheck = new Spfcheck ();
|
||||||
$res = $spfcheck->getRecords ("ip4empty.spf.tester.fournier38.fr");
|
$res = $spfcheck->getRecords ("ip4empty.spf.tester.fournier38.fr");
|
||||||
$this->assertSame ($res,
|
$this->assertSame ($res,
|
||||||
array ("ip4empty.spf.tester.fournier38.fr" => array (
|
array ("ip4empty.spf.tester.fournier38.fr" => array (
|
||||||
@@ -112,7 +114,7 @@ class spfcheckTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_getRecords_IP4_invalidIP4 ()
|
public function test_getRecords_IP4_invalidIP4 ()
|
||||||
{
|
{
|
||||||
$spfcheck = new spfcheck ();
|
$spfcheck = new Spfcheck ();
|
||||||
$res = $spfcheck->getRecords ("ip4invalid.spf.tester.fournier38.fr");
|
$res = $spfcheck->getRecords ("ip4invalid.spf.tester.fournier38.fr");
|
||||||
$this->assertSame ($res,
|
$this->assertSame ($res,
|
||||||
array ("ip4invalid.spf.tester.fournier38.fr" => array (
|
array ("ip4invalid.spf.tester.fournier38.fr" => array (
|
||||||
@@ -122,7 +124,7 @@ class spfcheckTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_getRecords_IP4_validIP4 ()
|
public function test_getRecords_IP4_validIP4 ()
|
||||||
{
|
{
|
||||||
$spfcheck = new spfcheck ();
|
$spfcheck = new Spfcheck ();
|
||||||
$res = $spfcheck->getRecords ("ip4valid.spf.tester.fournier38.fr");
|
$res = $spfcheck->getRecords ("ip4valid.spf.tester.fournier38.fr");
|
||||||
$this->assertSame ($res,
|
$this->assertSame ($res,
|
||||||
array ("ip4valid.spf.tester.fournier38.fr" => array (
|
array ("ip4valid.spf.tester.fournier38.fr" => array (
|
||||||
@@ -132,7 +134,7 @@ class spfcheckTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_getRecords_IP6_emptyIP6 ()
|
public function test_getRecords_IP6_emptyIP6 ()
|
||||||
{
|
{
|
||||||
$spfcheck = new spfcheck ();
|
$spfcheck = new Spfcheck ();
|
||||||
$res = $spfcheck->getRecords ("ip6empty.spf.tester.fournier38.fr");
|
$res = $spfcheck->getRecords ("ip6empty.spf.tester.fournier38.fr");
|
||||||
$this->assertSame ($res,
|
$this->assertSame ($res,
|
||||||
array ("ip6empty.spf.tester.fournier38.fr" => array (
|
array ("ip6empty.spf.tester.fournier38.fr" => array (
|
||||||
@@ -142,7 +144,7 @@ class spfcheckTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_getRecords_IP6_invalidIP6 ()
|
public function test_getRecords_IP6_invalidIP6 ()
|
||||||
{
|
{
|
||||||
$spfcheck = new spfcheck ();
|
$spfcheck = new Spfcheck ();
|
||||||
$res = $spfcheck->getRecords ("ip6invalid.spf.tester.fournier38.fr");
|
$res = $spfcheck->getRecords ("ip6invalid.spf.tester.fournier38.fr");
|
||||||
$this->assertSame ($res,
|
$this->assertSame ($res,
|
||||||
array ("ip6invalid.spf.tester.fournier38.fr" => array (
|
array ("ip6invalid.spf.tester.fournier38.fr" => array (
|
||||||
@@ -152,7 +154,7 @@ class spfcheckTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_getRecords_IP6_validIP6 ()
|
public function test_getRecords_IP6_validIP6 ()
|
||||||
{
|
{
|
||||||
$spfcheck = new spfcheck ();
|
$spfcheck = new Spfcheck ();
|
||||||
$res = $spfcheck->getRecords ("ip6valid.spf.tester.fournier38.fr");
|
$res = $spfcheck->getRecords ("ip6valid.spf.tester.fournier38.fr");
|
||||||
$this->assertSame ($res,
|
$this->assertSame ($res,
|
||||||
array ("ip6valid.spf.tester.fournier38.fr" => array (
|
array ("ip6valid.spf.tester.fournier38.fr" => array (
|
||||||
@@ -162,7 +164,7 @@ class spfcheckTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_getRecords_PTR ()
|
public function test_getRecords_PTR ()
|
||||||
{
|
{
|
||||||
$spfcheck = new spfcheck ();
|
$spfcheck = new Spfcheck ();
|
||||||
$res = $spfcheck->getRecords ("ptrvalid.spf.tester.fournier38.fr");
|
$res = $spfcheck->getRecords ("ptrvalid.spf.tester.fournier38.fr");
|
||||||
$this->assertSame ($res,
|
$this->assertSame ($res,
|
||||||
array ("ptrvalid.spf.tester.fournier38.fr" => array (
|
array ("ptrvalid.spf.tester.fournier38.fr" => array (
|
||||||
@@ -172,7 +174,7 @@ class spfcheckTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_getRecords_All_Multiple ()
|
public function test_getRecords_All_Multiple ()
|
||||||
{
|
{
|
||||||
$spfcheck = new spfcheck ();
|
$spfcheck = new Spfcheck ();
|
||||||
$res = $spfcheck->getRecords ("allmultiple.spf.tester.fournier38.fr");
|
$res = $spfcheck->getRecords ("allmultiple.spf.tester.fournier38.fr");
|
||||||
$this->assertSame ($res,
|
$this->assertSame ($res,
|
||||||
array ("allmultiple.spf.tester.fournier38.fr" => array (
|
array ("allmultiple.spf.tester.fournier38.fr" => array (
|
||||||
@@ -182,7 +184,7 @@ class spfcheckTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_getRecords_All_NotEnd ()
|
public function test_getRecords_All_NotEnd ()
|
||||||
{
|
{
|
||||||
$spfcheck = new spfcheck ();
|
$spfcheck = new Spfcheck ();
|
||||||
$res = $spfcheck->getRecords ("allnotend.spf.tester.fournier38.fr");
|
$res = $spfcheck->getRecords ("allnotend.spf.tester.fournier38.fr");
|
||||||
$this->assertSame ($res,
|
$this->assertSame ($res,
|
||||||
array ("allnotend.spf.tester.fournier38.fr" => array (
|
array ("allnotend.spf.tester.fournier38.fr" => array (
|
||||||
@@ -192,7 +194,7 @@ class spfcheckTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_getRecords_All_NotSet ()
|
public function test_getRecords_All_NotSet ()
|
||||||
{
|
{
|
||||||
$spfcheck = new spfcheck ();
|
$spfcheck = new Spfcheck ();
|
||||||
$res = $spfcheck->getRecords ("allnotset.spf.tester.fournier38.fr");
|
$res = $spfcheck->getRecords ("allnotset.spf.tester.fournier38.fr");
|
||||||
$this->assertSame ($res,
|
$this->assertSame ($res,
|
||||||
array ("allnotset.spf.tester.fournier38.fr" => array (
|
array ("allnotset.spf.tester.fournier38.fr" => array (
|
||||||
@@ -201,7 +203,7 @@ class spfcheckTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_wideIPRange ()
|
public function test_wideIPRange ()
|
||||||
{
|
{
|
||||||
$spfcheck = new spfcheck ();
|
$spfcheck = new Spfcheck ();
|
||||||
$spfcheck->getRecords ("wide.spf.tester.fournier38.fr");
|
$spfcheck->getRecords ("wide.spf.tester.fournier38.fr");
|
||||||
$res = $spfcheck->getErrors ();
|
$res = $spfcheck->getErrors ();
|
||||||
$this->assertSame ($res,
|
$this->assertSame ($res,
|
||||||
@@ -213,7 +215,7 @@ class spfcheckTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_recordsWithPlus ()
|
public function test_recordsWithPlus ()
|
||||||
{
|
{
|
||||||
$spfcheck = new spfcheck ();
|
$spfcheck = new Spfcheck ();
|
||||||
$res = $spfcheck->getRecords ("plus.spf.tester.fournier38.fr");
|
$res = $spfcheck->getRecords ("plus.spf.tester.fournier38.fr");
|
||||||
$this->assertSame ($res,
|
$this->assertSame ($res,
|
||||||
array ("plus.spf.tester.fournier38.fr" => array (
|
array ("plus.spf.tester.fournier38.fr" => array (
|
||||||
@@ -228,7 +230,7 @@ class spfcheckTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_getRecords_Unknown ()
|
public function test_getRecords_Unknown ()
|
||||||
{
|
{
|
||||||
$spfcheck = new spfcheck ();
|
$spfcheck = new Spfcheck ();
|
||||||
$res = $spfcheck->getRecords ("unknown.spf.tester.fournier38.fr");
|
$res = $spfcheck->getRecords ("unknown.spf.tester.fournier38.fr");
|
||||||
$this->assertSame ($res,
|
$this->assertSame ($res,
|
||||||
array ("unknown.spf.tester.fournier38.fr" => array (
|
array ("unknown.spf.tester.fournier38.fr" => array (
|
||||||
@@ -238,28 +240,28 @@ class spfcheckTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_ipCheckToSPF_OK_inA ()
|
public function test_ipCheckToSPF_OK_inA ()
|
||||||
{
|
{
|
||||||
$spfcheck = new spfcheck ();
|
$spfcheck = new Spfcheck ();
|
||||||
$res = $spfcheck->ipCheckToSPF ("plus.spf.tester.fournier38.fr", "178.33.236.5");
|
$res = $spfcheck->ipCheckToSPF ("plus.spf.tester.fournier38.fr", "178.33.236.5");
|
||||||
$this->assertSame ($res, "PASS");
|
$this->assertSame ($res, "PASS");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_ipCheckToSPF_FAIL_inALL ()
|
public function test_ipCheckToSPF_FAIL_inALL ()
|
||||||
{
|
{
|
||||||
$spfcheck = new spfcheck ();
|
$spfcheck = new Spfcheck ();
|
||||||
$res = $spfcheck->ipCheckToSPF ("plus.spf.tester.fournier38.fr", "1.3.6.5");
|
$res = $spfcheck->ipCheckToSPF ("plus.spf.tester.fournier38.fr", "1.3.6.5");
|
||||||
$this->assertSame ($res, "FAIL");
|
$this->assertSame ($res, "FAIL");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_ipCheckToSPF_OK_inALL ()
|
public function test_ipCheckToSPF_OK_inALL ()
|
||||||
{
|
{
|
||||||
$spfcheck = new spfcheck ();
|
$spfcheck = new Spfcheck ();
|
||||||
$res = $spfcheck->ipCheckToSPF ("plus.spf.tester.fournier38.fr", "1.3.6.5");
|
$res = $spfcheck->ipCheckToSPF ("plus.spf.tester.fournier38.fr", "1.3.6.5");
|
||||||
$this->assertSame ($res, "FAIL");
|
$this->assertSame ($res, "FAIL");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_ipCheckToSPF_FAIL_inIP4 ()
|
public function test_ipCheckToSPF_FAIL_inIP4 ()
|
||||||
{
|
{
|
||||||
$spfcheck = new spfcheck ();
|
$spfcheck = new Spfcheck ();
|
||||||
$res = $spfcheck->ipCheckToSPF ("plus.spf.tester.fournier38.fr", "137.74.69.64");
|
$res = $spfcheck->ipCheckToSPF ("plus.spf.tester.fournier38.fr", "137.74.69.64");
|
||||||
$this->assertSame ($res, "FAIL");
|
$this->assertSame ($res, "FAIL");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,21 +7,24 @@
|
|||||||
|
|
||||||
namespace Domframework\Tests;
|
namespace Domframework\Tests;
|
||||||
|
|
||||||
|
use Domframework\Sse;
|
||||||
|
|
||||||
/** Test the domframework Server-Sent Events part */
|
/** Test the domframework Server-Sent Events part */
|
||||||
class sseTest extends \PHPUnit_Framework_TestCase
|
class SseTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
public function test_loop_NOTDEFINED ()
|
public function test_loop_NOTDEFINED ()
|
||||||
{
|
{
|
||||||
$this->expectException ("Exception");
|
$this->expectException ("Exception");
|
||||||
$sse = new sse ();
|
$sse = new Sse ();
|
||||||
$res = $sse->loop ();
|
$res = $sse->loop ();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_loop_JUSTPING ()
|
public function test_loop_JUSTPING ()
|
||||||
{
|
{
|
||||||
$this->expectOutputString(str_repeat (": ping\n\n", 5));
|
$this->expectOutputString(str_repeat (": ping\n\n", 5));
|
||||||
$sse = new sse ();
|
$sse = new Sse ();
|
||||||
@unlink ("/tmp/dfwTestSSE1");
|
if (file_exists ("/tmp/dfwTestSSE1"))
|
||||||
|
unlink ("/tmp/dfwTestSSE1");
|
||||||
$sse->setBackendFiles ("/tmp/dfwTestSSE1")
|
$sse->setBackendFiles ("/tmp/dfwTestSSE1")
|
||||||
->setPingTime(1);
|
->setPingTime(1);
|
||||||
$sse->loop ();
|
$sse->loop ();
|
||||||
@@ -30,8 +33,9 @@ class sseTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function test_loop_SKIP_START ()
|
public function test_loop_SKIP_START ()
|
||||||
{
|
{
|
||||||
$this->expectOutputString(str_repeat (": ping\n\n", 5));
|
$this->expectOutputString(str_repeat (": ping\n\n", 5));
|
||||||
$sse = new sse ();
|
$sse = new Sse ();
|
||||||
@unlink ("/tmp/dfwTestSSE1");
|
if (file_exists ("/tmp/dfwTestSSE1"))
|
||||||
|
unlink ("/tmp/dfwTestSSE1");
|
||||||
file_put_contents ("/tmp/dfwTestSSE1", "NOT SEEN");
|
file_put_contents ("/tmp/dfwTestSSE1", "NOT SEEN");
|
||||||
$sse->setBackendFiles ("/tmp/dfwTestSSE1")
|
$sse->setBackendFiles ("/tmp/dfwTestSSE1")
|
||||||
->setPingTime(1);
|
->setPingTime(1);
|
||||||
@@ -42,8 +46,9 @@ class sseTest extends \PHPUnit_Framework_TestCase
|
|||||||
{
|
{
|
||||||
$this->expectOutputString(str_repeat (": ping\n\n", 4).
|
$this->expectOutputString(str_repeat (": ping\n\n", 4).
|
||||||
"data: WILL BE SEEN\n\n: ping\n\n");
|
"data: WILL BE SEEN\n\n: ping\n\n");
|
||||||
@unlink ("/tmp/dfwTestSSE1");
|
if (file_exists ("/tmp/dfwTestSSE1"))
|
||||||
$sse = new sse ();
|
unlink ("/tmp/dfwTestSSE1");
|
||||||
|
$sse = new Sse ();
|
||||||
pcntl_signal(SIGALRM, function () {
|
pcntl_signal(SIGALRM, function () {
|
||||||
file_put_contents ("/tmp/dfwTestSSE1", "WILL BE SEEN\n");
|
file_put_contents ("/tmp/dfwTestSSE1", "WILL BE SEEN\n");
|
||||||
}, false);
|
}, false);
|
||||||
@@ -59,9 +64,11 @@ class sseTest extends \PHPUnit_Framework_TestCase
|
|||||||
"event: event1\ndata: WILL BE SEEN 1\n\n".
|
"event: event1\ndata: WILL BE SEEN 1\n\n".
|
||||||
"event: event2\ndata: WILL BE SEEN 2\n\n".
|
"event: event2\ndata: WILL BE SEEN 2\n\n".
|
||||||
": ping\n\n");
|
": ping\n\n");
|
||||||
@unlink ("/tmp/dfwTestSSE1");
|
if (file_exists ("/tmp/dfwTestSSE1"))
|
||||||
@unlink ("/tmp/dfwTestSSE2");
|
unlink ("/tmp/dfwTestSSE1");
|
||||||
$sse = new sse ();
|
if (file_exists ("/tmp/dfwTestSSE2"))
|
||||||
|
unlink ("/tmp/dfwTestSSE2");
|
||||||
|
$sse = new Sse ();
|
||||||
pcntl_signal(SIGALRM, function () {
|
pcntl_signal(SIGALRM, function () {
|
||||||
file_put_contents ("/tmp/dfwTestSSE1", "WILL BE SEEN 1\n");
|
file_put_contents ("/tmp/dfwTestSSE1", "WILL BE SEEN 1\n");
|
||||||
file_put_contents ("/tmp/dfwTestSSE2", "WILL BE SEEN 2\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: event1\ndata: will be seen 1\n\n".
|
||||||
"event: event2\ndata: WILL BE SEEN 2\n\n".
|
"event: event2\ndata: WILL BE SEEN 2\n\n".
|
||||||
": ping\n\n");
|
": ping\n\n");
|
||||||
@unlink ("/tmp/dfwTestSSE1");
|
if (file_exists ("/tmp/dfwTestSSE1"))
|
||||||
@unlink ("/tmp/dfwTestSSE2");
|
unlink ("/tmp/dfwTestSSE1");
|
||||||
$sse = new sse ();
|
if (file_exists ("/tmp/dfwTestSSE2"))
|
||||||
|
unlink ("/tmp/dfwTestSSE2");
|
||||||
|
$sse = new Sse ();
|
||||||
pcntl_signal(SIGALRM, function () {
|
pcntl_signal(SIGALRM, function () {
|
||||||
file_put_contents ("/tmp/dfwTestSSE1", "WILL BE SEEN 1\n");
|
file_put_contents ("/tmp/dfwTestSSE1", "WILL BE SEEN 1\n");
|
||||||
file_put_contents ("/tmp/dfwTestSSE2", "WILL BE SEEN 2\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",
|
$sse->setBackendFiles (["event1" => "/tmp/dfwTestSSE1",
|
||||||
"event2" => "/tmp/dfwTestSSE2"])
|
"event2" => "/tmp/dfwTestSSE2"])
|
||||||
->setHandlersEvent (["event1" => "lowerHandlersEvent"])
|
->setHandlersEvent ([
|
||||||
|
"event1" => __NAMESPACE__."\\lowerHandlersEvent"])
|
||||||
->setPingTime(1);
|
->setPingTime(1);
|
||||||
$sse->loop ();
|
$sse->loop ();
|
||||||
}
|
}
|
||||||
@@ -102,8 +112,9 @@ class sseTest extends \PHPUnit_Framework_TestCase
|
|||||||
$this->expectOutputString(str_repeat (": ping\n\n", 4).
|
$this->expectOutputString(str_repeat (": ping\n\n", 4).
|
||||||
"data: will be seen 1\n\n".
|
"data: will be seen 1\n\n".
|
||||||
": ping\n\n");
|
": ping\n\n");
|
||||||
@unlink ("/tmp/dfwTestSSE1");
|
if (file_exists ("/tmp/dfwTestSSE1"))
|
||||||
$sse = new sse ();
|
unlink ("/tmp/dfwTestSSE1");
|
||||||
|
$sse = new Sse ();
|
||||||
pcntl_signal(SIGALRM, function () {
|
pcntl_signal(SIGALRM, function () {
|
||||||
file_put_contents ("/tmp/dfwTestSSE1", "WILL BE SEEN 1\n");
|
file_put_contents ("/tmp/dfwTestSSE1", "WILL BE SEEN 1\n");
|
||||||
}, false);
|
}, false);
|
||||||
@@ -112,7 +123,7 @@ class sseTest extends \PHPUnit_Framework_TestCase
|
|||||||
return strtolower ($val);
|
return strtolower ($val);
|
||||||
}
|
}
|
||||||
$sse->setBackendFiles ("/tmp/dfwTestSSE1")
|
$sse->setBackendFiles ("/tmp/dfwTestSSE1")
|
||||||
->setHandlerDataonly ("lowerHandlerDataonly")
|
->setHandlerDataonly (__NAMESPACE__."\\lowerHandlerDataonly")
|
||||||
->setPingTime(1);
|
->setPingTime(1);
|
||||||
$sse->loop ();
|
$sse->loop ();
|
||||||
}
|
}
|
||||||
@@ -122,8 +133,9 @@ class sseTest extends \PHPUnit_Framework_TestCase
|
|||||||
$this->expectOutputString(str_repeat (": ping\n\n", 4).
|
$this->expectOutputString(str_repeat (": ping\n\n", 4).
|
||||||
"data: PREwill be seen 1POST\n\n".
|
"data: PREwill be seen 1POST\n\n".
|
||||||
": ping\n\n");
|
": ping\n\n");
|
||||||
@unlink ("/tmp/dfwTestSSE1");
|
if (file_exists ("/tmp/dfwTestSSE1"))
|
||||||
$sse = new sse ();
|
unlink ("/tmp/dfwTestSSE1");
|
||||||
|
$sse = new Sse ();
|
||||||
pcntl_signal(SIGALRM, function () {
|
pcntl_signal(SIGALRM, function () {
|
||||||
file_put_contents ("/tmp/dfwTestSSE1", "WILL BE SEEN 1\n");
|
file_put_contents ("/tmp/dfwTestSSE1", "WILL BE SEEN 1\n");
|
||||||
}, false);
|
}, false);
|
||||||
@@ -132,7 +144,8 @@ class sseTest extends \PHPUnit_Framework_TestCase
|
|||||||
return $param1.strtolower ($val).$param2;
|
return $param1.strtolower ($val).$param2;
|
||||||
}
|
}
|
||||||
$sse->setBackendFiles ("/tmp/dfwTestSSE1")
|
$sse->setBackendFiles ("/tmp/dfwTestSSE1")
|
||||||
->setHandlerDataonly ("lowerHandlerDataonlyWithParams", "PRE", "POST")
|
->setHandlerDataonly (
|
||||||
|
__NAMESPACE__."\\lowerHandlerDataonlyWithParams", "PRE", "POST")
|
||||||
->setPingTime(1);
|
->setPingTime(1);
|
||||||
$sse->loop ();
|
$sse->loop ();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,12 +7,14 @@
|
|||||||
|
|
||||||
namespace Domframework\Tests;
|
namespace Domframework\Tests;
|
||||||
|
|
||||||
|
use Domframework\Tcpclient;
|
||||||
|
|
||||||
/** Test the TCP client */
|
/** Test the TCP client */
|
||||||
class tcpclientTest extends \PHPUnit_Framework_TestCase
|
class TcpclientTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
public function test_GoogleIPv4 ()
|
public function test_GoogleIPv4 ()
|
||||||
{
|
{
|
||||||
$tcpclient = new \tcpclient ("www.google.fr", 80);
|
$tcpclient = new Tcpclient ("www.google.fr", 80);
|
||||||
$tcpclient->preferIPv4 (true);
|
$tcpclient->preferIPv4 (true);
|
||||||
$tcpclient->connect ();
|
$tcpclient->connect ();
|
||||||
$tcpclient->send ("GET / HTTP/1.1\r\n".
|
$tcpclient->send ("GET / HTTP/1.1\r\n".
|
||||||
@@ -29,7 +31,7 @@ class tcpclientTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_GoogleIPv4orIpv6 ()
|
public function test_GoogleIPv4orIpv6 ()
|
||||||
{
|
{
|
||||||
$tcpclient = new \tcpclient ("www.google.fr", 80);
|
$tcpclient = new Tcpclient ("www.google.fr", 80);
|
||||||
$tcpclient->connect ();
|
$tcpclient->connect ();
|
||||||
$tcpclient->send ("GET / HTTP/1.1\r\n".
|
$tcpclient->send ("GET / HTTP/1.1\r\n".
|
||||||
"Host: www.google.fr\r\n".
|
"Host: www.google.fr\r\n".
|
||||||
@@ -45,7 +47,7 @@ class tcpclientTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_GoogleSSL ()
|
public function test_GoogleSSL ()
|
||||||
{
|
{
|
||||||
$tcpclient = new \tcpclient ("www.google.fr", 443);
|
$tcpclient = new Tcpclient ("www.google.fr", 443);
|
||||||
$tcpclient->connect ();
|
$tcpclient->connect ();
|
||||||
$tcpclient->cryptoEnable (true);
|
$tcpclient->cryptoEnable (true);
|
||||||
$tcpclient->send ("GET / HTTP/1.1\r\n".
|
$tcpclient->send ("GET / HTTP/1.1\r\n".
|
||||||
@@ -62,7 +64,7 @@ class tcpclientTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_GoogleSSLIPv6 ()
|
public function test_GoogleSSLIPv6 ()
|
||||||
{
|
{
|
||||||
$tcpclient = new \tcpclient ("ipv6.google.com", 443);
|
$tcpclient = new Tcpclient ("ipv6.google.com", 443);
|
||||||
$tcpclient->connect ();
|
$tcpclient->connect ();
|
||||||
$tcpclient->cryptoEnable (true);
|
$tcpclient->cryptoEnable (true);
|
||||||
$tcpclient->send ("GET / HTTP/1.1\r\n".
|
$tcpclient->send ("GET / HTTP/1.1\r\n".
|
||||||
|
|||||||
@@ -7,8 +7,10 @@
|
|||||||
|
|
||||||
namespace Domframework\Tests;
|
namespace Domframework\Tests;
|
||||||
|
|
||||||
/** Test the userssql.php file */
|
use Domframework\Userssql;
|
||||||
class userssqlTest extends \PHPUnit_Framework_TestCase
|
|
||||||
|
/** Test the Userssql.php file */
|
||||||
|
class UserssqlTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
public function test_clean ()
|
public function test_clean ()
|
||||||
{
|
{
|
||||||
@@ -17,28 +19,28 @@ class userssqlTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_initStorage ()
|
public function test_initStorage ()
|
||||||
{
|
{
|
||||||
$userssql = new userssql ("sqlite:///tmp/database.db");
|
$userssql = new Userssql ("sqlite:///tmp/database.db");
|
||||||
$res = $userssql->initStorage ();
|
$res = $userssql->initStorage ();
|
||||||
$this->assertSame ($res, 0);
|
$this->assertSame ($res, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_listusers1 ()
|
public function test_listusers1 ()
|
||||||
{
|
{
|
||||||
$userssql = new userssql ("sqlite:///tmp/database.db");
|
$userssql = new Userssql ("sqlite:///tmp/database.db");
|
||||||
$res = $userssql->listusers ();
|
$res = $userssql->listusers ();
|
||||||
$this->assertSame ($res, array ());
|
$this->assertSame ($res, array ());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_adduser1 ()
|
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");
|
$res = $userssql->adduser ("toto@toto.com", "Toto", "Toto2");
|
||||||
$this->assertSame ($res, "toto@toto.com");
|
$this->assertSame ($res, "toto@toto.com");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_listusers2 ()
|
public function test_listusers2 ()
|
||||||
{
|
{
|
||||||
$userssql = new userssql ("sqlite:///tmp/database.db");
|
$userssql = new Userssql ("sqlite:///tmp/database.db");
|
||||||
$res = $userssql->listusers ();
|
$res = $userssql->listusers ();
|
||||||
$this->assertSame ($res, array (array ("email"=>"toto@toto.com",
|
$this->assertSame ($res, array (array ("email"=>"toto@toto.com",
|
||||||
"firstname"=>"Toto",
|
"firstname"=>"Toto",
|
||||||
@@ -47,49 +49,49 @@ class userssqlTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_overwritepassword1 ()
|
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");
|
$res = $userssql->overwritepassword ("toto@toto.com", "PassW0rd");
|
||||||
$this->assertSame ($res, 1);
|
$this->assertSame ($res, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_checkValidPassword1 ()
|
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");
|
$res = $userssql->checkValidPassword ("toto@toto.com", "PassW0rd");
|
||||||
$this->assertSame ($res, true);
|
$this->assertSame ($res, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_checkValidPassword2 ()
|
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");
|
$res = $userssql->checkValidPassword ("toto@toto.com", "BAD PASSWD");
|
||||||
$this->assertSame ($res, false);
|
$this->assertSame ($res, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_changepassword1 ()
|
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!");
|
$res = $userssql->changepassword ("toto@toto.com", "PassW0rd", "NEW PASS!");
|
||||||
$this->assertSame ($res, 1);
|
$this->assertSame ($res, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_checkValidPassword3 ()
|
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");
|
$res = $userssql->checkValidPassword ("toto@toto.com", "PassW0rd");
|
||||||
$this->assertSame ($res, false);
|
$this->assertSame ($res, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_checkValidPassword4 ()
|
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!");
|
$res = $userssql->checkValidPassword ("toto@toto.com", "NEW PASS!");
|
||||||
$this->assertSame ($res, true);
|
$this->assertSame ($res, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_updateuser ()
|
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",
|
$res = $userssql->updateuser ("toto@toto.com", "titi@titi.com", "titi",
|
||||||
"titi2");
|
"titi2");
|
||||||
$this->assertSame ($res, 1);
|
$this->assertSame ($res, 1);
|
||||||
@@ -97,7 +99,7 @@ class userssqlTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_listusers3 ()
|
public function test_listusers3 ()
|
||||||
{
|
{
|
||||||
$userssql = new userssql ("sqlite:///tmp/database.db");
|
$userssql = new Userssql ("sqlite:///tmp/database.db");
|
||||||
$res = $userssql->listusers ();
|
$res = $userssql->listusers ();
|
||||||
$this->assertSame ($res, array (array ("email"=>"titi@titi.com",
|
$this->assertSame ($res, array (array ("email"=>"titi@titi.com",
|
||||||
"firstname"=>"titi",
|
"firstname"=>"titi",
|
||||||
@@ -106,21 +108,21 @@ class userssqlTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_checkValidPassword5 ()
|
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!");
|
$res = $userssql->checkValidPassword ("titi@titi.com", "NEW PASS!");
|
||||||
$this->assertSame ($res, true);
|
$this->assertSame ($res, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_deluser ()
|
public function test_deluser ()
|
||||||
{
|
{
|
||||||
$userssql = new userssql ("sqlite:///tmp/database.db");
|
$userssql = new Userssql ("sqlite:///tmp/database.db");
|
||||||
$res = $userssql->deluser ("titi@titi.com");
|
$res = $userssql->deluser ("titi@titi.com");
|
||||||
$this->assertSame ($res, 1);
|
$this->assertSame ($res, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_listusers4 ()
|
public function test_listusers4 ()
|
||||||
{
|
{
|
||||||
$userssql = new userssql ("sqlite:///tmp/database.db");
|
$userssql = new Userssql ("sqlite:///tmp/database.db");
|
||||||
$res = $userssql->listusers ();
|
$res = $userssql->listusers ();
|
||||||
$this->assertSame ($res, array ());
|
$this->assertSame ($res, array ());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,18 +7,20 @@
|
|||||||
|
|
||||||
namespace Domframework\Tests;
|
namespace Domframework\Tests;
|
||||||
|
|
||||||
/** Test the uuid.php file */
|
use Domframework\Uuid;
|
||||||
class uuidTest extends \PHPUnit_Framework_TestCase
|
|
||||||
|
/** Test the Uuid.php file */
|
||||||
|
class UuidTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
public function test_uuid1 ()
|
public function test_uuid1 ()
|
||||||
{
|
{
|
||||||
$res = uuid::uuid4 ();
|
$res = Uuid::uuid4 ();
|
||||||
$this->assertRegExp (36, strlen ($res));
|
$this->assertRegExp (36, strlen ($res));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_uuid2 ()
|
public function test_uuid2 ()
|
||||||
{
|
{
|
||||||
$res = uuid::uuid4 ();
|
$res = Uuid::uuid4 ();
|
||||||
$this->assertRegExp (true, strspn ("0123456789abcdef-", $res) ==
|
$this->assertRegExp (true, strspn ("0123456789abcdef-", $res) ==
|
||||||
strlen ($res));
|
strlen ($res));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,60 +7,62 @@
|
|||||||
|
|
||||||
namespace Domframework\Tests;
|
namespace Domframework\Tests;
|
||||||
|
|
||||||
|
use Domframework\Verify;
|
||||||
|
|
||||||
/** Test the Verify */
|
/** Test the Verify */
|
||||||
class verifyTest extends \PHPUnit_Framework_TestCase
|
class VerifyTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
///////////////
|
///////////////
|
||||||
// DATES //
|
// DATES //
|
||||||
///////////////
|
///////////////
|
||||||
public function test_is_datetimeSQL1 ()
|
public function test_is_datetimeSQL1 ()
|
||||||
{
|
{
|
||||||
$verify = new \verify ();
|
$verify = new Verify ();
|
||||||
$res = $verify->is_datetimeSQL ("2017-04-13 22:55:17");
|
$res = $verify->is_datetimeSQL ("2017-04-13 22:55:17");
|
||||||
$this->assertSame ($res, true);
|
$this->assertSame ($res, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_is_datetimeSQL2 ()
|
public function test_is_datetimeSQL2 ()
|
||||||
{
|
{
|
||||||
$verify = new \verify ();
|
$verify = new Verify ();
|
||||||
$res = $verify->is_datetimeSQL ("2017-13-55 22:55:17");
|
$res = $verify->is_datetimeSQL ("2017-13-55 22:55:17");
|
||||||
$this->assertSame ($res, false);
|
$this->assertSame ($res, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_staticIs_datetimeSQL1 ()
|
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);
|
$this->assertSame ($res, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_staticIs_datetimeSQL2 ()
|
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);
|
$this->assertSame ($res, false);
|
||||||
}
|
}
|
||||||
public function test_is_dateSQL1 ()
|
public function test_is_dateSQL1 ()
|
||||||
{
|
{
|
||||||
$verify = new \verify ();
|
$verify = new Verify ();
|
||||||
$res = $verify->is_dateSQL ("2017-04-13");
|
$res = $verify->is_dateSQL ("2017-04-13");
|
||||||
$this->assertSame ($res, true);
|
$this->assertSame ($res, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_is_dateSQL2 ()
|
public function test_is_dateSQL2 ()
|
||||||
{
|
{
|
||||||
$verify = new \verify ();
|
$verify = new Verify ();
|
||||||
$res = $verify->is_dateSQL ("2017-13-55");
|
$res = $verify->is_dateSQL ("2017-13-55");
|
||||||
$this->assertSame ($res, false);
|
$this->assertSame ($res, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_staticIs_dateSQL1 ()
|
public function test_staticIs_dateSQL1 ()
|
||||||
{
|
{
|
||||||
$res = \verify::staticIs_dateSQL ("2017-04-13");
|
$res = Verify::staticIs_dateSQL ("2017-04-13");
|
||||||
$this->assertSame ($res, true);
|
$this->assertSame ($res, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_staticIs_dateSQL2 ()
|
public function test_staticIs_dateSQL2 ()
|
||||||
{
|
{
|
||||||
$res = \verify::staticIs_dateSQL ("2017-13-55");
|
$res = Verify::staticIs_dateSQL ("2017-13-55");
|
||||||
$this->assertSame ($res, false);
|
$this->assertSame ($res, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -70,13 +72,13 @@ class verifyTest extends \PHPUnit_Framework_TestCase
|
|||||||
/////////////////
|
/////////////////
|
||||||
public function test_staticIsAllowedChars_1 ()
|
public function test_staticIsAllowedChars_1 ()
|
||||||
{
|
{
|
||||||
$res = \verify::staticIsAllowedChars ("éléphant", "abcd");
|
$res = Verify::staticIsAllowedChars ("éléphant", "abcd");
|
||||||
$this->assertSame ($res, false);
|
$this->assertSame ($res, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_staticIsAllowedChars_2 ()
|
public function test_staticIsAllowedChars_2 ()
|
||||||
{
|
{
|
||||||
$res = \verify::staticIsAllowedChars ("éléphant", "anhplté");
|
$res = Verify::staticIsAllowedChars ("éléphant", "anhplté");
|
||||||
$this->assertSame ($res, true);
|
$this->assertSame ($res, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -85,25 +87,25 @@ class verifyTest extends \PHPUnit_Framework_TestCase
|
|||||||
/////////////////
|
/////////////////
|
||||||
public function test_staticIs_integer1 ()
|
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);
|
$this->assertSame ($res, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_staticIs_integer2 ()
|
public function test_staticIs_integer2 ()
|
||||||
{
|
{
|
||||||
$res = \verify::staticIs_integer ("01234");
|
$res = Verify::staticIs_integer ("01234");
|
||||||
$this->assertSame ($res, true);
|
$this->assertSame ($res, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_staticIs_integer3 ()
|
public function test_staticIs_integer3 ()
|
||||||
{
|
{
|
||||||
$res = \verify::staticIs_integer ("0x1234");
|
$res = Verify::staticIs_integer ("0x1234");
|
||||||
$this->assertSame ($res, false);
|
$this->assertSame ($res, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_staticIs_integer4 ()
|
public function test_staticIs_integer4 ()
|
||||||
{
|
{
|
||||||
$res = \verify::staticIs_integer ("");
|
$res = Verify::staticIs_integer ("");
|
||||||
$this->assertSame ($res, false);
|
$this->assertSame ($res, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -116,27 +118,27 @@ class verifyTest extends \PHPUnit_Framework_TestCase
|
|||||||
/////////////
|
/////////////
|
||||||
public function test_is_url1 ()
|
public function test_is_url1 ()
|
||||||
{
|
{
|
||||||
$verify = new \verify ();
|
$verify = new Verify ();
|
||||||
$res = $verify->is_url ("invalid");
|
$res = $verify->is_url ("invalid");
|
||||||
$this->assertsame ($res, false);
|
$this->assertsame ($res, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_is_url2 ()
|
public function test_is_url2 ()
|
||||||
{
|
{
|
||||||
$verify = new \verify ();
|
$verify = new Verify ();
|
||||||
$res = $verify->is_url ("http://valid");
|
$res = $verify->is_url ("http://valid");
|
||||||
$this->assertsame ($res, true);
|
$this->assertsame ($res, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_staticIs_url1 ()
|
public function test_staticIs_url1 ()
|
||||||
{
|
{
|
||||||
$res = \verify::staticIs_url ("invalid");
|
$res = Verify::staticIs_url ("invalid");
|
||||||
$this->assertsame ($res, false);
|
$this->assertsame ($res, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_staticIs_url2 ()
|
public function test_staticIs_url2 ()
|
||||||
{
|
{
|
||||||
$res = \verify::staticIs_url ("http://valid");
|
$res = Verify::staticIs_url ("http://valid");
|
||||||
$this->assertsame ($res, true);
|
$this->assertsame ($res, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -145,40 +147,40 @@ class verifyTest extends \PHPUnit_Framework_TestCase
|
|||||||
////////////////
|
////////////////
|
||||||
public function test_is_UUID1 ()
|
public function test_is_UUID1 ()
|
||||||
{
|
{
|
||||||
$verify = new \verify ();
|
$verify = new Verify ();
|
||||||
$res = $verify->is_UUID ("ca39275f-9224-425f-ba94-efce2aa5b52c");
|
$res = $verify->is_UUID ("ca39275f-9224-425f-ba94-efce2aa5b52c");
|
||||||
$this->assertsame ($res, true);
|
$this->assertsame ($res, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_is_UUID2 ()
|
public function test_is_UUID2 ()
|
||||||
{
|
{
|
||||||
$verify = new \verify ();
|
$verify = new Verify ();
|
||||||
$res = $verify->is_UUID ("zz39275f-9224-425f-ba94-efce2aa5b52c");
|
$res = $verify->is_UUID ("zz39275f-9224-425f-ba94-efce2aa5b52c");
|
||||||
$this->assertsame ($res, false);
|
$this->assertsame ($res, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_is_UUID3 ()
|
public function test_is_UUID3 ()
|
||||||
{
|
{
|
||||||
$verify = new \verify ();
|
$verify = new Verify ();
|
||||||
$res = $verify->is_UUID ("2c");
|
$res = $verify->is_UUID ("2c");
|
||||||
$this->assertsame ($res, false);
|
$this->assertsame ($res, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_staticis_UUID1 ()
|
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);
|
$this->assertsame ($res, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_staticis_UUID2 ()
|
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);
|
$this->assertsame ($res, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_staticis_UUID3 ()
|
public function test_staticis_UUID3 ()
|
||||||
{
|
{
|
||||||
$res = \verify::staticis_UUID ("2c");
|
$res = Verify::staticis_UUID ("2c");
|
||||||
$this->assertsame ($res, false);
|
$this->assertsame ($res, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,8 @@
|
|||||||
|
|
||||||
namespace Domframework\Tests;
|
namespace Domframework\Tests;
|
||||||
|
|
||||||
|
use Domframework\Xdiff;
|
||||||
|
|
||||||
/** Test the domframework xdiff part */
|
/** Test the domframework xdiff part */
|
||||||
class xdiffTest extends \PHPUnit_Framework_TestCase
|
class xdiffTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
@@ -72,7 +74,7 @@ to this document.
|
|||||||
public function test_diff_normal_1 ()
|
public function test_diff_normal_1 ()
|
||||||
{
|
{
|
||||||
// Mode normal
|
// Mode normal
|
||||||
$xdiff = new xdiff ();
|
$xdiff = new Xdiff ();
|
||||||
$res = $xdiff->diff ($this->string1, $this->string2);
|
$res = $xdiff->diff ($this->string1, $this->string2);
|
||||||
$this->assertSame ($res, "0a1,6
|
$this->assertSame ($res, "0a1,6
|
||||||
> This is an important
|
> This is an important
|
||||||
@@ -102,7 +104,7 @@ to this document.
|
|||||||
public function test_diff_normal_2 ()
|
public function test_diff_normal_2 ()
|
||||||
{
|
{
|
||||||
// Mode normal
|
// Mode normal
|
||||||
$xdiff = new xdiff ();
|
$xdiff = new Xdiff ();
|
||||||
$res = $xdiff->diff ("NEWLINE\n".$this->string1, $this->string2);
|
$res = $xdiff->diff ("NEWLINE\n".$this->string1, $this->string2);
|
||||||
$this->assertSame ($res, "1c1,6
|
$this->assertSame ($res, "1c1,6
|
||||||
< NEWLINE
|
< NEWLINE
|
||||||
@@ -134,7 +136,7 @@ to this document.
|
|||||||
public function test_diff_normal_3 ()
|
public function test_diff_normal_3 ()
|
||||||
{
|
{
|
||||||
// Mode normal
|
// Mode normal
|
||||||
$xdiff = new xdiff ();
|
$xdiff = new Xdiff ();
|
||||||
$res = $xdiff->diff ("NEWLINE\n", "\n");
|
$res = $xdiff->diff ("NEWLINE\n", "\n");
|
||||||
$this->assertSame ($res, "1c1
|
$this->assertSame ($res, "1c1
|
||||||
< NEWLINE
|
< NEWLINE
|
||||||
@@ -146,7 +148,7 @@ to this document.
|
|||||||
public function test_diff_normal_4 ()
|
public function test_diff_normal_4 ()
|
||||||
{
|
{
|
||||||
// Mode normal
|
// Mode normal
|
||||||
$xdiff = new xdiff ();
|
$xdiff = new Xdiff ();
|
||||||
$res = $xdiff->diff ("\n", "NEWLINE\n");
|
$res = $xdiff->diff ("\n", "NEWLINE\n");
|
||||||
$this->assertSame ($res, "1c1
|
$this->assertSame ($res, "1c1
|
||||||
<
|
<
|
||||||
@@ -157,14 +159,14 @@ to this document.
|
|||||||
|
|
||||||
public function test_diff_normal_5 ()
|
public function test_diff_normal_5 ()
|
||||||
{
|
{
|
||||||
$xdiff = new xdiff ();
|
$xdiff = new Xdiff ();
|
||||||
$res = $xdiff->diff ("\n", "\n");
|
$res = $xdiff->diff ("\n", "\n");
|
||||||
$this->assertSame ($res, "");
|
$this->assertSame ($res, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_diff_normal_6 ()
|
public function test_diff_normal_6 ()
|
||||||
{
|
{
|
||||||
$xdiff = new xdiff ();
|
$xdiff = new Xdiff ();
|
||||||
$res = $xdiff->diff ("\n", "");
|
$res = $xdiff->diff ("\n", "");
|
||||||
$this->assertSame ($res, "1d0
|
$this->assertSame ($res, "1d0
|
||||||
< \n");
|
< \n");
|
||||||
@@ -172,7 +174,7 @@ to this document.
|
|||||||
|
|
||||||
public function test_diff_normal_7 ()
|
public function test_diff_normal_7 ()
|
||||||
{
|
{
|
||||||
$xdiff = new xdiff ();
|
$xdiff = new Xdiff ();
|
||||||
$res = $xdiff->diff ("", "\n");
|
$res = $xdiff->diff ("", "\n");
|
||||||
$this->assertSame ($res, "0a1
|
$this->assertSame ($res, "0a1
|
||||||
> \n");
|
> \n");
|
||||||
@@ -181,7 +183,7 @@ to this document.
|
|||||||
public function test_diff_unified_1 ()
|
public function test_diff_unified_1 ()
|
||||||
{
|
{
|
||||||
// Mode unified
|
// Mode unified
|
||||||
$xdiff = new xdiff ("unified");
|
$xdiff = new Xdiff ("unified");
|
||||||
$res = $xdiff->diff ($this->string1, $this->string2);
|
$res = $xdiff->diff ($this->string1, $this->string2);
|
||||||
$date = date ("Y-m-d H:i:s.u00");
|
$date = date ("Y-m-d H:i:s.u00");
|
||||||
// DST must answer +0200 in winter and +0100 in summer
|
// DST must answer +0200 in winter and +0100 in summer
|
||||||
@@ -215,7 +217,7 @@ to this document.
|
|||||||
public function test_diff_unified_2 ()
|
public function test_diff_unified_2 ()
|
||||||
{
|
{
|
||||||
// Mode unified
|
// Mode unified
|
||||||
$xdiff = new xdiff ("unified");
|
$xdiff = new Xdiff ("unified");
|
||||||
$res = $xdiff->diff ("NEWLINE\n".$this->string1, $this->string2);
|
$res = $xdiff->diff ("NEWLINE\n".$this->string1, $this->string2);
|
||||||
$this->assertSame ($res, "--- Original ".date ("Y-m-d H:i:s.u000 O")."
|
$this->assertSame ($res, "--- Original ".date ("Y-m-d H:i:s.u000 O")."
|
||||||
+++ New ".date ("Y-m-d H:i:s.u001 O")."
|
+++ New ".date ("Y-m-d H:i:s.u001 O")."
|
||||||
@@ -246,7 +248,7 @@ to this document.
|
|||||||
|
|
||||||
public function test_diff_unified_3 ()
|
public function test_diff_unified_3 ()
|
||||||
{
|
{
|
||||||
$xdiff = new xdiff ("unified");
|
$xdiff = new Xdiff ("unified");
|
||||||
$res = $xdiff->diff ("NEWLINE\n", "\n");
|
$res = $xdiff->diff ("NEWLINE\n", "\n");
|
||||||
$this->assertSame ($res, "--- Original ".date ("Y-m-d H:i:s.u000 O")."
|
$this->assertSame ($res, "--- Original ".date ("Y-m-d H:i:s.u000 O")."
|
||||||
+++ New ".date ("Y-m-d H:i:s.u001 O")."
|
+++ New ".date ("Y-m-d H:i:s.u001 O")."
|
||||||
@@ -258,7 +260,7 @@ to this document.
|
|||||||
|
|
||||||
public function test_diff_unified_4 ()
|
public function test_diff_unified_4 ()
|
||||||
{
|
{
|
||||||
$xdiff = new xdiff ("unified");
|
$xdiff = new Xdiff ("unified");
|
||||||
$res = $xdiff->diff ("\n", "NEWLINE\n");
|
$res = $xdiff->diff ("\n", "NEWLINE\n");
|
||||||
$this->assertSame ($res, "--- Original ".date ("Y-m-d H:i:s.u000 O")."
|
$this->assertSame ($res, "--- Original ".date ("Y-m-d H:i:s.u000 O")."
|
||||||
+++ New ".date ("Y-m-d H:i:s.u001 O")."
|
+++ New ".date ("Y-m-d H:i:s.u001 O")."
|
||||||
@@ -270,14 +272,14 @@ to this document.
|
|||||||
|
|
||||||
public function test_diff_unified_5 ()
|
public function test_diff_unified_5 ()
|
||||||
{
|
{
|
||||||
$xdiff = new xdiff ("unified");
|
$xdiff = new Xdiff ("unified");
|
||||||
$res = $xdiff->diff ("\n", "\n");
|
$res = $xdiff->diff ("\n", "\n");
|
||||||
$this->assertSame ($res, "");
|
$this->assertSame ($res, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_diff_unified_6 ()
|
public function test_diff_unified_6 ()
|
||||||
{
|
{
|
||||||
$xdiff = new xdiff ("unified");
|
$xdiff = new Xdiff ("unified");
|
||||||
$res = $xdiff->diff ("\n", "");
|
$res = $xdiff->diff ("\n", "");
|
||||||
$this->assertSame ($res, "--- Original ".date ("Y-m-d H:i:s.u000 O")."
|
$this->assertSame ($res, "--- Original ".date ("Y-m-d H:i:s.u000 O")."
|
||||||
+++ New ".date ("Y-m-d H:i:s.u001 O")."
|
+++ New ".date ("Y-m-d H:i:s.u001 O")."
|
||||||
@@ -287,7 +289,7 @@ to this document.
|
|||||||
|
|
||||||
public function test_diff_unified_7 ()
|
public function test_diff_unified_7 ()
|
||||||
{
|
{
|
||||||
$xdiff = new xdiff ("unified");
|
$xdiff = new Xdiff ("unified");
|
||||||
$res = $xdiff->diff ("", "\n");
|
$res = $xdiff->diff ("", "\n");
|
||||||
$this->assertSame ($res, "--- Original ".date ("Y-m-d H:i:s.u000 O")."
|
$this->assertSame ($res, "--- Original ".date ("Y-m-d H:i:s.u000 O")."
|
||||||
+++ New ".date ("Y-m-d H:i:s.u001 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_xdiff1", $this->string1);
|
||||||
file_put_contents ("/tmp/test_xdiff2", $this->string2);
|
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");
|
$res = $xdiff->diffFile ("/tmp/test_xdiff1", "/tmp/test_xdiff2");
|
||||||
$this->assertSame ($res, "--- /tmp/test_xdiff1 ".date ("Y-m-d H:i:s.u000 O")."
|
$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")."
|
+++ /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 ()
|
public function test_diffFile_unified_2 ()
|
||||||
{
|
{
|
||||||
$xdiff = new xdiff ("unified");
|
$xdiff = new Xdiff ("unified");
|
||||||
$this->setExpectedException ();
|
$this->setExpectedException ();
|
||||||
$res = $xdiff->diffFile ("/tmp/test_xdiffNOTEXISTS", "/tmp/test_xdiff2");
|
$res = $xdiff->diffFile ("/tmp/test_xdiffNOTEXISTS", "/tmp/test_xdiff2");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_diffFile_unified_3 ()
|
public function test_diffFile_unified_3 ()
|
||||||
{
|
{
|
||||||
$xdiff = new xdiff ("unified");
|
$xdiff = new Xdiff ("unified");
|
||||||
$this->setExpectedException ();
|
$this->setExpectedException ();
|
||||||
$res = $xdiff->diffFile ("/tmp/test_xdiff1", "/tmp/test_xdiffNOTEXISTS");
|
$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_xdiff1", $this->string1);
|
||||||
file_put_contents ("/tmp/test_xdiff2", $this->string2);
|
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");
|
$res = $xdiff->diffFile ("/tmp/test_xdiff1", "/tmp/test_xdiff2");
|
||||||
$this->assertSame ($res,
|
$this->assertSame ($res,
|
||||||
" > This is an important
|
" > This is an important
|
||||||
|
|||||||
@@ -7,19 +7,21 @@
|
|||||||
|
|
||||||
namespace Domframework\Tests;
|
namespace Domframework\Tests;
|
||||||
|
|
||||||
|
use Domframework\Xmppclient;
|
||||||
|
|
||||||
/** Test the domframework xmppclient part */
|
/** Test the domframework xmppclient part */
|
||||||
class xmppclientTest extends \PHPUnit_Framework_TestCase
|
class xmppclientTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
public function test_connection_BADNAME ()
|
public function test_connection_BADNAME ()
|
||||||
{
|
{
|
||||||
$this->expectException ("Exception");
|
$this->expectException ("Exception");
|
||||||
$xmppclient = new xmppclient ();
|
$xmppclient = new Xmppclient ();
|
||||||
$res = $xmppclient->connect ("NOTFOUND.fournier38.fr", 5222, "", "");
|
$res = $xmppclient->connect ("NOTFOUND.fournier38.fr", 5222, "", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_connection_authenticate_1 ()
|
public function test_connection_authenticate_1 ()
|
||||||
{
|
{
|
||||||
$xmppclient = new xmppclient ();
|
$xmppclient = new Xmppclient ();
|
||||||
$res = $xmppclient->connect ("xmpp.fournier38.fr", 5222,
|
$res = $xmppclient->connect ("xmpp.fournier38.fr", 5222,
|
||||||
"testxmpp@xmpp.fournier38.fr", "LSqmBXDUZWxk");
|
"testxmpp@xmpp.fournier38.fr", "LSqmBXDUZWxk");
|
||||||
$this->assertSame (is_object ($res), true);
|
$this->assertSame (is_object ($res), true);
|
||||||
@@ -27,7 +29,7 @@ class xmppclientTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_connection_disco_1 ()
|
public function test_connection_disco_1 ()
|
||||||
{
|
{
|
||||||
$xmppclient = new xmppclient ();
|
$xmppclient = new Xmppclient ();
|
||||||
$xmppclient->connect ("xmpp.fournier38.fr", 5222,
|
$xmppclient->connect ("xmpp.fournier38.fr", 5222,
|
||||||
"testxmpp@xmpp.fournier38.fr", "LSqmBXDUZWxk");
|
"testxmpp@xmpp.fournier38.fr", "LSqmBXDUZWxk");
|
||||||
$res = $xmppclient->discoveryService ();
|
$res = $xmppclient->discoveryService ();
|
||||||
@@ -36,7 +38,7 @@ class xmppclientTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_connection_sendMessage_1 ()
|
public function test_connection_sendMessage_1 ()
|
||||||
{
|
{
|
||||||
$xmppclient = new xmppclient ();
|
$xmppclient = new Xmppclient ();
|
||||||
$xmppclient->connect ("xmpp.fournier38.fr", 5222,
|
$xmppclient->connect ("xmpp.fournier38.fr", 5222,
|
||||||
"testxmpp@xmpp.fournier38.fr", "LSqmBXDUZWxk");
|
"testxmpp@xmpp.fournier38.fr", "LSqmBXDUZWxk");
|
||||||
$res = $xmppclient->sendMessagePrivate ("dominique@fournier38.fr",
|
$res = $xmppclient->sendMessagePrivate ("dominique@fournier38.fr",
|
||||||
@@ -46,7 +48,7 @@ class xmppclientTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function test_connection_sendMessage_2 ()
|
public function test_connection_sendMessage_2 ()
|
||||||
{
|
{
|
||||||
$xmppclient = new xmppclient ();
|
$xmppclient = new Xmppclient ();
|
||||||
$xmppclient->connect ("xmpp.fournier38.fr", 5222,
|
$xmppclient->connect ("xmpp.fournier38.fr", 5222,
|
||||||
"testxmpp@xmpp.fournier38.fr", "LSqmBXDUZWxk");
|
"testxmpp@xmpp.fournier38.fr", "LSqmBXDUZWxk");
|
||||||
$res = $xmppclient->sendMessagePrivate ("dominique@fournier38.fr",
|
$res = $xmppclient->sendMessagePrivate ("dominique@fournier38.fr",
|
||||||
|
|||||||
@@ -119,7 +119,7 @@ class Authjwt extends Auth
|
|||||||
if ($auth["email"] === "anonymous")
|
if ($auth["email"] === "anonymous")
|
||||||
throw new \Exception (dgettext ("domframework",
|
throw new \Exception (dgettext ("domframework",
|
||||||
"AuthJWT : can not create token for anonymous"), 403);
|
"AuthJWT : can not create token for anonymous"), 403);
|
||||||
$uuid = uuid::uuid4 ();
|
$uuid = Uuid::uuid4 ();
|
||||||
$cachefile = new Cachefile ();
|
$cachefile = new Cachefile ();
|
||||||
$cachefile->directory = $this->cacheDir;
|
$cachefile->directory = $this->cacheDir;
|
||||||
$cachefile->write ($uuid, $auth);
|
$cachefile->write ($uuid, $auth);
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ class Authorizationdb extends Authorization
|
|||||||
{
|
{
|
||||||
$this->treecheckExecute ($object);
|
$this->treecheckExecute ($object);
|
||||||
}
|
}
|
||||||
catch (Exception $e)
|
catch (\Exception $e)
|
||||||
{
|
{
|
||||||
throw new \Exception ($e->getMessage(), 405);
|
throw new \Exception ($e->getMessage(), 405);
|
||||||
}
|
}
|
||||||
@@ -163,7 +163,7 @@ class Authorizationdb extends Authorization
|
|||||||
{
|
{
|
||||||
$this->treecheckExecute ($object);
|
$this->treecheckExecute ($object);
|
||||||
}
|
}
|
||||||
catch (Exception $e)
|
catch (\Exception $e)
|
||||||
{
|
{
|
||||||
throw new \Exception ($e->getMessage(), 405);
|
throw new \Exception ($e->getMessage(), 405);
|
||||||
}
|
}
|
||||||
@@ -191,7 +191,7 @@ class Authorizationdb extends Authorization
|
|||||||
{
|
{
|
||||||
$this->treecheckWrite ($object);
|
$this->treecheckWrite ($object);
|
||||||
}
|
}
|
||||||
catch (Exception $e)
|
catch (\Exception $e)
|
||||||
{
|
{
|
||||||
throw new \Exception ($e->getMessage(), 405);
|
throw new \Exception ($e->getMessage(), 405);
|
||||||
}
|
}
|
||||||
@@ -227,7 +227,7 @@ class Authorizationdb extends Authorization
|
|||||||
{
|
{
|
||||||
$this->treecheckExecute ($object);
|
$this->treecheckExecute ($object);
|
||||||
}
|
}
|
||||||
catch (Exception $e)
|
catch (\Exception $e)
|
||||||
{
|
{
|
||||||
throw new \Exception ($e->getMessage(), 405);
|
throw new \Exception ($e->getMessage(), 405);
|
||||||
}
|
}
|
||||||
@@ -259,7 +259,7 @@ class Authorizationdb extends Authorization
|
|||||||
{
|
{
|
||||||
$this->treecheckWrite ($object);
|
$this->treecheckWrite ($object);
|
||||||
}
|
}
|
||||||
catch (Exception $e)
|
catch (\Exception $e)
|
||||||
{
|
{
|
||||||
throw new \Exception ($e->getMessage(), 405);
|
throw new \Exception ($e->getMessage(), 405);
|
||||||
}
|
}
|
||||||
@@ -301,7 +301,7 @@ class Authorizationdb extends Authorization
|
|||||||
{
|
{
|
||||||
$this->treecheckExecute ($object);
|
$this->treecheckExecute ($object);
|
||||||
}
|
}
|
||||||
catch (Exception $e)
|
catch (\Exception $e)
|
||||||
{
|
{
|
||||||
throw new \Exception ($e->getMessage(), 405);
|
throw new \Exception ($e->getMessage(), 405);
|
||||||
}
|
}
|
||||||
@@ -347,7 +347,7 @@ class Authorizationdb extends Authorization
|
|||||||
{
|
{
|
||||||
$this->treecheckExecute ($object);
|
$this->treecheckExecute ($object);
|
||||||
}
|
}
|
||||||
catch (Exception $e)
|
catch (\Exception $e)
|
||||||
{
|
{
|
||||||
throw new \Exception ($e->getMessage(), 405);
|
throw new \Exception ($e->getMessage(), 405);
|
||||||
}
|
}
|
||||||
@@ -390,7 +390,7 @@ class Authorizationdb extends Authorization
|
|||||||
{
|
{
|
||||||
$this->treecheckExecute ($object);
|
$this->treecheckExecute ($object);
|
||||||
}
|
}
|
||||||
catch (Exception $e)
|
catch (\Exception $e)
|
||||||
{
|
{
|
||||||
throw new \Exception ($e->getMessage(), 405);
|
throw new \Exception ($e->getMessage(), 405);
|
||||||
}
|
}
|
||||||
@@ -430,7 +430,7 @@ class Authorizationdb extends Authorization
|
|||||||
{
|
{
|
||||||
$this->treecheckExecute ($object);
|
$this->treecheckExecute ($object);
|
||||||
}
|
}
|
||||||
catch (Exception $e)
|
catch (\Exception $e)
|
||||||
{
|
{
|
||||||
throw new \Exception ($e->getMessage(), 405);
|
throw new \Exception ($e->getMessage(), 405);
|
||||||
}
|
}
|
||||||
@@ -468,7 +468,7 @@ class Authorizationdb extends Authorization
|
|||||||
{
|
{
|
||||||
$this->treecheckExecute ($object);
|
$this->treecheckExecute ($object);
|
||||||
}
|
}
|
||||||
catch (Exception $e)
|
catch (\Exception $e)
|
||||||
{
|
{
|
||||||
throw new \Exception ($e->getMessage(), 405);
|
throw new \Exception ($e->getMessage(), 405);
|
||||||
}
|
}
|
||||||
@@ -506,7 +506,7 @@ class Authorizationdb extends Authorization
|
|||||||
{
|
{
|
||||||
$this->treecheckExecute ($object);
|
$this->treecheckExecute ($object);
|
||||||
}
|
}
|
||||||
catch (Exception $e)
|
catch (\Exception $e)
|
||||||
{
|
{
|
||||||
throw new \Exception ($e->getMessage(), 405);
|
throw new \Exception ($e->getMessage(), 405);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ class Authzgroups
|
|||||||
{
|
{
|
||||||
$st = $this->dbObject->prepare ($req);
|
$st = $this->dbObject->prepare ($req);
|
||||||
}
|
}
|
||||||
catch (Exception $e)
|
catch (\Exception $e)
|
||||||
{
|
{
|
||||||
if ($this->dbObject->debug) echo "DEBUG : PREPARE ERROR ! Return FALSE".
|
if ($this->dbObject->debug) echo "DEBUG : PREPARE ERROR ! Return FALSE".
|
||||||
$e->getMessage()."\n";
|
$e->getMessage()."\n";
|
||||||
@@ -86,14 +86,14 @@ class Authzgroups
|
|||||||
if ($rc === false)
|
if ($rc === false)
|
||||||
throw new \Exception ("Can't execute SQL request", 500);
|
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".
|
if ($this->dbObject->debug) echo "DEBUG : EXECUTE ERROR ! Return FALSE".
|
||||||
$e->getMessage()."\n";
|
$e->getMessage()."\n";
|
||||||
throw new \Exception ($e->getMessage(), 500);
|
throw new \Exception ($e->getMessage(), 500);
|
||||||
}
|
}
|
||||||
$res = array ();
|
$res = array ();
|
||||||
while ($d = $st->fetch (PDO::FETCH_ASSOC))
|
while ($d = $st->fetch (\PDO::FETCH_ASSOC))
|
||||||
$res[$d["object"]] = $d["right"];
|
$res[$d["object"]] = $d["right"];
|
||||||
// Transform the numerical rights to RO/RW
|
// Transform the numerical rights to RO/RW
|
||||||
foreach ($res as $k=>$r)
|
foreach ($res as $k=>$r)
|
||||||
@@ -382,7 +382,7 @@ class Authzgroups
|
|||||||
$class= "db$table";
|
$class= "db$table";
|
||||||
$this->$class->createTable ();
|
$this->$class->createTable ();
|
||||||
}
|
}
|
||||||
catch (Exception $e)
|
catch (\Exception $e)
|
||||||
{
|
{
|
||||||
echo $e->getMessage()."\n";
|
echo $e->getMessage()."\n";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -253,7 +253,7 @@ class Cli
|
|||||||
$constParams .= ">";
|
$constParams .= ">";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception $e)
|
catch (\Exception $e)
|
||||||
{
|
{
|
||||||
// No constructor
|
// No constructor
|
||||||
}
|
}
|
||||||
@@ -346,7 +346,7 @@ class Cli
|
|||||||
$paramsConst = $r1->getParameters();
|
$paramsConst = $r1->getParameters();
|
||||||
$min = $max = count ($paramsConst);
|
$min = $max = count ($paramsConst);
|
||||||
}
|
}
|
||||||
catch (Exception $e)
|
catch (\Exception $e)
|
||||||
{
|
{
|
||||||
// No constructor available in class
|
// No constructor available in class
|
||||||
}
|
}
|
||||||
@@ -437,7 +437,7 @@ class Cli
|
|||||||
var_dump ($s);
|
var_dump ($s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception $e)
|
catch (\Exception $e)
|
||||||
{
|
{
|
||||||
file_put_contents("php://stderr", $e->getMessage()."\n");
|
file_put_contents("php://stderr", $e->getMessage()."\n");
|
||||||
if ($this->EXPERT)
|
if ($this->EXPERT)
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ class Convert
|
|||||||
foreach (preg_split ("#([".preg_quote ($delimiters)."]+)#", $str, -1,
|
foreach (preg_split ("#([".preg_quote ($delimiters)."]+)#", $str, -1,
|
||||||
PREG_SPLIT_DELIM_CAPTURE) as $tok)
|
PREG_SPLIT_DELIM_CAPTURE) as $tok)
|
||||||
{
|
{
|
||||||
$res .= \convert::ucfirst ($tok);
|
$res .= Convert::ucfirst ($tok);
|
||||||
}
|
}
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -389,7 +389,7 @@ class Dblayer
|
|||||||
elseif ($data[$key] !== "" && $params[0] === "datetime")
|
elseif ($data[$key] !== "" && $params[0] === "datetime")
|
||||||
{
|
{
|
||||||
// The date format must be in ANSI SQL : YYYY-MM-DD HH:MM:SS
|
// 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])
|
if (!$d || $d->format("Y-m-d H:i:s") !== $data[$key])
|
||||||
{
|
{
|
||||||
$errors[$key] = array ("error", sprintf (
|
$errors[$key] = array ("error", sprintf (
|
||||||
@@ -402,7 +402,7 @@ class Dblayer
|
|||||||
elseif ($data[$key] !== "" && $params[0] === "date")
|
elseif ($data[$key] !== "" && $params[0] === "date")
|
||||||
{
|
{
|
||||||
// The date format must be in ANSI SQL : YYYY-MM-DD
|
// 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])
|
if (!$d || $d->format("Y-m-d") !== $data[$key])
|
||||||
{
|
{
|
||||||
$errors[$key] = array ("error", sprintf (
|
$errors[$key] = array ("error", sprintf (
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ class Dblayerauthzgroups extends Dblayer
|
|||||||
$this->authzgroups->accessRight ($this->module, $this->user,
|
$this->authzgroups->accessRight ($this->module, $this->user,
|
||||||
$this->path."/".$line[$this->primary]);
|
$this->path."/".$line[$this->primary]);
|
||||||
}
|
}
|
||||||
catch (Exception $e)
|
catch (\Exception $e)
|
||||||
{
|
{
|
||||||
unset ($data[$key]);
|
unset ($data[$key]);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1647,10 +1647,10 @@ class Dblayeroo
|
|||||||
if (! is_object ($object))
|
if (! is_object ($object))
|
||||||
$this->DBException ("Invalid setForeignObj parameter: not an object");
|
$this->DBException ("Invalid setForeignObj parameter: not an object");
|
||||||
if (! is_subclass_of ($object, __CLASS__) &&
|
if (! is_subclass_of ($object, __CLASS__) &&
|
||||||
get_class ($object) !== "dblayeroo" &&
|
get_class ($object) !== "Dblayeroo" &&
|
||||||
get_class ($object) !== __NAMESPACE__."\dblayeroo")
|
get_class ($object) !== __NAMESPACE__."\Dblayeroo")
|
||||||
$this->DBException (
|
$this->DBException (
|
||||||
"Invalid object provided to setForeignObj (not dblayeroo object)");
|
"Invalid object provided to setForeignObj (not Dblayeroo object)");
|
||||||
if (! isset ($object->table))
|
if (! isset ($object->table))
|
||||||
$this->DBException (
|
$this->DBException (
|
||||||
"Invalid object provided to setForeignObj (no table defined)");
|
"Invalid object provided to setForeignObj (no table defined)");
|
||||||
@@ -2098,10 +2098,10 @@ class Dblayeroo
|
|||||||
if (! is_object ($object))
|
if (! is_object ($object))
|
||||||
$this->DBException ("Invalid object provided to join (not object)");
|
$this->DBException ("Invalid object provided to join (not object)");
|
||||||
if (! is_subclass_of ($object, __CLASS__) &&
|
if (! is_subclass_of ($object, __CLASS__) &&
|
||||||
get_class ($object) !== "dblayeroo" &&
|
get_class ($object) !== "Dblayeroo" &&
|
||||||
get_class ($object) !== __NAMESPACE__."\dblayeroo")
|
get_class ($object) !== __NAMESPACE__."\Dblayeroo")
|
||||||
$this->DBException (
|
$this->DBException (
|
||||||
"Invalid object provided to join (not dblayeroo object)");
|
"Invalid object provided to join (not Dblayeroo object)");
|
||||||
if ($this->dsn !== $object->dsn)
|
if ($this->dsn !== $object->dsn)
|
||||||
$this->DBException (
|
$this->DBException (
|
||||||
"DSN different : don't support JOIN between databases");
|
"DSN different : don't support JOIN between databases");
|
||||||
|
|||||||
@@ -771,7 +771,7 @@ class Mail
|
|||||||
// time. An exception is raised, but it is not important
|
// time. An exception is raised, but it is not important
|
||||||
$this->delHeader ($head, $sectionID);
|
$this->delHeader ($head, $sectionID);
|
||||||
}
|
}
|
||||||
catch (Exception $e)
|
catch (\Exception $e)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
16
src/Rss.php
16
src/Rss.php
@@ -60,7 +60,7 @@ class Rss
|
|||||||
return $this->link;
|
return $this->link;
|
||||||
if (! is_string ($link))
|
if (! is_string ($link))
|
||||||
throw new \Exception ("Link provided to RSS is not a string", 500);
|
throw new \Exception ("Link provided to RSS is not a string", 500);
|
||||||
$verify = new verify ();
|
$verify = new Verify ();
|
||||||
if (! $verify->is_URL ($link))
|
if (! $verify->is_URL ($link))
|
||||||
throw new \Exception ("Link provided to RSS is not an URL", 500);
|
throw new \Exception ("Link provided to RSS is not an URL", 500);
|
||||||
if ($link === "")
|
if ($link === "")
|
||||||
@@ -124,14 +124,14 @@ class Rss
|
|||||||
if (! is_string ($lastBuildDate))
|
if (! is_string ($lastBuildDate))
|
||||||
throw new \Exception ("lastBuildDate provided to RSS is not a string",
|
throw new \Exception ("lastBuildDate provided to RSS is not a string",
|
||||||
500);
|
500);
|
||||||
$verify = new verify ();
|
$verify = new Verify ();
|
||||||
if (! $verify->is_datetimeSQL ($lastBuildDate))
|
if (! $verify->is_datetimeSQL ($lastBuildDate))
|
||||||
throw new \Exception ("lastBuildDate provided to RSS is not a valid date",
|
throw new \Exception ("lastBuildDate provided to RSS is not a valid date",
|
||||||
500);
|
500);
|
||||||
if ($lastBuildDate === "")
|
if ($lastBuildDate === "")
|
||||||
$lastBuildDate = null;
|
$lastBuildDate = null;
|
||||||
else
|
else
|
||||||
$lastBuildDate = \convert::convertDate ($lastBuildDate, "Y-m-d H:i:s",
|
$lastBuildDate = Convert::convertDate ($lastBuildDate, "Y-m-d H:i:s",
|
||||||
\DateTime::RFC2822);
|
\DateTime::RFC2822);
|
||||||
$this->lastBuildDate = $lastBuildDate;
|
$this->lastBuildDate = $lastBuildDate;
|
||||||
return $this;
|
return $this;
|
||||||
@@ -194,7 +194,7 @@ class Rss
|
|||||||
$tmpItem->pubDate = $item->pubDate ();
|
$tmpItem->pubDate = $item->pubDate ();
|
||||||
}
|
}
|
||||||
// Ident correctely the xml created in SimpleXML
|
// Ident correctely the xml created in SimpleXML
|
||||||
$dom = new DOMDocument('1.0');
|
$dom = new \DOMDocument('1.0');
|
||||||
$dom->preserveWhiteSpace = false;
|
$dom->preserveWhiteSpace = false;
|
||||||
$dom->formatOutput = true;
|
$dom->formatOutput = true;
|
||||||
$dom->loadXML($xml->asXML());
|
$dom->loadXML($xml->asXML());
|
||||||
@@ -258,7 +258,7 @@ class Rssitem
|
|||||||
return $this->link;
|
return $this->link;
|
||||||
if (! is_string ($link))
|
if (! is_string ($link))
|
||||||
throw new \Exception ("Link provided to RSS Item is not a string", 500);
|
throw new \Exception ("Link provided to RSS Item is not a string", 500);
|
||||||
$verify = new verify ();
|
$verify = new Verify ();
|
||||||
if (! $verify->is_URL ($link))
|
if (! $verify->is_URL ($link))
|
||||||
throw new \Exception ("Link provided to RSS Item is not an URL", 500);
|
throw new \Exception ("Link provided to RSS Item is not an URL", 500);
|
||||||
if ($link === "")
|
if ($link === "")
|
||||||
@@ -339,14 +339,14 @@ class Rssitem
|
|||||||
if (! is_string ($pubDate))
|
if (! is_string ($pubDate))
|
||||||
throw new \Exception ("pubDate provided to RSS Item is not a string",
|
throw new \Exception ("pubDate provided to RSS Item is not a string",
|
||||||
500);
|
500);
|
||||||
if (! \verify::staticIs_datetimeSQL ($pubDate))
|
if (! Verify::staticIs_datetimeSQL ($pubDate))
|
||||||
throw new \Exception ("pubDate provided to RSS Item is not a valid date",
|
throw new \Exception ("pubDate provided to RSS Item is not a valid date",
|
||||||
500);
|
500);
|
||||||
if ($pubDate === "")
|
if ($pubDate === "")
|
||||||
$pubDate = null;
|
$pubDate = null;
|
||||||
else
|
else
|
||||||
$pubDate = \convert::convertDate ($pubDate, "Y-m-d H:i:s",
|
$pubDate = Convert::convertDate ($pubDate, "Y-m-d H:i:s",
|
||||||
DateTime::RFC2822);
|
\DateTime::RFC2822);
|
||||||
$this->pubDate = $pubDate;
|
$this->pubDate = $pubDate;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user