[Database] is now [DatabaseDriver] and manages `multiple servers`
This commit is contained in:
parent
64e3ce58ac
commit
65a1883a53
|
@ -18,6 +18,9 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Loads the build facade
|
||||||
|
require_once __BUILD__.'/Builder.php';
|
||||||
|
|
||||||
|
|
||||||
/* AUTOLOADER
|
/* AUTOLOADER
|
||||||
*
|
*
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
<?php
|
||||||
|
/**************************
|
||||||
|
* Builder *
|
||||||
|
* 05-11-16 *
|
||||||
|
***************************
|
||||||
|
* Designed & Developed by *
|
||||||
|
* xdrm-brackets *
|
||||||
|
***************************
|
||||||
|
* https://xdrm.io/ *
|
||||||
|
**************************/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class Builder{
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -1,7 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace api\core;
|
namespace api\core;
|
||||||
use \database\core\Database;
|
use \database\core\DatabaseDriver;
|
||||||
use \manager\ManagerError;
|
use \manager\ManagerError;
|
||||||
use \api\core\Checker;
|
use \api\core\Checker;
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace api\module;
|
namespace api\module;
|
||||||
use \database\core\Database;
|
use \database\core\DatabaseDriver;
|
||||||
use \manager\sessionManager;
|
use \manager\sessionManager;
|
||||||
use \api\core\ModuleRequest;
|
use \api\core\ModuleRequest;
|
||||||
use \manager\ManagerError;
|
use \manager\ManagerError;
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
namespace api\module;
|
namespace api\module;
|
||||||
use \manager\sessionManager;
|
use \manager\sessionManager;
|
||||||
use \database\core\Database;
|
use \database\core\DatabaseDriver;
|
||||||
use \manager\ManagerError;
|
use \manager\ManagerError;
|
||||||
use \api\core\ModuleRequest;
|
use \api\core\ModuleRequest;
|
||||||
use \database\core\Repo;
|
use \database\core\Repo;
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
namespace api\module;
|
namespace api\module;
|
||||||
use \manager\sessionManager;
|
use \manager\sessionManager;
|
||||||
use \database\core\Database;
|
use \database\core\DatabaseDriver;
|
||||||
use \manager\ManagerError;
|
use \manager\ManagerError;
|
||||||
use \database\core\Repo;
|
use \database\core\Repo;
|
||||||
use \lightdb\core\lightdb;
|
use \lightdb\core\lightdb;
|
||||||
|
@ -218,6 +218,7 @@
|
||||||
public static function search($params){
|
public static function search($params){
|
||||||
extract($params);
|
extract($params);
|
||||||
|
|
||||||
|
|
||||||
// Contiendra les sujets
|
// Contiendra les sujets
|
||||||
$subjects = [];
|
$subjects = [];
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace api\module;
|
namespace api\module;
|
||||||
use \database\core\Database;
|
use \database\core\DatabaseDriver;
|
||||||
use \api\core\Checker;
|
use \api\core\Checker;
|
||||||
use \manager\sessionManager;
|
use \manager\sessionManager;
|
||||||
use \manager\ManagerError;
|
use \manager\ManagerError;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace api\module;
|
namespace api\module;
|
||||||
use \database\core\Database;
|
use \database\core\DatabaseDriver;
|
||||||
use \manager\sessionManager;
|
use \manager\sessionManager;
|
||||||
use \api\core\ModuleRequest;
|
use \api\core\ModuleRequest;
|
||||||
use \manager\ManagerError;
|
use \manager\ManagerError;
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
namespace api\module;
|
namespace api\module;
|
||||||
use \manager\sessionManager;
|
use \manager\sessionManager;
|
||||||
use \database\core\Database;
|
use \database\core\DatabaseDriver;
|
||||||
use \manager\ManagerError;
|
use \manager\ManagerError;
|
||||||
use \database\core\Repo;
|
use \database\core\Repo;
|
||||||
|
|
||||||
|
|
|
@ -4,81 +4,165 @@
|
||||||
use \manager\ManagerError;
|
use \manager\ManagerError;
|
||||||
|
|
||||||
|
|
||||||
class DataBase{
|
class DataBaseDriver{
|
||||||
|
|
||||||
/* ATTRIBUTS STATIQUES */
|
/* STATIC ATTRIBUTES */
|
||||||
public static function config_path(){
|
public static function default_path(){
|
||||||
return [
|
return [
|
||||||
'local' => __CONFIG__.'/database-local.json',
|
'local' => __CONFIG__.'/database-local.json',
|
||||||
'remote' => __CONFIG__.'/database.json'
|
'remote' => __CONFIG__.'/database.json'
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
private static $pdo;
|
|
||||||
private static $instance;
|
|
||||||
|
|
||||||
|
private static $path; // Databases configurations files
|
||||||
|
private static $config; // PDO configurations
|
||||||
|
private static $instance = []; // Database driver instance list
|
||||||
|
|
||||||
/* ATTRIBUTS */
|
public $error;
|
||||||
|
|
||||||
|
/* ATTRIBUTES */
|
||||||
private $host;
|
private $host;
|
||||||
private $dbname;
|
private $dbname;
|
||||||
private $username;
|
private $username;
|
||||||
private $password;
|
private $password;
|
||||||
|
private $pdo;
|
||||||
public static $error;
|
|
||||||
|
|
||||||
|
|
||||||
public function __construct($host, $dbname, $username, $password){
|
|
||||||
|
/* CONSTRUCTOR OF A DATABASE DRIVER
|
||||||
|
*
|
||||||
|
* @host<String> Database Server's host
|
||||||
|
* @dbname<String> Database name
|
||||||
|
* @username<String> Database username
|
||||||
|
* @password<String> Database password
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private function __construct($host, $dbname, $username, $password){
|
||||||
|
/* (2) Stores configuration */
|
||||||
$this->host = $host;
|
$this->host = $host;
|
||||||
$this->dbname = $dbname;
|
$this->dbname = $dbname;
|
||||||
$this->username = $username;
|
$this->username = $username;
|
||||||
$this->password = $password;
|
$this->password = $password;
|
||||||
|
|
||||||
try{
|
try{
|
||||||
self::$pdo = new \PDO('mysql:host='.$this->host.';dbname='.$this->dbname, $this->username, $this->password);
|
|
||||||
|
$this->pdo = new \PDO('mysql:host='.$this->host.';dbname='.$this->dbname, $this->username, $this->password);
|
||||||
|
|
||||||
// On signale que tout s'est bien passe
|
// On signale que tout s'est bien passe
|
||||||
self::$error = ManagerError::Success;
|
$this->error = ManagerError::Success;
|
||||||
|
|
||||||
}catch(Exception $e){
|
}catch(Exception $e){
|
||||||
// On signale qu'il y a une erreur
|
// On signale qu'il y a une erreur
|
||||||
self::$error = ManagerError::PDOConnection;
|
$this->error = ManagerError::PDOConnection;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* retourne une instance de la classe */
|
|
||||||
public static function getInstance(){
|
|
||||||
if( self::$instance == null || self::$error != ManagerError::Success ){ // Si aucune instance existante OU erreur de connection
|
|
||||||
|
|
||||||
// chargement de la configuration du server SQL
|
/************************************************
|
||||||
|
**** Multiton Management (static) ****
|
||||||
|
************************************************/
|
||||||
|
|
||||||
|
/* ADDS A NEW CONNECTION
|
||||||
|
*
|
||||||
|
* @label<String> [optional] Database Label
|
||||||
|
* @local<String> [optional] Local configuration path
|
||||||
|
* @remote<String> [optional] Remote configuration path
|
||||||
|
*
|
||||||
|
* @return status<Boolean> If added successfully
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public static function add($label=null, $local=null, $remote=null){
|
||||||
|
/* [1] Default values
|
||||||
|
=========================================================*/
|
||||||
|
/* (1) If label isn't given */
|
||||||
|
is_null($label) && ($label = 'default');
|
||||||
|
|
||||||
|
/* (2) If label and no path */
|
||||||
|
if( $label !== 'default' && (is_null($local) || is_null($remote)) )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
|
||||||
|
/* [2] Stores paths
|
||||||
|
=========================================================*/
|
||||||
|
/* (1) If not default, stores new values */
|
||||||
|
if( $label !== 'default' )
|
||||||
|
self::$path[$label] = [ 'local' => $local, 'remote' => $remote ];
|
||||||
|
/* (2) If default, fetch default path */
|
||||||
|
else
|
||||||
|
self::$path[$label] = self::default_path();
|
||||||
|
|
||||||
|
|
||||||
|
/* [3] Test configuration paths
|
||||||
|
=========================================================*/
|
||||||
|
/* (1) If paths aren't files */
|
||||||
|
if( !is_file(self::$path[$label]['local']) || !is_file(self::$path[$label]['remote']) )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
/* (2) If paths aren't JSON */
|
||||||
|
$jLocal = json_decode( file_get_contents(self::$path[$label]['local']), true );
|
||||||
|
$jRemote = json_decode( file_get_contents(self::$path[$label]['remote']), true );
|
||||||
|
|
||||||
|
if( !is_array($jLocal) || !is_array($jRemote) )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
|
||||||
|
/* [4] Instanciates the driver
|
||||||
|
=========================================================*/
|
||||||
|
try{
|
||||||
|
|
||||||
|
/* (1) If local -> instanciates with local configuration */
|
||||||
if( !checkdnsrr($_SERVER['SERVER_NAME'], 'NS') )
|
if( !checkdnsrr($_SERVER['SERVER_NAME'], 'NS') )
|
||||||
$conf = json_decode( file_get_contents(self::config_path()['local']), true );
|
self::$instance[$label] = new DatabaseDriver($jLocal['host'], $jLocal['dbname'], $jLocal['user'], $jLocal['password']);
|
||||||
|
/* (2) If Remote -> instanciates with Remote configuration */
|
||||||
else
|
else
|
||||||
$conf = json_decode( file_get_contents(self::config_path()['remote']), true );
|
self::$instance[$label] = new DatabaseDriver($jRemote['host'], $jRemote['dbname'], $jRemote['user'], $jRemote['password']);
|
||||||
|
|
||||||
// creation de l'instance en fonction des parametres
|
return true;
|
||||||
self::$instance = new DataBase($conf['host'], $conf['dbname'], $conf['user'], $conf['password']);
|
|
||||||
|
}catch(\Exception $e){
|
||||||
|
|
||||||
|
/* (3) If fails */
|
||||||
|
return false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return self::$instance;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* GET A DATABASE DRIVER INSTANCE
|
||||||
|
*
|
||||||
|
* @label<String> [optional] Driver's label
|
||||||
|
*
|
||||||
|
* @return driver<Database> Multiton
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public static function get($label=null){
|
||||||
|
/* [1] Checks arguments
|
||||||
|
=========================================================*/
|
||||||
|
/* (1) Label default value */
|
||||||
|
is_null($label) && ($label = 'default');
|
||||||
|
|
||||||
|
/* (2) If no label, or unknown label */
|
||||||
|
if( is_null($label) || !isset(self::$instance[$label]) )
|
||||||
|
throw new \Exception('Database @label is incorrect.');
|
||||||
|
|
||||||
|
|
||||||
|
/* [2] Returns instance
|
||||||
|
=========================================================*/
|
||||||
|
return self::$instance[$label];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* retourne la connection statique */
|
/* retourne la connection statique */
|
||||||
public static function getPDO(){
|
public static function getPDO($label=null){
|
||||||
$instance = self::getInstance();
|
$instance = self::get($label);
|
||||||
|
|
||||||
return self::$pdo;
|
return $instance->pdo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function getConfig(){
|
public function getConfig(){
|
||||||
return [
|
return [
|
||||||
'host' => $this->host,
|
'host' => $this->host,
|
|
@ -1,7 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace database\repo;
|
namespace database\repo;
|
||||||
use \database\core\Database;
|
use \database\core\DatabaseDriver;
|
||||||
|
|
||||||
class parentRepo{
|
class parentRepo{
|
||||||
|
|
||||||
|
@ -30,8 +30,8 @@
|
||||||
|
|
||||||
/* [2] On charge la liste des colonnes de la table
|
/* [2] On charge la liste des colonnes de la table
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
$getColumns = Database::getPDO()->query('SHOW COLUMNS FROM '.static::table_name());
|
$getColumns = DatabaseDriver::getPDO()->query('SHOW COLUMNS FROM '.static::table_name());
|
||||||
$cols = Database::delNumeric( $getColumns->fetchAll() );
|
$cols = DatabaseDriver::delNumeric( $getColumns->fetchAll() );
|
||||||
|
|
||||||
$table_columns = [
|
$table_columns = [
|
||||||
'_PRIMARY_' => [] // Contiendra les champs de la clé primaire
|
'_PRIMARY_' => [] // Contiendra les champs de la clé primaire
|
||||||
|
@ -84,7 +84,7 @@
|
||||||
$getRequestString .= ' ORDER BY 1 ASC';
|
$getRequestString .= ' ORDER BY 1 ASC';
|
||||||
|
|
||||||
// On prépare la requête
|
// On prépare la requête
|
||||||
$getRequest = Database::getPDO()->prepare($getRequestString);
|
$getRequest = DatabaseDriver::getPDO()->prepare($getRequestString);
|
||||||
|
|
||||||
|
|
||||||
/* [5] On exécute la requête
|
/* [5] On exécute la requête
|
||||||
|
@ -107,7 +107,7 @@
|
||||||
|
|
||||||
/* [6] On récupère le résultat
|
/* [6] On récupère le résultat
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
return Database::delNumeric( $getRequest->fetchAll() );
|
return DatabaseDriver::delNumeric( $getRequest->fetchAll() );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
namespace database\repo;
|
namespace database\repo;
|
||||||
use \manager\sessionManager;
|
use \manager\sessionManager;
|
||||||
use \database\core\Database;
|
use \database\core\DatabaseDriver;
|
||||||
use \api\core\Checker;
|
use \api\core\Checker;
|
||||||
|
|
||||||
class token extends parentRepo{
|
class token extends parentRepo{
|
||||||
|
@ -38,14 +38,14 @@
|
||||||
public static function getAll(){
|
public static function getAll(){
|
||||||
/* [1] On prepare et execute la requete
|
/* [1] On prepare et execute la requete
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
$request = Database::getPDO()->query("SELECT id_token, name, token, expires, (CURDATE() > expires) as expired
|
$request = DatabaseDriver::getPDO()->query("SELECT id_token, name, token, expires, (CURDATE() > expires) as expired
|
||||||
FROM api_token
|
FROM api_token
|
||||||
ORDER BY expires DESC");
|
ORDER BY expires DESC");
|
||||||
|
|
||||||
|
|
||||||
/* [3] On retourne les donnees
|
/* [3] On retourne les donnees
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
return Database::delNumeric( $request->fetchAll() );
|
return DatabaseDriver::delNumeric( $request->fetchAll() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -66,7 +66,7 @@
|
||||||
|
|
||||||
/* [1] Verification dans la base de donnees
|
/* [1] Verification dans la base de donnees
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
$check = Database::getPDO()->prepare("SELECT id_token, permission
|
$check = DatabaseDriver::getPDO()->prepare("SELECT id_token, permission
|
||||||
FROM api_token
|
FROM api_token
|
||||||
WHERE CURDATE() <= expires
|
WHERE CURDATE() <= expires
|
||||||
AND token = :token");
|
AND token = :token");
|
||||||
|
@ -112,7 +112,7 @@
|
||||||
$token = sessionManager::sha1(uniqid());
|
$token = sessionManager::sha1(uniqid());
|
||||||
|
|
||||||
// Verification dans la BDD
|
// Verification dans la BDD
|
||||||
$check = Database::getPDO()->prepare("SELECT id_token FROM api_token WHERE token = :token");
|
$check = DatabaseDriver::getPDO()->prepare("SELECT id_token FROM api_token WHERE token = :token");
|
||||||
$check->execute( array( ':token' => $token ) );
|
$check->execute( array( ':token' => $token ) );
|
||||||
|
|
||||||
// VRAI un token est identique
|
// VRAI un token est identique
|
||||||
|
@ -122,7 +122,7 @@
|
||||||
|
|
||||||
/* [2] On cree le token
|
/* [2] On cree le token
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
$create = Database::getPDO()->prepare("INSERT INTO api_token(id_token, token, name, expires)
|
$create = DatabaseDriver::getPDO()->prepare("INSERT INTO api_token(id_token, token, name, expires)
|
||||||
VALUES(DEFAULT, :token, :name, :expiration)");
|
VALUES(DEFAULT, :token, :name, :expiration)");
|
||||||
$create->execute(array(
|
$create->execute(array(
|
||||||
':token' => $token,
|
':token' => $token,
|
||||||
|
@ -132,7 +132,7 @@
|
||||||
|
|
||||||
/* [3] On verifie qu'il a bien ete cree
|
/* [3] On verifie qu'il a bien ete cree
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
$created = Database::getPDO()->prepare("SELECT id_token FROM api_token
|
$created = DatabaseDriver::getPDO()->prepare("SELECT id_token FROM api_token
|
||||||
WHERE token = :token
|
WHERE token = :token
|
||||||
AND name = :name");
|
AND name = :name");
|
||||||
$created->execute(array(
|
$created->execute(array(
|
||||||
|
@ -175,7 +175,7 @@
|
||||||
|
|
||||||
/* [2] Suppression du token
|
/* [2] Suppression du token
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
$remove = Database::getPDO()->prepare("DELETE FROM api_token
|
$remove = DatabaseDriver::getPDO()->prepare("DELETE FROM api_token
|
||||||
WHERE id_token = :id_token");
|
WHERE id_token = :id_token");
|
||||||
$remove->execute(array( ':id_token' => $id_token ));
|
$remove->execute(array( ':id_token' => $id_token ));
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace database\repo;
|
namespace database\repo;
|
||||||
use \database\core\Database;
|
use \database\core\DatabaseDriver;
|
||||||
use \api\core\Checker;
|
use \api\core\Checker;
|
||||||
use \manager\sessionManager;
|
use \manager\sessionManager;
|
||||||
use \database\repo\parentRepo;
|
use \database\repo\parentRepo;
|
||||||
|
@ -32,7 +32,7 @@
|
||||||
|
|
||||||
/* [1] On verifie son login/password dans la BDD
|
/* [1] On verifie son login/password dans la BDD
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
$check = Database::getPDO()->prepare("SELECT id_user, login
|
$check = DatabaseDriver::getPDO()->prepare("SELECT id_user, login
|
||||||
FROM users
|
FROM users
|
||||||
WHERE ( login = :username OR mail = :mail ) AND password = :password");
|
WHERE ( login = :username OR mail = :mail ) AND password = :password");
|
||||||
$check->execute(array(
|
$check->execute(array(
|
||||||
|
@ -49,7 +49,7 @@
|
||||||
|
|
||||||
|
|
||||||
// On retourne le resultat
|
// On retourne le resultat
|
||||||
return Database::delNumeric( $result );
|
return DatabaseDriver::delNumeric( $result );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -79,7 +79,7 @@
|
||||||
|
|
||||||
/* [1] On verifie que le login/mail et reference sont uniques
|
/* [1] On verifie que le login/mail et reference sont uniques
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
$checkUnique = Database::getPDO()->prepare("SELECT id_user
|
$checkUnique = DatabaseDriver::getPDO()->prepare("SELECT id_user
|
||||||
FROM users
|
FROM users
|
||||||
WHERE login = :login
|
WHERE login = :login
|
||||||
OR mail = :mail ");
|
OR mail = :mail ");
|
||||||
|
@ -94,7 +94,7 @@
|
||||||
|
|
||||||
/* [2] Creation de l'utilisateur
|
/* [2] Creation de l'utilisateur
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
$create = Database::getPDO()->prepare("INSERT INTO users(id_user, login, password, mail)
|
$create = DatabaseDriver::getPDO()->prepare("INSERT INTO users(id_user, login, password, mail)
|
||||||
VALUES(DEFAULT, :login, :password, :mail)");
|
VALUES(DEFAULT, :login, :password, :mail)");
|
||||||
$create->execute(array(
|
$create->execute(array(
|
||||||
':login' => $login,
|
':login' => $login,
|
||||||
|
@ -104,7 +104,7 @@
|
||||||
|
|
||||||
/* [3] Verification de la creation + recuperation id
|
/* [3] Verification de la creation + recuperation id
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
$checkCreate = Database::getPDO()->prepare("SELECT id_user
|
$checkCreate = DatabaseDriver::getPDO()->prepare("SELECT id_user
|
||||||
FROM users
|
FROM users
|
||||||
WHERE login = :login
|
WHERE login = :login
|
||||||
AND password = :password
|
AND password = :password
|
||||||
|
@ -142,7 +142,7 @@
|
||||||
public static function remove($id_user){
|
public static function remove($id_user){
|
||||||
/* [1] On effectue la suppression
|
/* [1] On effectue la suppression
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
$getUser = Database::getPDO()->prepare("DELETE FROM users WHERE id_user = :id_user");
|
$getUser = DatabaseDriver::getPDO()->prepare("DELETE FROM users WHERE id_user = :id_user");
|
||||||
$getUser->execute(array( ':id_user' => $id_user ));
|
$getUser->execute(array( ':id_user' => $id_user ));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
namespace orm\core;
|
namespace orm\core;
|
||||||
|
|
||||||
use \database\core\Database;
|
use \database\core\DatabaseDriver;
|
||||||
use \orm\core\SQLBuilder;
|
use \orm\core\SQLBuilder;
|
||||||
|
|
||||||
|
|
||||||
|
@ -511,7 +511,7 @@
|
||||||
$requestString = SQLBuilder::BUILD($requestS).';';
|
$requestString = SQLBuilder::BUILD($requestS).';';
|
||||||
|
|
||||||
/* (2) On prépare la requête */
|
/* (2) On prépare la requête */
|
||||||
$request = Database::getPDO()->prepare($requestString);
|
$request = DatabaseDriver::getPDO()->prepare($requestString);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -636,7 +636,7 @@
|
||||||
/* [2] On bind les paramètres et exécute la requête
|
/* [2] On bind les paramètres et exécute la requête
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
/* (0) On initialise la requête et les paramètres */
|
/* (0) On initialise la requête et les paramètres */
|
||||||
$request = Database::getPDO()->prepare($requestS.';');
|
$request = DatabaseDriver::getPDO()->prepare($requestS.';');
|
||||||
$bound = [];
|
$bound = [];
|
||||||
|
|
||||||
/* (1) On bind les paramètres */
|
/* (1) On bind les paramètres */
|
||||||
|
@ -728,7 +728,7 @@
|
||||||
$requestString = SQLBuilder::BUILD($requestS).';';
|
$requestString = SQLBuilder::BUILD($requestS).';';
|
||||||
|
|
||||||
/* (2) On prépare la requête */
|
/* (2) On prépare la requête */
|
||||||
$request = Database::getPDO()->prepare($requestString);
|
$request = DatabaseDriver::getPDO()->prepare($requestString);
|
||||||
|
|
||||||
/* [5] On exécute la requête et retourne le résultat
|
/* [5] On exécute la requête et retourne le résultat
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
|
@ -893,7 +893,7 @@
|
||||||
$requestString = SQLBuilder::BUILD($requestS).';';
|
$requestString = SQLBuilder::BUILD($requestS).';';
|
||||||
|
|
||||||
/* (3) On prépare la requête */
|
/* (3) On prépare la requête */
|
||||||
$request = Database::getPDO()->prepare($requestString);
|
$request = DatabaseDriver::getPDO()->prepare($requestString);
|
||||||
// var_dump($requestString);
|
// var_dump($requestString);
|
||||||
|
|
||||||
/* [8] On exécute la requête et retourne le résultat
|
/* [8] On exécute la requête et retourne le résultat
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
namespace orm\core;
|
namespace orm\core;
|
||||||
|
|
||||||
use \database\core\Database;
|
use \database\core\DatabaseDriver;
|
||||||
use \orm\core\Rows;
|
use \orm\core\Rows;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
namespace orm\core;
|
namespace orm\core;
|
||||||
|
|
||||||
use \database\core\Database;
|
use \database\core\DatabaseDriver;
|
||||||
use \manager\ManagerError;
|
use \manager\ManagerError;
|
||||||
use \orm\core\Rows;
|
use \orm\core\Rows;
|
||||||
|
|
||||||
|
@ -34,8 +34,8 @@
|
||||||
/* [1] On vérifie que la table existe
|
/* [1] On vérifie que la table existe
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
/* (1) Requête */
|
/* (1) Requête */
|
||||||
$checkTable = Database::getPDO()->query("SHOW tables FROM ".self::$database);
|
$checkTable = DatabaseDriver::getPDO()->query("SHOW tables FROM ".self::$database);
|
||||||
$checkTableResult = Database::delNumeric( $checkTable->fetchAll() );
|
$checkTableResult = DatabaseDriver::delNumeric( $checkTable->fetchAll() );
|
||||||
|
|
||||||
/* (2) On met en forme les données */
|
/* (2) On met en forme les données */
|
||||||
$tables = [];
|
$tables = [];
|
||||||
|
@ -54,8 +54,8 @@
|
||||||
/* [2] Si la table existe, on récupère les colonnes
|
/* [2] Si la table existe, on récupère les colonnes
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
/* (1) On récupère les colonnes */
|
/* (1) On récupère les colonnes */
|
||||||
$getColumns = Database::getPDO()->query("SHOW columns FROM ".self::$database.'.'.$table_name);
|
$getColumns = DatabaseDriver::getPDO()->query("SHOW columns FROM ".self::$database.'.'.$table_name);
|
||||||
$columnsResult = Database::delNumeric( $getColumns->fetchAll() );
|
$columnsResult = DatabaseDriver::delNumeric( $getColumns->fetchAll() );
|
||||||
|
|
||||||
/* (2) On met en forme les données */
|
/* (2) On met en forme les données */
|
||||||
$columns = [];
|
$columns = [];
|
||||||
|
@ -85,7 +85,7 @@
|
||||||
/* [3] On récupère les clés étrangères
|
/* [3] On récupère les clés étrangères
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
/* (1) On récupère le texte du 'CREATE TABLE' */
|
/* (1) On récupère le texte du 'CREATE TABLE' */
|
||||||
$getCreateTable = Database::getPDO()->query("show create table ".$table_name);
|
$getCreateTable = DatabaseDriver::getPDO()->query("show create table ".$table_name);
|
||||||
if( is_bool($getCreateTable) )
|
if( is_bool($getCreateTable) )
|
||||||
throw new \Exception('[*] Cannot fetch constrains');
|
throw new \Exception('[*] Cannot fetch constrains');
|
||||||
$create_table = $getCreateTable->fetch()['Create Table'];
|
$create_table = $getCreateTable->fetch()['Create Table'];
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"host" : "shadowx-dev.com",
|
||||||
|
"dbname" : "cnrs",
|
||||||
|
"user" : "cnrs",
|
||||||
|
"password" : "yEHsPxCurd7RsynE"
|
||||||
|
}
|
|
@ -6,7 +6,7 @@
|
||||||
use \api\core\ModuleRequest;
|
use \api\core\ModuleRequest;
|
||||||
use \api\core\ModuleResponse;
|
use \api\core\ModuleResponse;
|
||||||
use \manager\ManagerError;
|
use \manager\ManagerError;
|
||||||
use \database\core\Database;
|
use \database\core\DatabaseDriver;
|
||||||
use \api\core\Checker;
|
use \api\core\Checker;
|
||||||
use \manager\MenuManager;
|
use \manager\MenuManager;
|
||||||
|
|
||||||
|
@ -22,19 +22,22 @@
|
||||||
|
|
||||||
define('__REDIRECT__', 'Location: /dashboard/');
|
define('__REDIRECT__', 'Location: /dashboard/');
|
||||||
|
|
||||||
|
/* [1] Set databases
|
||||||
/* [x] Gestion des utilisateurs
|
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
/* (1) Valeurs par defaut */
|
DatabaseDriver::add();
|
||||||
|
DatabaseDriver::add('lab-surveys', __CONFIG__.'/database-lab-surveys.json', __CONFIG__.'/database-lab-surveys.json');
|
||||||
|
|
||||||
|
|
||||||
|
/* [2] Identity Management
|
||||||
|
=========================================================*/
|
||||||
|
/* (1) Session initialization */
|
||||||
if( !isset($_SESSION['userid']) ) $_SESSION['userid'] = null;
|
if( !isset($_SESSION['userid']) ) $_SESSION['userid'] = null;
|
||||||
if( !isset($_SESSION['username']) ) $_SESSION['username'] = null;
|
if( !isset($_SESSION['username']) ) $_SESSION['username'] = null;
|
||||||
if( !isset($_SESSION['permission']) ) $_SESSION['permission'] = [];
|
if( !isset($_SESSION['permission']) ) $_SESSION['permission'] = [];
|
||||||
|
|
||||||
|
|
||||||
/* (2) Gestion de la connection */
|
/* (2) Sign-In management */
|
||||||
$login_vars = isset($_POST['login-sub']);
|
$login_vars = isset($_POST['login-sub']) && isset($_POST['login']) && isset($_POST['password']);
|
||||||
$login_vars = $login_vars && isset($_POST['login']);
|
|
||||||
$login_vars = $login_vars && isset($_POST['password']);
|
|
||||||
|
|
||||||
// Status de login
|
// Status de login
|
||||||
$_SESSION['login_status'] = 'no';
|
$_SESSION['login_status'] = 'no';
|
||||||
|
@ -50,16 +53,11 @@
|
||||||
$_SESSION['login_status'] = 'logged';
|
$_SESSION['login_status'] = 'logged';
|
||||||
|
|
||||||
// Si on n'a pas les bonnes donnees
|
// Si on n'a pas les bonnes donnees
|
||||||
else
|
else
|
||||||
$_SESSION['login_status'] = 'error';
|
$_SESSION['login_status'] = 'error';
|
||||||
}
|
}
|
||||||
|
|
||||||
// var_dump($login_vars);
|
/* (3) Log-Out management */
|
||||||
// var_dump($_SESSION);
|
|
||||||
// exit();
|
|
||||||
|
|
||||||
|
|
||||||
/* (3) Gestion de le deconnexion */
|
|
||||||
$logout_vars = isset($_POST['logout-sub']);
|
$logout_vars = isset($_POST['logout-sub']);
|
||||||
|
|
||||||
// Si on se deconnecte
|
// Si on se deconnecte
|
||||||
|
@ -78,13 +76,13 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* [0] On initialise le routeur
|
/* [3] On initialise le routeur
|
||||||
===================================================*/
|
===================================================*/
|
||||||
|
/* (1) New Router */
|
||||||
$R = new Router( $_GET['url'] );
|
$R = new Router( $_GET['url'] );
|
||||||
|
|
||||||
|
|
||||||
/* (2) Gestion des SVG avec couleur modifiée */
|
/* (2) path/to/resource/filename@0hexa0.svg -> update svg content */
|
||||||
// path/to/resource/filename@HEXADE.svg
|
|
||||||
$R->get('(.+)@([a-f0-9]{6})(\.svg)', function($matches){
|
$R->get('(.+)@([a-f0-9]{6})(\.svg)', function($matches){
|
||||||
$path = __PUBLIC__.'/'.$matches[0].$matches[2];
|
$path = __PUBLIC__.'/'.$matches[0].$matches[2];
|
||||||
|
|
||||||
|
@ -108,25 +106,23 @@
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
/* [1] On cree les regles de routage
|
/* [4] / -> homepage
|
||||||
===================================================*/
|
===================================================*/
|
||||||
// Racine -> page d'accueil
|
// Racine -> page d'accueil
|
||||||
$R->get('/?', function(){ header(__REDIRECT__); });
|
$R->get('/?', function(){ header(__REDIRECT__); });
|
||||||
|
|
||||||
|
|
||||||
/* [2] On recupere la liste des pages du site
|
/* [5] Manage websites pages
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
$temporaryMenuInflater = new MenuManager();
|
$temporaryMenuInflater = new MenuManager();
|
||||||
$views = $temporaryMenuInflater->getCategories();
|
$views = $temporaryMenuInflater->getCategories();
|
||||||
|
|
||||||
|
// pagename/arg1/arg2 -> include view
|
||||||
// nomPage/arg1/arg2 -> inclusion de la page
|
|
||||||
$R->get('(?:'.implode('|', $views).')(?:/[\w-]+)*/?', function(){ include __PUBLIC__.'/view.php'; });
|
$R->get('(?:'.implode('|', $views).')(?:/[\w-]+)*/?', function(){ include __PUBLIC__.'/view.php'; });
|
||||||
|
|
||||||
|
|
||||||
|
/* [6] host.xxx/api/{module}/{method} -> api
|
||||||
|
=========================================================*/
|
||||||
// Api
|
|
||||||
$R->post('api(?:/(.*))?', function($url){
|
$R->post('api(?:/(.*))?', function($url){
|
||||||
$request = ModuleRequest::fromPost($url, $_POST);
|
$request = ModuleRequest::fromPost($url, $_POST);
|
||||||
$answer = $request->dispatch();
|
$answer = $request->dispatch();
|
||||||
|
@ -138,14 +134,13 @@
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
// N'importe -> page d'accueil
|
/* [7] Any other URL -> homepage
|
||||||
$R->get('.+', function(){ header(__REDIRECT__); });
|
=========================================================*/
|
||||||
|
$R->get('.+', function(){ header(__REDIRECT__); });
|
||||||
$R->post('.+', function(){ header(__REDIRECT__); });
|
$R->post('.+', function(){ header(__REDIRECT__); });
|
||||||
|
|
||||||
|
|
||||||
|
/* [8] Launch Router
|
||||||
|
|
||||||
/* [3] On lance le routeur
|
|
||||||
===================================================*/
|
===================================================*/
|
||||||
$R->run();
|
$R->run();
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
use \database\core\Repo;
|
use \database\core\Repo;
|
||||||
use \api\core\ModuleRequest;
|
use \api\core\ModuleRequest;
|
||||||
use \manager\ManagerError;
|
use \manager\ManagerError;
|
||||||
use \database\core\Database;
|
use \database\core\DatabaseDriver;
|
||||||
|
|
||||||
debug();
|
debug();
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ if( permission('admin') ){
|
||||||
|
|
||||||
echo "<div>";
|
echo "<div>";
|
||||||
echo "<span>".$token['name']."</span>";
|
echo "<span>".$token['name']."</span>";
|
||||||
echo "<span data-prefix='Expiration'>".Database::frDate($token['expires'])."</span>";
|
echo "<span data-prefix='Expiration'>".DatabaseDriver::frDate($token['expires'])."</span>";
|
||||||
echo "</div><div>";
|
echo "</div><div>";
|
||||||
echo "<span><span class='flag'>".$token['token']."</span></span>";
|
echo "<span><span class='flag'>".$token['token']."</span></span>";
|
||||||
echo "</div>";
|
echo "</div>";
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
use \manager\sessionManager;
|
use \manager\sessionManager;
|
||||||
use \manager\ManagerError;
|
use \manager\ManagerError;
|
||||||
use \database\core\Repo;
|
use \database\core\Repo;
|
||||||
use \database\core\Database;
|
use \database\core\DatabaseDriver;
|
||||||
use \lightdb\core\lightdb;
|
use \lightdb\core\lightdb;
|
||||||
|
|
||||||
use \api\client;
|
use \api\client;
|
||||||
|
|
|
@ -5,17 +5,17 @@
|
||||||
/* [1] Verification du chargement de la config
|
/* [1] Verification du chargement de la config
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
public function testGetInstanceWithNoSERVER(){
|
public function testGetInstanceWithNoSERVER(){
|
||||||
$instance = \database\core\Database::getInstance();
|
$instance = \database\core\DatabaseDriver::getInstance();
|
||||||
|
|
||||||
$this->assertEquals( 'localhost', $instance->getConfig()['host'] );
|
$this->assertEquals( 'localhost', $instance->getConfig()['host'] );
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetInstanceWithSERVERLocal(){
|
public function testGetInstanceWithSERVERLocal(){
|
||||||
// Pour regenerer une instance, on definit une erreur
|
// Pour regenerer une instance, on definit une erreur
|
||||||
\database\core\Database::$error = \manager\ManagerError::PDOConnection;
|
\database\core\DatabaseDriver::$error = \manager\ManagerError::PDOConnection;
|
||||||
|
|
||||||
|
|
||||||
$instance = \database\core\Database::getInstance();
|
$instance = \database\core\DatabaseDriver::getInstance();
|
||||||
|
|
||||||
$this->assertEquals( 'localhost', $instance->getConfig()['host'] );
|
$this->assertEquals( 'localhost', $instance->getConfig()['host'] );
|
||||||
}
|
}
|
||||||
|
@ -25,20 +25,20 @@
|
||||||
/* [2] Verification du singleton (getInstance)
|
/* [2] Verification du singleton (getInstance)
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
public function testInstancePersistence(){
|
public function testInstancePersistence(){
|
||||||
\database\core\Database::$error = \manager\ManagerError::PDOConnection;
|
\database\core\DatabaseDriver::$error = \manager\ManagerError::PDOConnection;
|
||||||
|
|
||||||
$instance_construct = \database\core\Database::getInstance();
|
$instance_construct = \database\core\DatabaseDriver::getInstance();
|
||||||
$instance_nextuse = \database\core\Database::getInstance();
|
$instance_nextuse = \database\core\DatabaseDriver::getInstance();
|
||||||
|
|
||||||
$this->assertSame( $instance_construct, $instance_nextuse );
|
$this->assertSame( $instance_construct, $instance_nextuse );
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testInstancePersistenceRefutation(){
|
public function testInstancePersistenceRefutation(){
|
||||||
\database\core\Database::$error = \manager\ManagerError::PDOConnection;
|
\database\core\DatabaseDriver::$error = \manager\ManagerError::PDOConnection;
|
||||||
$instance_construct = \database\core\Database::getInstance();
|
$instance_construct = \database\core\DatabaseDriver::getInstance();
|
||||||
|
|
||||||
\database\core\Database::$error = \manager\ManagerError::PDOConnection;
|
\database\core\DatabaseDriver::$error = \manager\ManagerError::PDOConnection;
|
||||||
$instance_nextuse = \database\core\Database::getInstance();
|
$instance_nextuse = \database\core\DatabaseDriver::getInstance();
|
||||||
|
|
||||||
$this->assertNotSame( $instance_construct, $instance_nextuse );
|
$this->assertNotSame( $instance_construct, $instance_nextuse );
|
||||||
}
|
}
|
||||||
|
@ -48,7 +48,7 @@
|
||||||
/* [3] Verification de l'objet PDO
|
/* [3] Verification de l'objet PDO
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
public function testPDO(){
|
public function testPDO(){
|
||||||
$pdo = \database\core\Database::getPDO();
|
$pdo = \database\core\DatabaseDriver::getPDO();
|
||||||
|
|
||||||
$this->assertGreaterThan( 0, count($pdo->query('SELECT * FROM users')->fetchAll()), '[!] Aucun utilisateur trouve.');
|
$this->assertGreaterThan( 0, count($pdo->query('SELECT * FROM users')->fetchAll()), '[!] Aucun utilisateur trouve.');
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,11 +5,11 @@
|
||||||
/* [0] Verification du type
|
/* [0] Verification du type
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
public function testTypeInt(){
|
public function testTypeInt(){
|
||||||
$this->assertEquals( [], \database\core\Database::delNumeric(10) );
|
$this->assertEquals( [], \database\core\DatabaseDriver::delNumeric(10) );
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testTypeString(){
|
public function testTypeString(){
|
||||||
$this->assertEquals( [], \database\core\Database::delNumeric('notarray') );
|
$this->assertEquals( [], \database\core\DatabaseDriver::delNumeric('notarray') );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* [1] Verification pour 2 dimensions
|
/* [1] Verification pour 2 dimensions
|
||||||
|
@ -23,7 +23,7 @@
|
||||||
1 => 'Jean Dupont',
|
1 => 'Jean Dupont',
|
||||||
));
|
));
|
||||||
|
|
||||||
$computed_array = \database\core\Database::delNumeric( $fetchData );
|
$computed_array = \database\core\DatabaseDriver::delNumeric( $fetchData );
|
||||||
|
|
||||||
$this->assertArrayHasKey( 'id', $computed_array[0] );
|
$this->assertArrayHasKey( 'id', $computed_array[0] );
|
||||||
$this->assertArrayHasKey( 'nom', $computed_array[0] );
|
$this->assertArrayHasKey( 'nom', $computed_array[0] );
|
||||||
|
@ -46,7 +46,7 @@
|
||||||
7 => 'Bla'
|
7 => 'Bla'
|
||||||
));
|
));
|
||||||
|
|
||||||
$computed_array = \database\core\Database::delNumeric( $fetchData );
|
$computed_array = \database\core\DatabaseDriver::delNumeric( $fetchData );
|
||||||
|
|
||||||
$this->assertArrayHasKey( 'id', $computed_array[0] );
|
$this->assertArrayHasKey( 'id', $computed_array[0] );
|
||||||
$this->assertArrayHasKey( 'nom', $computed_array[0] );
|
$this->assertArrayHasKey( 'nom', $computed_array[0] );
|
||||||
|
@ -73,7 +73,7 @@
|
||||||
1 => 'Jean Dupont'
|
1 => 'Jean Dupont'
|
||||||
);
|
);
|
||||||
|
|
||||||
$computed_array = \database\core\Database::delNumeric( $fetchData );
|
$computed_array = \database\core\DatabaseDriver::delNumeric( $fetchData );
|
||||||
|
|
||||||
$this->assertArrayHasKey( 'id', $computed_array );
|
$this->assertArrayHasKey( 'id', $computed_array );
|
||||||
$this->assertArrayHasKey( 'nom', $computed_array );
|
$this->assertArrayHasKey( 'nom', $computed_array );
|
||||||
|
@ -96,7 +96,7 @@
|
||||||
7 => 'Bla'
|
7 => 'Bla'
|
||||||
);
|
);
|
||||||
|
|
||||||
$computed_array = \database\core\Database::delNumeric( $fetchData );
|
$computed_array = \database\core\DatabaseDriver::delNumeric( $fetchData );
|
||||||
|
|
||||||
$this->assertArrayHasKey( 'id', $computed_array );
|
$this->assertArrayHasKey( 'id', $computed_array );
|
||||||
$this->assertArrayHasKey( 'nom', $computed_array );
|
$this->assertArrayHasKey( 'nom', $computed_array );
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<?php namespace phpunit;
|
<?php namespace phpunit;
|
||||||
use \database\core\Database;
|
use \database\core\DatabaseDriver;
|
||||||
|
|
||||||
class Database_readableNumber extends \PHPUnit_Framework_TestCase{
|
class Database_readableNumber extends \PHPUnit_Framework_TestCase{
|
||||||
|
|
||||||
|
@ -9,43 +9,43 @@
|
||||||
/* [1] Gestion du formattage+affichage des numéros
|
/* [1] Gestion du formattage+affichage des numéros
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
public function testA(){
|
public function testA(){
|
||||||
$this->assertEquals( Database::readableNumber('0102030405'), $this->formatted );
|
$this->assertEquals( DatabaseDriver::readableNumber('0102030405'), $this->formatted );
|
||||||
$this->assertEquals( Database::readableNumber('01 02 03 04 05'), $this->formatted );
|
$this->assertEquals( DatabaseDriver::readableNumber('01 02 03 04 05'), $this->formatted );
|
||||||
}
|
}
|
||||||
public function testB(){
|
public function testB(){
|
||||||
$this->assertEquals( Database::readableNumber('+33102030405'), $this->formatted );
|
$this->assertEquals( DatabaseDriver::readableNumber('+33102030405'), $this->formatted );
|
||||||
$this->assertEquals( Database::readableNumber('+331 02 03 04 05'), $this->formatted );
|
$this->assertEquals( DatabaseDriver::readableNumber('+331 02 03 04 05'), $this->formatted );
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testC(){
|
public function testC(){
|
||||||
$this->assertEquals( Database::readableNumber('33102030405'), $this->formatted );
|
$this->assertEquals( DatabaseDriver::readableNumber('33102030405'), $this->formatted );
|
||||||
$this->assertEquals( Database::readableNumber('331 02 03 04 05'), $this->formatted );
|
$this->assertEquals( DatabaseDriver::readableNumber('331 02 03 04 05'), $this->formatted );
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testCbis(){
|
public function testCbis(){
|
||||||
$this->assertEquals( Database::readableNumber('033102030405'), $this->formatted );
|
$this->assertEquals( DatabaseDriver::readableNumber('033102030405'), $this->formatted );
|
||||||
$this->assertEquals( Database::readableNumber('0331 02 03 04 05'), $this->formatted );
|
$this->assertEquals( DatabaseDriver::readableNumber('0331 02 03 04 05'), $this->formatted );
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testBter(){
|
public function testBter(){
|
||||||
$this->assertEquals( Database::readableNumber('0033102030405'), $this->formatted );
|
$this->assertEquals( DatabaseDriver::readableNumber('0033102030405'), $this->formatted );
|
||||||
$this->assertEquals( Database::readableNumber('00331 02 03 04 05'), $this->formatted );
|
$this->assertEquals( DatabaseDriver::readableNumber('00331 02 03 04 05'), $this->formatted );
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testFirstSpace(){
|
public function testFirstSpace(){
|
||||||
$this->assertEquals( Database::readableNumber('0 102030405'), $this->formatted );
|
$this->assertEquals( DatabaseDriver::readableNumber('0 102030405'), $this->formatted );
|
||||||
$this->assertEquals( Database::readableNumber('+33 102030405'), $this->formatted );
|
$this->assertEquals( DatabaseDriver::readableNumber('+33 102030405'), $this->formatted );
|
||||||
$this->assertEquals( Database::readableNumber('33 102030405'), $this->formatted );
|
$this->assertEquals( DatabaseDriver::readableNumber('33 102030405'), $this->formatted );
|
||||||
$this->assertEquals( Database::readableNumber('033 102030405'), $this->formatted );
|
$this->assertEquals( DatabaseDriver::readableNumber('033 102030405'), $this->formatted );
|
||||||
$this->assertEquals( Database::readableNumber('0033 102030405'), $this->formatted );
|
$this->assertEquals( DatabaseDriver::readableNumber('0033 102030405'), $this->formatted );
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testAllSpaces(){
|
public function testAllSpaces(){
|
||||||
$this->assertEquals( Database::readableNumber('0 1 02 03 04 05'), $this->formatted );
|
$this->assertEquals( DatabaseDriver::readableNumber('0 1 02 03 04 05'), $this->formatted );
|
||||||
$this->assertEquals( Database::readableNumber('+33 1 02 03 04 05'), $this->formatted );
|
$this->assertEquals( DatabaseDriver::readableNumber('+33 1 02 03 04 05'), $this->formatted );
|
||||||
$this->assertEquals( Database::readableNumber('33 1 02 03 04 05'), $this->formatted );
|
$this->assertEquals( DatabaseDriver::readableNumber('33 1 02 03 04 05'), $this->formatted );
|
||||||
$this->assertEquals( Database::readableNumber('033 1 02 03 04 05'), $this->formatted );
|
$this->assertEquals( DatabaseDriver::readableNumber('033 1 02 03 04 05'), $this->formatted );
|
||||||
$this->assertEquals( Database::readableNumber('0033 1 02 03 04 05'), $this->formatted );
|
$this->assertEquals( DatabaseDriver::readableNumber('0033 1 02 03 04 05'), $this->formatted );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue