Update Tests to supports namespaces

This commit is contained in:
2021-05-07 16:55:38 +02:00
parent ccf0f47c7f
commit 55530b055c
49 changed files with 82 additions and 64 deletions

View File

@@ -7,26 +7,28 @@
namespace Domframework\Tests; namespace Domframework\Tests;
use Domframework\Auth;
/** Test the authentication */ /** Test the authentication */
class authTest extends PHPUnit_Framework_TestCase class AuthTest extends \PHPUnit_Framework_TestCase
{ {
public function test_page_1 () public function test_page_1 ()
{ {
$auth = new auth (); $auth = new Auth ();
$res = $auth->pageHTML ("http://localhost"); $res = $auth->pageHTML ("http://localhost");
$this->assertSame (!! strpos ($res, "<form "), true); $this->assertSame (!! strpos ($res, "<form "), true);
} }
public function test_Message () public function test_Message ()
{ {
$auth = new auth (); $auth = new Auth ();
$res = $auth->pageHTML ("http://localhost", "MESSAGE"); $res = $auth->pageHTML ("http://localhost", "MESSAGE");
$this->assertSame (!! strpos ($res, "MESSAGE"), true); $this->assertSame (!! strpos ($res, "MESSAGE"), true);
} }
public function test_URL_1 () public function test_URL_1 ()
{ {
$auth = new auth (); $auth = new Auth ();
$res = $auth->pageHTML ("http://localhost", "MESSAGE", "URL/TEST"); $res = $auth->pageHTML ("http://localhost", "MESSAGE", "URL/TEST");
$this->assertSame (!! strpos ($res, "URL/TEST"), true); $this->assertSame (!! strpos ($res, "URL/TEST"), true);
} }
@@ -34,7 +36,7 @@ class authTest extends PHPUnit_Framework_TestCase
public function test_alreadyAuth_1 () public function test_alreadyAuth_1 ()
{ {
// Not Authenticated // Not Authenticated
$auth = new auth (); $auth = new Auth ();
$res = $auth->pageHTML ("http://localhost", "MESSAGE", "URL/TEST", false); $res = $auth->pageHTML ("http://localhost", "MESSAGE", "URL/TEST", false);
$this->assertSame (!! strpos ($res, "Please sign in"), true); $this->assertSame (!! strpos ($res, "Please sign in"), true);
} }
@@ -42,7 +44,7 @@ class authTest extends PHPUnit_Framework_TestCase
public function test_alreadyAuth_2 () public function test_alreadyAuth_2 ()
{ {
// Authenticated // Authenticated
$auth = new auth (); $auth = new Auth ();
$res = $auth->pageHTML ("http://localhost", "", "", "AUTHENTICATED USER"); $res = $auth->pageHTML ("http://localhost", "", "", "AUTHENTICATED USER");
$this->assertSame (!! strpos ($res, "AUTHENTICATED USER"), true); $this->assertSame (!! strpos ($res, "AUTHENTICATED USER"), true);
} }

View File

@@ -8,7 +8,7 @@
namespace Domframework\Tests; namespace Domframework\Tests;
/** Test the authhtpasswd.php file */ /** Test the authhtpasswd.php file */
class authhtpasswdTest extends PHPUnit_Framework_TestCase class authhtpasswdTest extends \PHPUnit_Framework_TestCase
{ {
public function test_clean () public function test_clean ()
{ {

View File

@@ -8,7 +8,7 @@
namespace Domframework\Tests; namespace Domframework\Tests;
/** Test the authjwt.php file */ /** Test the authjwt.php file */
class authjwtTest extends PHPUnit_Framework_TestCase class authjwtTest extends \PHPUnit_Framework_TestCase
{ {
public function __construct () public function __construct ()
{ {

View File

@@ -8,7 +8,7 @@
namespace Domframework\Tests; namespace Domframework\Tests;
/** 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 ()
{ {

View File

@@ -8,7 +8,7 @@
namespace Domframework\Tests; namespace Domframework\Tests;
/** Test the authzgroups.php file */ /** Test the authzgroups.php file */
class authzgroupsTest extends PHPUnit_Framework_TestCase class authzgroupsTest extends \PHPUnit_Framework_TestCase
{ {
private $dbconfig = array ( private $dbconfig = array (
"dsn" => "sqlite:/tmp/databaseAuthzGroups.db", "dsn" => "sqlite:/tmp/databaseAuthzGroups.db",

View File

@@ -8,7 +8,7 @@
namespace Domframework\Tests; namespace Domframework\Tests;
/** Test the authzgroupsoo.php file */ /** Test the authzgroupsoo.php file */
class authzgroupsooTest extends PHPUnit_Framework_TestCase class authzgroupsooTest extends \PHPUnit_Framework_TestCase
{ {
private $dbconfig = array ( private $dbconfig = array (
"dsn" => "sqlite:/tmp/databaseAuthzGroupsoo.db", "dsn" => "sqlite:/tmp/databaseAuthzGroupsoo.db",

View File

@@ -8,7 +8,7 @@
namespace Domframework\Tests; namespace Domframework\Tests;
/** Test the cache.php file */ /** Test the cache.php file */
class cachefileTest extends PHPUnit_Framework_TestCase class cachefileTest extends \PHPUnit_Framework_TestCase
{ {
public function testInit () public function testInit ()
{ {

View File

@@ -9,7 +9,7 @@ namespace Domframework\Tests;
/** 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 ()
{ {

View File

@@ -8,7 +8,7 @@
namespace Domframework\Tests; namespace Domframework\Tests;
/** Test the config.php file */ /** Test the config.php file */
class configTest extends PHPUnit_Framework_TestCase class configTest extends \PHPUnit_Framework_TestCase
{ {
public function test_ExternFile () public function test_ExternFile ()

View File

@@ -8,7 +8,7 @@
namespace Domframework\Tests; namespace Domframework\Tests;
/** 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 ()
{ {

View File

@@ -8,7 +8,7 @@
namespace Domframework\Tests; namespace Domframework\Tests;
/** Test the csrf.php file */ /** Test the csrf.php file */
class csrfTest extends PHPUnit_Framework_TestCase class csrfTest extends \PHPUnit_Framework_TestCase
{ {
public function test_csrf1 () public function test_csrf1 ()
{ {

View File

@@ -8,7 +8,7 @@
namespace Domframework\Tests; namespace Domframework\Tests;
/** Test the dbjson database */ /** Test the dbjson database */
class dbjsonTest extends PHPUnit_Framework_TestCase class dbjsonTest extends \PHPUnit_Framework_TestCase
{ {
public function test_insertOne1 () public function test_insertOne1 ()
{ {

View File

@@ -7,7 +7,7 @@
namespace Domframework\Tests; namespace Domframework\Tests;
class dblayerauthzgroupsTest extends PHPUnit_Framework_TestCase class dblayerauthzgroupsTest extends \PHPUnit_Framework_TestCase
{ {
public $confs = array ( public $confs = array (
"sqlite" => array ( "sqlite" => array (

View File

@@ -5,7 +5,7 @@
*/ */
/** Test the encrypt.php file */ /** Test the encrypt.php file */
class encryptTest extends PHPUnit_Framework_TestCase class encryptTest extends \PHPUnit_Framework_TestCase
{ {
/** Check the length of the otken with cipher /** Check the length of the otken with cipher
*/ */

View File

@@ -4,7 +4,7 @@
@author Dominique Fournier <dominique@fournier38.fr> */ @author Dominique Fournier <dominique@fournier38.fr> */
/** Test the domframework file part */ /** Test the domframework file part */
class fileTest extends PHPUnit_Framework_TestCase class fileTest extends \PHPUnit_Framework_TestCase
{ {
public function testinit () public function testinit ()
{ {

View File

@@ -1,7 +1,7 @@
<?php <?php
/** 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 ()
{ {

View File

@@ -8,7 +8,7 @@
namespace Domframework\Tests; namespace Domframework\Tests;
/** 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 ()
{ {

View File

@@ -8,7 +8,7 @@
namespace Domframework\Tests; namespace Domframework\Tests;
/** Test the http.php file */ /** Test the http.php file */
class httpTest extends PHPUnit_Framework_TestCase class httpTest extends \PHPUnit_Framework_TestCase
{ {
/** bestChoice : exact existing entry /** bestChoice : exact existing entry
*/ */

View File

@@ -8,7 +8,7 @@
namespace Domframework\Tests; namespace Domframework\Tests;
/** Test the outputjson.php file */ /** Test the outputjson.php file */
class inifileTest extends PHPUnit_Framework_TestCase class inifileTest extends \PHPUnit_Framework_TestCase
{ {
public function testsetString001 () public function testsetString001 ()
{ {

View File

@@ -8,7 +8,7 @@
namespace Domframework\Tests; namespace Domframework\Tests;
/** Test the ipaddresses.php file */ /** Test the ipaddresses.php file */
class ipaddressesTest extends PHPUnit_Framework_TestCase class ipaddressesTest extends \PHPUnit_Framework_TestCase
{ {
public function test_validIPAddress1 () public function test_validIPAddress1 ()
{ {

View File

@@ -8,7 +8,7 @@
namespace Domframework\Tests; namespace Domframework\Tests;
/** Test the jwt.php file */ /** Test the jwt.php file */
class jwtTest extends PHPUnit_Framework_TestCase class jwtTest extends \PHPUnit_Framework_TestCase
{ {
public function test_createKey_1 () public function test_createKey_1 ()
{ {

View File

@@ -8,7 +8,7 @@
namespace Domframework\Tests; namespace Domframework\Tests;
/** Test the macaddresses.php file */ /** Test the macaddresses.php file */
class macaddressesTest extends PHPUnit_Framework_TestCase class macaddressesTest extends \PHPUnit_Framework_TestCase
{ {
public function test_isMACAddress_1 () public function test_isMACAddress_1 ()
{ {

View File

@@ -8,7 +8,7 @@
namespace Domframework\Tests; namespace Domframework\Tests;
/** Test the mail.php file */ /** Test the mail.php file */
class mailTest extends PHPUnit_Framework_TestCase class mailTest extends \PHPUnit_Framework_TestCase
{ {
public function test_setBodyText1 () public function test_setBodyText1 ()
{ {

View File

@@ -8,7 +8,7 @@
namespace Domframework\Tests; namespace Domframework\Tests;
/** Test the outputjson.php file */ /** Test the outputjson.php file */
class markdownTest extends PHPUnit_Framework_TestCase class markdownTest extends \PHPUnit_Framework_TestCase
{ {
// TitleSeText // TitleSeText
public function testTitleSeText1 () public function testTitleSeText1 ()

View File

@@ -8,7 +8,7 @@
namespace Domframework\Tests; namespace Domframework\Tests;
/** Test the outputdl.php file */ /** Test the outputdl.php file */
class outputdlTest extends PHPUnit_Framework_TestCase class outputdlTest extends \PHPUnit_Framework_TestCase
{ {
public function test_outputdl_init () public function test_outputdl_init ()
{ {

View File

@@ -8,7 +8,7 @@
namespace Domframework\Tests; namespace Domframework\Tests;
/** Test the outputhtml.php file */ /** Test the outputhtml.php file */
class outputhtmlTest extends PHPUnit_Framework_TestCase class outputhtmlTest extends \PHPUnit_Framework_TestCase
{ {
/** Entry null */ /** Entry null */
public function testlayout1 () public function testlayout1 ()

View File

@@ -8,7 +8,7 @@
namespace Domframework\Tests; namespace Domframework\Tests;
/** Test the outputjson.php file */ /** Test the outputjson.php file */
class outputjsonTest extends PHPUnit_Framework_TestCase class outputjsonTest extends \PHPUnit_Framework_TestCase
{ {
/** Entry null */ /** Entry null */
public function testoutputjson1 () public function testoutputjson1 ()

View File

@@ -9,7 +9,7 @@ namespace Domframework\Tests;
/** Test the password class /** 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 ()
{ {

View File

@@ -8,7 +8,7 @@
namespace Domframework\Tests; namespace Domframework\Tests;
/** Test the queue.php file */ /** Test the queue.php file */
class queueTest extends PHPUnit_Framework_TestCase class queueTest extends \PHPUnit_Framework_TestCase
{ {
public function test () public function test ()
{ {

View File

@@ -8,7 +8,7 @@
namespace Domframework\Tests; namespace Domframework\Tests;
/** Test the queuefile.php file */ /** Test the queuefile.php file */
class queuefileTest extends PHPUnit_Framework_TestCase class queuefileTest extends \PHPUnit_Framework_TestCase
{ {
public function test_clean () public function test_clean ()
{ {

View File

@@ -8,7 +8,7 @@
namespace Domframework\Tests; namespace Domframework\Tests;
/** Test the ratelimit.php file */ /** Test the ratelimit.php file */
class ratelimitTest extends PHPUnit_Framework_TestCase class ratelimitTest extends \PHPUnit_Framework_TestCase
{ {
public function test_ratelimit0 () public function test_ratelimit0 ()
{ {

View File

@@ -8,7 +8,7 @@
namespace Domframework\Tests; namespace Domframework\Tests;
/** Test the ratelimitfile.php file */ /** Test the ratelimitfile.php file */
class ratelimitfileTest extends PHPUnit_Framework_TestCase class ratelimitfileTest extends \PHPUnit_Framework_TestCase
{ {
public function test_ratelimitfile0 () public function test_ratelimitfile0 ()
{ {

View File

@@ -8,7 +8,7 @@
namespace Domframework\Tests; namespace Domframework\Tests;
/** 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
*/ */

View File

@@ -9,7 +9,7 @@ namespace Domframework\Tests;
/** Test the robotstxt file /** 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 ()

View File

@@ -8,7 +8,7 @@
namespace Domframework\Tests; namespace Domframework\Tests;
/** Test the route.php file */ /** Test the route.php file */
class routeTest extends PHPUnit_Framework_TestCase class routeTest extends \PHPUnit_Framework_TestCase
{ {
/// RELATIVE /// /// RELATIVE ///
/** Entry null */ /** Entry null */

View File

@@ -8,7 +8,7 @@
namespace Domframework\Tests; namespace Domframework\Tests;
/** 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 ()
{ {

View File

@@ -9,7 +9,7 @@ namespace Domframework\Tests;
/** Test the sitemap.php file /** 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 ()

View File

@@ -9,7 +9,7 @@ namespace Domframework\Tests;
/** Test the spfcheck tools /** 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 ()
{ {

View File

@@ -8,7 +8,7 @@
namespace Domframework\Tests; namespace Domframework\Tests;
/** 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 ()
{ {

View File

@@ -8,7 +8,7 @@
namespace Domframework\Tests; namespace Domframework\Tests;
/** 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 ()
{ {

View File

@@ -8,7 +8,7 @@
namespace Domframework\Tests; namespace Domframework\Tests;
/** Test the userssql.php file */ /** Test the userssql.php file */
class userssqlTest extends PHPUnit_Framework_TestCase class userssqlTest extends \PHPUnit_Framework_TestCase
{ {
public function test_clean () public function test_clean ()
{ {

View File

@@ -8,7 +8,7 @@
namespace Domframework\Tests; namespace Domframework\Tests;
/** Test the uuid.php file */ /** Test the uuid.php file */
class uuidTest extends PHPUnit_Framework_TestCase class uuidTest extends \PHPUnit_Framework_TestCase
{ {
public function test_uuid1 () public function test_uuid1 ()
{ {

View File

@@ -8,7 +8,7 @@
namespace Domframework\Tests; namespace Domframework\Tests;
/** Test the Verify */ /** Test the Verify */
class verifyTest extends PHPUnit_Framework_TestCase class verifyTest extends \PHPUnit_Framework_TestCase
{ {
/////////////// ///////////////
// DATES // // DATES //

View File

@@ -8,7 +8,7 @@
namespace Domframework\Tests; namespace Domframework\Tests;
/** Test the domframework xdiff part */ /** Test the domframework xdiff part */
class xdiffTest extends PHPUnit_Framework_TestCase class xdiffTest extends \PHPUnit_Framework_TestCase
{ {
// Declaration of $string1 and $string2 // Declaration of $string1 and $string2
// {{{ // {{{

View File

@@ -8,7 +8,7 @@
namespace Domframework\Tests; namespace Domframework\Tests;
/** 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 ()
{ {

View File

@@ -1,29 +1,45 @@
<?php <?php
/** Autoload */ /** Autoload */
spl_autoload_register(function ($class) { spl_autoload_register(function ($class) {
@include $class . '.php'; $classes = array ();
foreach (scandir ("src") as $file)
{
$fileShort = basename ($file);
if ($fileShort == "." || $fileShort == "..")
continue;
$classFile = substr ($fileShort, 0, -4);
$classes["Domframework\\".$classFile] = "src/$file";
}
if (key_exists ($class, $classes))
{
@include ($classes[$class]);
}
else
{
echo "ERROR : $class : doesnt exists in src\n";
}
}); });
define ("PHPUNIT", "ON-GOING"); define ("PHPUNIT", "ON-GOING");
file_put_contents ("Tests/dblayerooSqliteTest.php", file_put_contents ("Tests/DblayerooSqliteTest.php",
str_replace ("{ENGINE}", "sqlite", str_replace ("{ENGINE}", "sqlite",
file_get_contents ("Tests/dblayerooComplet.php"))); file_get_contents ("Tests/DblayerooComplet.php")));
file_put_contents ("Tests/dblayerooMySQLTest.php", file_put_contents ("Tests/DblayerooMySQLTest.php",
str_replace ("{ENGINE}", "mysql", str_replace ("{ENGINE}", "mysql",
file_get_contents ("Tests/dblayerooComplet.php"))); file_get_contents ("Tests/DblayerooComplet.php")));
file_put_contents ("Tests/dblayerooPostgreSQLTest.php", file_put_contents ("Tests/DblayerooPostgreSQLTest.php",
str_replace ("{ENGINE}", "pgsql", str_replace ("{ENGINE}", "pgsql",
file_get_contents ("Tests/dblayerooComplet.php"))); file_get_contents ("Tests/DblayerooComplet.php")));
file_put_contents ("Tests/dblayerSqliteTest.php", file_put_contents ("Tests/DblayerSqliteTest.php",
str_replace ("{ENGINE}", "sqlite", str_replace ("{ENGINE}", "sqlite",
file_get_contents ("Tests/dblayerComplet.php"))); file_get_contents ("Tests/DblayerComplet.php")));
file_put_contents ("Tests/dblayerMySQLTest.php", file_put_contents ("Tests/DblayerMySQLTest.php",
str_replace ("{ENGINE}", "mysql", str_replace ("{ENGINE}", "mysql",
file_get_contents ("Tests/dblayerComplet.php"))); file_get_contents ("Tests/DblayerComplet.php")));
file_put_contents ("Tests/dblayerPostgreSQLTest.php", file_put_contents ("Tests/DblayerPostgreSQLTest.php",
str_replace ("{ENGINE}", "pgsql", str_replace ("{ENGINE}", "pgsql",
file_get_contents ("Tests/dblayerComplet.php"))); file_get_contents ("Tests/DblayerComplet.php")));
// vim: syntax=on filetype=php // vim: syntax=on filetype=php

View File

@@ -18,7 +18,7 @@ namespace Domframework;
class Version class Version
{ {
const DOMFRAMEWORK_VERSION = "0.61"; const DOMFRAMEWORK_VERSION = "2.0";
static function version () static function version ()
{ {