Line 14... |
Line 14... |
14 |
* @license http://www.gnu.org/licenses/gpl.html Licence GNU-GPL
|
14 |
* @license http://www.gnu.org/licenses/gpl.html Licence GNU-GPL
|
15 |
* @version $Id$
|
15 |
* @version $Id$
|
16 |
*/
|
16 |
*/
|
17 |
abstract class ServicePhpUnit extends PHPUnit_Framework_TestCase {
|
17 |
abstract class ServicePhpUnit extends PHPUnit_Framework_TestCase {
|
Line -... |
Line 18... |
- |
|
18 |
|
18 |
|
19 |
protected static $cheminBase = '';
|
19 |
protected static $projet = '';
|
20 |
protected $projet = '';
|
20 |
protected $service = '';
|
21 |
protected $service = '';
|
21 |
protected $classeTestee = '';
|
22 |
protected $classeTestee = '';
|
22 |
protected $baseUrl = 'http://localhost/service:eflore:0.1/';
|
23 |
protected $baseUrl = 'http://localhost/service:eflore:0.1/';
|
23 |
protected $serviceBaseUrl = '';
|
24 |
protected $serviceBaseUrl = '';
|
24 |
//+------------------------------------------------------------------------------------------------------+
|
25 |
//+------------------------------------------------------------------------------------------------------+
|
Line 25... |
Line 26... |
25 |
// Intialisation
|
26 |
// Intialisation
|
26 |
|
27 |
|
27 |
public static function setUpBeforeClass() {
|
- |
|
28 |
error_reporting(E_ALL);
|
28 |
public static function setUpBeforeClass() {
|
29 |
|
- |
|
- |
|
29 |
error_reporting(E_ALL);
|
30 |
self::chargerFramework();
|
30 |
self::chargerFramework();
|
31 |
|
31 |
self::$cheminBase = realpath(__DIR__.'/../../modules/0.2').'/';
|
32 |
// Enregistrement en première position des autoload de la méthode gérant les classes des services
|
32 |
// Enregistrement en première position des autoload de la méthode gérant les classes des services
|
Line 33... |
Line 33... |
33 |
spl_autoload_register(array(get_class($this), 'chargerClasseAuto'));
|
33 |
spl_autoload_register(array(get_class($this), 'chargerClasseAuto'));
|
34 |
}
|
34 |
}
|
35 |
|
35 |
|
36 |
public static function chargerClasseAuto($classe) {
|
36 |
public static function chargerClasseAuto($classe) {
|
37 |
if (class_exists($classe)) {
|
- |
|
38 |
return null;
|
- |
|
- |
|
37 |
if (class_exists($classe)) {
|
39 |
}
|
38 |
return null;
|
- |
|
39 |
}
|
40 |
$cheminBase = realpath(__DIR__.'/../../modules/0.2').'/';
|
40 |
|
41 |
$cheminProjet = $cheminBase.self::$projet.'/';
|
41 |
$cheminBibliotheque = realpath(__DIR__.'/../../bibliotheque').'/';
|
42 |
$cheminBibliotheque = realpath(__DIR__.'/../../bibliotheque').'/';
|
42 |
$cheminBiblioInterfaces = $cheminBibliotheque.'interfaces/';
|
- |
|
43 |
$cheminBiblioNom = $cheminBibliotheque.'nom/';
|
- |
|
44 |
$cheminBiblioNomDeco = $cheminBiblioNom.'decorateurs/';
|
- |
|
45 |
$cheminsTests = __DIR__.'/';
|
- |
|
46 |
$chemins = array(
|
43 |
$cheminBiblioNom = $cheminBibliotheque.'nom/';
|
47 |
self::$cheminBase,
|
- |
|
48 |
$cheminBibliotheque,
|
44 |
$cheminBiblioNomDeco = $cheminBiblioNom.'decorateurs/';
|
49 |
$cheminsTests,
|
- |
|
50 |
$cheminBiblioInterfaces,
|
45 |
$cheminsTests = __DIR__.'/';
|
51 |
$cheminBiblioNom,
|
46 |
$chemins = array($cheminBase, $cheminProjet, $cheminBibliotheque, $cheminsTests, $cheminBiblioNom,
|
52 |
$cheminBiblioNomDeco);
|
47 |
$cheminBiblioNomDeco);
|
53 |
|
48 |
foreach ($chemins as $chemin) {
|
54 |
foreach ($chemins as $chemin) {
|
49 |
$chemin = $chemin.$classe.'.php';
|
55 |
$chemin = $chemin.$classe.'.php';
|
Line 77... |
Line 83... |
77 |
return $retour;
|
83 |
return $retour;
|
78 |
}
|
84 |
}
|
Line 79... |
Line 85... |
79 |
|
85 |
|
80 |
protected function consulterBrut($ressources, $parametres) {
|
86 |
protected function consulterBrut($ressources, $parametres) {
|
81 |
array_unshift($ressources, $this->service);
|
87 |
array_unshift($ressources, $this->service);
|
82 |
array_unshift($ressources, self::$projet);
|
88 |
array_unshift($ressources, $this->projet);
|
83 |
$Bdd = new Bdd();
|
89 |
$Bdd = new Bdd();
|
84 |
$Ressources = new Ressources($ressources);
|
90 |
$Ressources = new Ressources($ressources);
|
- |
|
91 |
$Parametres = new Parametres($parametres, $Bdd);
|
85 |
$Parametres = new Parametres($parametres, $Bdd);
|
92 |
require_once self::$cheminBase.$this->projet.'/'.$this->classeTestee.'.php';
|
86 |
$objetService = new $this->classeTestee($Ressources, $Parametres, $Bdd);
|
93 |
$objetService = new $this->classeTestee($Ressources, $Parametres, $Bdd);
|
87 |
$this->initialiserService($objetService);
|
94 |
$this->initialiserService($objetService);
|
88 |
$retourJson = $objetService->consulter();
|
95 |
$retourJson = $objetService->consulter();
|
89 |
return $retourJson;
|
96 |
return $retourJson;
|
Line 102... |
Line 109... |
102 |
foreach ($parametres as $cle => $valeur) {
|
109 |
foreach ($parametres as $cle => $valeur) {
|
103 |
$parametresUrl[] = $cle.'='.rawurlencode($valeur);
|
110 |
$parametresUrl[] = $cle.'='.rawurlencode($valeur);
|
104 |
}
|
111 |
}
|
105 |
$parametresUrl = '?'.implode('&', $parametresUrl);
|
112 |
$parametresUrl = '?'.implode('&', $parametresUrl);
|
106 |
}
|
113 |
}
|
107 |
$url = $this->baseUrl.self::$projet.'/'.$version.$this->service.$ressourcesUrl.$parametresUrl;
|
114 |
$url = $this->baseUrl.$this->projet.'/'.$version.$this->service.$ressourcesUrl.$parametresUrl;
|
108 |
return $url;
|
115 |
return $url;
|
109 |
}
|
116 |
}
|
Line 110... |
Line 117... |
110 |
|
117 |
|
111 |
//+------------------------------------------------------------------------------------------------------+
|
118 |
//+------------------------------------------------------------------------------------------------------+
|