61 |
jpm |
1 |
<?php
|
94 |
jpm |
2 |
require_once dirname(__FILE__).'/../ScriptEflorePhpUnit.php';
|
61 |
jpm |
3 |
|
94 |
jpm |
4 |
class OutilsTest extends ScriptEflorePhpUnit {
|
61 |
jpm |
5 |
|
|
|
6 |
public function testRecupererTableauConfigAssociatif() {
|
|
|
7 |
$chaineDeParametres = "param1=valeur1,\nparam2=valeur2";
|
|
|
8 |
$tableauDeParametres = Outils::recupererTableauConfig($chaineDeParametres);
|
|
|
9 |
$tableauDeParametresAttendus = array('param1' => 'valeur1','param2' => 'valeur2');
|
|
|
10 |
$this->assertEquals($tableauDeParametresAttendus, $tableauDeParametres);
|
|
|
11 |
}
|
|
|
12 |
|
|
|
13 |
public function testRecupererTableauConfigAssociatifAvecEspace() {
|
|
|
14 |
$chaineDeParametres = "param1 =valeur1 , \nparam2 = valeur2";
|
|
|
15 |
$tableauDeParametres = Outils::recupererTableauConfig($chaineDeParametres);
|
|
|
16 |
$tableauDeParametresAttendus = array('param1' => 'valeur1','param2' => 'valeur2');
|
|
|
17 |
$this->assertEquals($tableauDeParametresAttendus, $tableauDeParametres);
|
|
|
18 |
}
|
|
|
19 |
|
|
|
20 |
public function testRecupererTableauConfigSimple() {
|
|
|
21 |
$chaineDeParametres = "param1,\nparam2";
|
|
|
22 |
$tableauDeParametres = Outils::recupererTableauConfig($chaineDeParametres);
|
|
|
23 |
$tableauDeParametresAttendus = array('param1', 'param2');
|
|
|
24 |
$this->assertEquals($tableauDeParametresAttendus, $tableauDeParametres);
|
|
|
25 |
}
|
|
|
26 |
|
|
|
27 |
public function testRecupererTableauConfigSimpleAvecEspace() {
|
|
|
28 |
$chaineDeParametres = " param1 ,\n param2 ";
|
|
|
29 |
$tableauDeParametres = Outils::recupererTableauConfig($chaineDeParametres);
|
|
|
30 |
$tableauDeParametresAttendus = array('param1', 'param2');
|
|
|
31 |
$this->assertEquals($tableauDeParametresAttendus, $tableauDeParametres);
|
|
|
32 |
}
|
|
|
33 |
|
|
|
34 |
public function testExtraireRequetes() {
|
|
|
35 |
$contenuSql = "CREATE TABLE IF NOT EXISTS bdtfx_v1_01 (".
|
|
|
36 |
"num_nom int(9) NOT NULL DEFAULT '0',".
|
|
|
37 |
"num_nom_retenu varchar(9) CHARACTER SET utf8 DEFAULT NULL,".
|
|
|
38 |
") ENGINE=MyISAM DEFAULT CHARSET=utf8;\n\n".
|
|
|
39 |
"INSERT INTO bdtfx_meta (guid) VALUES".
|
|
|
40 |
"('urn:lsid:tela-botanica.org:bdtfx:1.01');\n".
|
|
|
41 |
"SELECT * FROM ma_table;";
|
|
|
42 |
$tableauDeRequetes = Outils::extraireRequetes($contenuSql);
|
|
|
43 |
$tableauDeRequetesAttendus = array("CREATE TABLE IF NOT EXISTS bdtfx_v1_01 (".
|
|
|
44 |
"num_nom int(9) NOT NULL DEFAULT '0',".
|
|
|
45 |
"num_nom_retenu varchar(9) CHARACTER SET utf8 DEFAULT NULL,".
|
|
|
46 |
") ENGINE=MyISAM DEFAULT CHARSET=utf8",
|
|
|
47 |
"INSERT INTO bdtfx_meta (guid) VALUES".
|
|
|
48 |
"('urn:lsid:tela-botanica.org:bdtfx:1.01')",
|
|
|
49 |
"SELECT * FROM ma_table");
|
|
|
50 |
$this->assertEquals($tableauDeRequetesAttendus, $tableauDeRequetes);
|
|
|
51 |
}
|
|
|
52 |
|
|
|
53 |
public function testAfficherAvancement() {
|
|
|
54 |
ob_start();
|
|
|
55 |
for ($i = 0; $i < 10; $i++) {
|
|
|
56 |
$tableauDeRequetes = Outils::afficherAvancement("Test");
|
|
|
57 |
}
|
|
|
58 |
$messageFinal = ob_get_clean();
|
|
|
59 |
$messageFinalAttendu = 'Test : 0'.chr(8).'1'.chr(8).'2'.chr(8).'3'.chr(8).'4'.chr(8).'5'.chr(8).'6'.chr(8).'7'.chr(8).'8'.chr(8).'9';
|
|
|
60 |
$this->assertEquals($messageFinalAttendu, $messageFinal);
|
|
|
61 |
}
|
|
|
62 |
}
|
|
|
63 |
?>
|