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

View File

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

View File

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

View File

@@ -8,7 +8,7 @@
namespace Domframework\Tests;
/** Test the authentication on Sympa Service */
class authsympaTest extends PHPUnit_Framework_TestCase
class authsympaTest extends \PHPUnit_Framework_TestCase
{
public function test_connect_1 ()
{

View File

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

View File

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

View File

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

View File

@@ -9,7 +9,7 @@ namespace Domframework\Tests;
/** Test the certification Authority
*/
class certificationauthorityTest extends PHPUnit_Framework_TestCase
class certificationauthorityTest extends \PHPUnit_Framework_TestCase
{
public function test_createCA_1 ()
{

View File

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

View File

@@ -8,7 +8,7 @@
namespace Domframework\Tests;
/** Test the Conversion of format */
class convertTest extends PHPUnit_Framework_TestCase
class convertTest extends \PHPUnit_Framework_TestCase
{
public function test_convertDate1 ()
{

View File

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

View File

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

View File

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

View File

@@ -5,7 +5,7 @@
*/
/** 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
*/

View File

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

View File

@@ -1,7 +1,7 @@
<?php
/** Test the FTS */
class ftsTest extends PHPUnit_Framework_TestCase
class ftsTest extends \PHPUnit_Framework_TestCase
{
public function test_tokenizerSearch0 ()
{

View File

@@ -8,7 +8,7 @@
namespace Domframework\Tests;
/** Test the GetOpts */
class getoptsTest extends PHPUnit_Framework_TestCase
class getoptsTest extends \PHPUnit_Framework_TestCase
{
public function test_empty1 ()
{

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -9,7 +9,7 @@ namespace Domframework\Tests;
/** Test the password class
*/
class passwordTest extends PHPUnit_Framework_TestCase
class passwordTest extends \PHPUnit_Framework_TestCase
{
public function test_cryptPasswd_1 ()
{

View File

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

View File

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

View File

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

View File

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

View File

@@ -8,7 +8,7 @@
namespace Domframework\Tests;
/** Test the domframework REST part */
class restTest extends PHPUnit_Framework_TestCase
class restTest extends \PHPUnit_Framework_TestCase
{
/** No param, JSON by default
*/

View File

@@ -9,7 +9,7 @@ namespace Domframework\Tests;
/** Test the robotstxt file
*/
class robotstxtTest extends PHPUnit_Framework_TestCase
class robotstxtTest extends \PHPUnit_Framework_TestCase
{
// Empty Robots
public function test_Construct_1 ()

View File

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

View File

@@ -8,7 +8,7 @@
namespace Domframework\Tests;
/** Test the RSS */
class rssTest extends PHPUnit_Framework_TestCase
class rssTest extends \PHPUnit_Framework_TestCase
{
public function test_empty0 ()
{

View File

@@ -9,7 +9,7 @@ namespace Domframework\Tests;
/** Test the sitemap.php file
*/
class sitemapTest extends PHPUnit_Framework_TestCase
class sitemapTest extends \PHPUnit_Framework_TestCase
{
// Empty Sitemap
public function test_EmptySitemap_1 ()

View File

@@ -9,7 +9,7 @@ namespace Domframework\Tests;
/** Test the spfcheck tools
*/
class spfcheckTest extends PHPUnit_Framework_TestCase
class spfcheckTest extends \PHPUnit_Framework_TestCase
{
public function test_getRecords_NoSPF ()
{

View File

@@ -8,7 +8,7 @@
namespace Domframework\Tests;
/** Test the domframework Server-Sent Events part */
class sseTest extends PHPUnit_Framework_TestCase
class sseTest extends \PHPUnit_Framework_TestCase
{
public function test_loop_NOTDEFINED ()
{

View File

@@ -8,7 +8,7 @@
namespace Domframework\Tests;
/** Test the TCP client */
class tcpclientTest extends PHPUnit_Framework_TestCase
class tcpclientTest extends \PHPUnit_Framework_TestCase
{
public function test_GoogleIPv4 ()
{

View File

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

View File

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

View File

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

View File

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

View File

@@ -8,7 +8,7 @@
namespace Domframework\Tests;
/** Test the domframework xmppclient part */
class xmppclientTest extends PHPUnit_Framework_TestCase
class xmppclientTest extends \PHPUnit_Framework_TestCase
{
public function test_connection_BADNAME ()
{

View File

@@ -1,29 +1,45 @@
<?php
/** Autoload */
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");
file_put_contents ("Tests/dblayerooSqliteTest.php",
file_put_contents ("Tests/DblayerooSqliteTest.php",
str_replace ("{ENGINE}", "sqlite",
file_get_contents ("Tests/dblayerooComplet.php")));
file_put_contents ("Tests/dblayerooMySQLTest.php",
file_get_contents ("Tests/DblayerooComplet.php")));
file_put_contents ("Tests/DblayerooMySQLTest.php",
str_replace ("{ENGINE}", "mysql",
file_get_contents ("Tests/dblayerooComplet.php")));
file_put_contents ("Tests/dblayerooPostgreSQLTest.php",
file_get_contents ("Tests/DblayerooComplet.php")));
file_put_contents ("Tests/DblayerooPostgreSQLTest.php",
str_replace ("{ENGINE}", "pgsql",
file_get_contents ("Tests/dblayerooComplet.php")));
file_put_contents ("Tests/dblayerSqliteTest.php",
file_get_contents ("Tests/DblayerooComplet.php")));
file_put_contents ("Tests/DblayerSqliteTest.php",
str_replace ("{ENGINE}", "sqlite",
file_get_contents ("Tests/dblayerComplet.php")));
file_put_contents ("Tests/dblayerMySQLTest.php",
file_get_contents ("Tests/DblayerComplet.php")));
file_put_contents ("Tests/DblayerMySQLTest.php",
str_replace ("{ENGINE}", "mysql",
file_get_contents ("Tests/dblayerComplet.php")));
file_put_contents ("Tests/dblayerPostgreSQLTest.php",
file_get_contents ("Tests/DblayerComplet.php")));
file_put_contents ("Tests/DblayerPostgreSQLTest.php",
str_replace ("{ENGINE}", "pgsql",
file_get_contents ("Tests/dblayerComplet.php")));
file_get_contents ("Tests/DblayerComplet.php")));
// vim: syntax=on filetype=php