| Line 107... |
Line 107... |
| 107 |
|
107 |
|
| 108 |
// Lancement des tests unitaires
|
108 |
// Lancement des tests unitaires
|
| 109 |
Debug::printr('Lancement des tests unitaires');
|
109 |
Debug::printr('Lancement des tests unitaires');
|
| 110 |
$tests_numeros = array_keys($this->tests);
|
110 |
$tests_numeros = array_keys($this->tests);
|
| 111 |
Debug::printr($tests_numeros);
|
111 |
Debug::printr($tests_numeros);
|
| 112 |
foreach ($tests_numeros as $numero) {
|
112 |
foreach ($tests_numeros as &$numero) {
|
| Line 113... |
Line 113... |
| 113 |
$info = $this->getInfosTest($numero);
|
113 |
$info = $this->getInfosTest($numero);
|
| 114 |
|
114 |
|
| 115 |
if ($numero < 5) {
|
115 |
if ($numero < 5) {
|
| Line 157... |
Line 157... |
| 157 |
if ($info['numero'] < 5) {
|
157 |
if ($info['numero'] < 5) {
|
| 158 |
return ($info['resultat'] ? '1' : '0');
|
158 |
return ($info['resultat'] ? '1' : '0');
|
| 159 |
}
|
159 |
}
|
| 160 |
}
|
160 |
}
|
| Line 161... |
Line 161... |
| 161 |
|
161 |
|
| 162 |
private function verifierResultats($resultats) {
|
162 |
private function verifierResultats(&$resultats) {
|
| 163 |
$ok = true;
|
163 |
$ok = true;
|
| 164 |
foreach ($resultats as $resultat) {
|
164 |
foreach ($resultats as $resultat) {
|
| 165 |
if ($resultat == '0') {
|
165 |
if ($resultat == '0') {
|
| 166 |
$ok = false;
|
166 |
$ok = false;
|
| Line 214... |
Line 214... |
| 214 |
$info = $this->getInfosTest(2);
|
214 |
$info = $this->getInfosTest(2);
|
| 215 |
$info['special'] = true;
|
215 |
$info['special'] = true;
|
| Line 216... |
Line 216... |
| 216 |
|
216 |
|
| 217 |
$champs_attendus = explode(',', $this->manuel['champs']);
|
217 |
$champs_attendus = explode(',', $this->manuel['champs']);
|
| 218 |
$champs_presents = array();
|
218 |
$champs_presents = array();
|
| 219 |
foreach ($this->colonnes as $colonne) {
|
219 |
foreach ($this->colonnes as &$colonne) {
|
| 220 |
$champs_presents[$colonne['Field']] = $colonne;
|
220 |
$champs_presents[$colonne['Field']] = $colonne;
|
| Line 221... |
Line 221... |
| 221 |
}
|
221 |
}
|
| 222 |
|
222 |
|
| 223 |
$ok = true;
|
223 |
$ok = true;
|
| 224 |
$champs_manquant = array();
|
224 |
$champs_manquant = array();
|
| 225 |
foreach ($champs_attendus as $champ_attendu) {
|
225 |
foreach ($champs_attendus as &$champ_attendu) {
|
| 226 |
if (!isset($champs_presents[$champ_attendu])) {
|
226 |
if (!isset($champs_presents[$champ_attendu])) {
|
| 227 |
$champs_manquant[] = $champ_attendu;
|
227 |
$champs_manquant[] = $champ_attendu;
|
| 228 |
$ok = false;
|
228 |
$ok = false;
|
| Line 241... |
Line 241... |
| 241 |
* Test #03
|
241 |
* Test #03
|
| 242 |
*/
|
242 |
*/
|
| 243 |
private function testerTypeDesChamps() {
|
243 |
private function testerTypeDesChamps() {
|
| 244 |
$champs_attendus = explode(',', $this->manuel['champs_type']);
|
244 |
$champs_attendus = explode(',', $this->manuel['champs_type']);
|
| 245 |
$champs_presents = array();
|
245 |
$champs_presents = array();
|
| 246 |
foreach ($this->colonnes as $colonne) {
|
246 |
foreach ($this->colonnes as &$colonne) {
|
| 247 |
$champs_presents[$colonne['Field']] = $colonne['Type'];
|
247 |
$champs_presents[$colonne['Field']] = $colonne['Type'];
|
| 248 |
}
|
248 |
}
|
| Line 249... |
Line 249... |
| 249 |
|
249 |
|
| 250 |
// Recercherche des erreurs
|
250 |
// Recercherche des erreurs
|
| 251 |
$champs_erreur = array();
|
251 |
$champs_erreur = array();
|
| 252 |
foreach ($champs_attendus as $champ_attendu) {
|
252 |
foreach ($champs_attendus as &$champ_attendu) {
|
| 253 |
list($champ_attendu_nom, $champ_attendu_type_taille) = explode('=', trim($champ_attendu));
|
253 |
list($champ_attendu_nom, $champ_attendu_type_taille) = explode('=', trim($champ_attendu));
|
| Line 254... |
Line 254... |
| 254 |
list($champ_attendu_type, $champ_attendu_taille) = explode('|', trim($champ_attendu_type_taille));
|
254 |
list($champ_attendu_type, $champ_attendu_taille) = explode('|', trim($champ_attendu_type_taille));
|
| 255 |
|
255 |
|
| Line 272... |
Line 272... |
| 272 |
*/
|
272 |
*/
|
| 273 |
private function testerNumNomClePrimaire() {
|
273 |
private function testerNumNomClePrimaire() {
|
| 274 |
$info = $this->getInfosTest(4);
|
274 |
$info = $this->getInfosTest(4);
|
| 275 |
$info['special'] = true;
|
275 |
$info['special'] = true;
|
| Line 276... |
Line 276... |
| 276 |
|
276 |
|
| 277 |
foreach ($this->colonnes as $colonne) {
|
277 |
foreach ($this->colonnes as &$colonne) {
|
| 278 |
if ($colonne['Field'] == 'num_nom' && $colonne['Key'] == 'PRI') {
|
278 |
if ($colonne['Field'] == 'num_nom' && $colonne['Key'] == 'PRI') {
|
| - |
|
279 |
$info['resultat'] = true;
|
| 279 |
$info['resultat'] = true;
|
280 |
break;
|
| 280 |
}
|
281 |
}
|
| 281 |
}
|
282 |
}
|
| 282 |
return $info;
|
283 |
return $info;
|
| Line 286... |
Line 287... |
| 286 |
/**
|
287 |
/**
|
| 287 |
* Test #05
|
288 |
* Test #05
|
| 288 |
*/
|
289 |
*/
|
| 289 |
private function testerTailleDesChamps() {
|
290 |
private function testerTailleDesChamps() {
|
| 290 |
$tailles_champs_maxi = array();
|
291 |
$tailles_champs_maxi = array();
|
| 291 |
foreach ($this->colonnes as $colonne) {
|
292 |
foreach ($this->colonnes as &$colonne) {
|
| 292 |
if (preg_match('/^varchar\(([0-9]+)\)$/', $colonne['Type'], $match)) {
|
293 |
if (preg_match('/^varchar\(([0-9]+)\)$/', $colonne['Type'], $match)) {
|
| 293 |
$tailles_champs_maxi[$colonne['Field']] = $match[1];
|
294 |
$tailles_champs_maxi[$colonne['Field']] = $match[1];
|
| 294 |
}
|
295 |
}
|
| 295 |
}
|
296 |
}
|
| Line 296... |
Line 297... |
| 296 |
|
297 |
|
| 297 |
$tailles_trouvees = array();
|
298 |
$tailles_trouvees = array();
|
| 298 |
foreach ($this->analyses as $analyse) {
|
299 |
foreach ($this->analyses as &$analyse) {
|
| 299 |
if (preg_match('/\.([^.]+)$/', $analyse['Field_name'], $match)) {
|
300 |
if (preg_match('/\.([^.]+)$/', $analyse['Field_name'], $match)) {
|
| 300 |
$tailles_trouvees[$match[1]] = $analyse['Max_length'];
|
301 |
$tailles_trouvees[$match[1]] = $analyse['Max_length'];
|
| 301 |
}
|
302 |
}
|
| Line 302... |
Line 303... |
| 302 |
}
|
303 |
}
|
| 303 |
|
304 |
|
| 304 |
$champs_erreur = array();
|
305 |
$champs_erreur = array();
|
| 305 |
$champs_attendus = explode(',', $this->manuel['champs']);
|
306 |
$champs_attendus = explode(',', $this->manuel['champs']);
|
| 306 |
foreach ($champs_attendus as $champ_attendu) {
|
307 |
foreach ($champs_attendus as &$champ_attendu) {
|
| 307 |
if (isset($tailles_champs_maxi[$champ_attendu]) && isset($tailles_trouvees[$champ_attendu])) {
|
308 |
if (isset($tailles_champs_maxi[$champ_attendu]) && isset($tailles_trouvees[$champ_attendu])) {
|
| 308 |
if ($tailles_champs_maxi[$champ_attendu] == $tailles_trouvees[$champ_attendu]) {
|
309 |
if ($tailles_champs_maxi[$champ_attendu] == $tailles_trouvees[$champ_attendu]) {
|
| 309 |
$champs_erreur[] = array($champ_attendu, $tailles_champs_maxi[$champ_attendu], $tailles_trouvees[$champ_attendu]);
|
310 |
$champs_erreur[] = array($champ_attendu, $tailles_champs_maxi[$champ_attendu], $tailles_trouvees[$champ_attendu]);
|
| Line 546... |
Line 547... |
| 546 |
$noms_erreur = array();
|
547 |
$noms_erreur = array();
|
| 547 |
foreach ($this->noms as &$nom) {
|
548 |
foreach ($this->noms as &$nom) {
|
| 548 |
if ($nom['rang'] == $this->manuel['rang_sp']) {
|
549 |
if ($nom['rang'] == $this->manuel['rang_sp']) {
|
| 549 |
$suffixe_plte_cultivee = $this->construireSuffixeNomPltCultivee($nom);
|
550 |
$suffixe_plte_cultivee = $this->construireSuffixeNomPltCultivee($nom);
|
| 550 |
$nom_sci_ideal = $this->formaterStyleNomGenre($nom['genre']);
|
551 |
$nom_sci_ideal = $this->formaterStyleNomGenre($nom['genre']);
|
| 551 |
$nom_sci_ideal .= ' '.strtolower($nom['epithete_sp']);
|
552 |
$nom_sci_ideal .= ' '.utf8_encode(strtolower(utf8_decode($nom['epithete_sp'])));
|
| 552 |
$nom_sci_ideal .= ($suffixe_plte_cultivee != '' ? ' '.$suffixe_plte_cultivee : '');
|
553 |
$nom_sci_ideal .= ($suffixe_plte_cultivee != '' ? ' '.$suffixe_plte_cultivee : '');
|
| 553 |
if ($nom['nom_sci'] != $nom_sci_ideal) {
|
554 |
if ($nom['nom_sci'] != $nom_sci_ideal) {
|
| 554 |
$nom_sci_traite = $this->repererEspace($nom['nom_sci']);
|
555 |
$nom_sci_traite = $this->repererEspace($nom['nom_sci']);
|
| 555 |
$noms_erreur[] = array($nom['num_nom'], $nom_sci_traite, $nom_sci_ideal, $nom['exclure_taxref']);
|
556 |
$noms_erreur[] = array($nom['num_nom'], $nom_sci_traite, $nom_sci_ideal, $nom['exclure_taxref']);
|
| 556 |
}
|
557 |
}
|
| Line 566... |
Line 567... |
| 566 |
$noms_erreur = array();
|
567 |
$noms_erreur = array();
|
| 567 |
foreach ($this->noms as &$nom) {
|
568 |
foreach ($this->noms as &$nom) {
|
| 568 |
if ($nom['rang'] > $this->manuel['rang_sp']) {
|
569 |
if ($nom['rang'] > $this->manuel['rang_sp']) {
|
| 569 |
$suffixe_plte_cultivee = $this->construireSuffixeNomPltCultivee($nom);
|
570 |
$suffixe_plte_cultivee = $this->construireSuffixeNomPltCultivee($nom);
|
| 570 |
$nom_sci_ideal = $this->formaterStyleNomGenre($nom['genre']);
|
571 |
$nom_sci_ideal = $this->formaterStyleNomGenre($nom['genre']);
|
| 571 |
$nom_sci_ideal .= ' '.strtolower($nom['epithete_sp']);
|
572 |
$nom_sci_ideal .= ' '.utf8_encode(strtolower(utf8_decode($nom['epithete_sp'])));
|
| 572 |
$nom_sci_ideal .= ' '.strtolower($nom['type_epithete']);
|
573 |
$nom_sci_ideal .= ' '.utf8_encode(strtolower(utf8_decode($nom['type_epithete'])));
|
| 573 |
$nom_sci_ideal .= ' '.strtolower($nom['epithete_infra_sp']);
|
574 |
$nom_sci_ideal .= ' '.utf8_encode(strtolower(utf8_decode($nom['epithete_infra_sp'])));
|
| 574 |
$nom_sci_ideal .= ($suffixe_plte_cultivee != '' ? ' '.$suffixe_plte_cultivee : '');
|
575 |
$nom_sci_ideal .= ($suffixe_plte_cultivee != '' ? ' '.$suffixe_plte_cultivee : '');
|
| 575 |
if ($nom['nom_sci'] != $nom_sci_ideal) {
|
576 |
if ($nom['nom_sci'] != $nom_sci_ideal) {
|
| 576 |
$nom_sci_traite = $this->repererEspace($nom['nom_sci']);
|
577 |
$nom_sci_traite = $this->repererEspace($nom['nom_sci']);
|
| 577 |
$noms_erreur[] = array($nom['num_nom'], $nom_sci_traite, $nom_sci_ideal, $nom['exclure_taxref']);
|
578 |
$noms_erreur[] = array($nom['num_nom'], $nom_sci_traite, $nom_sci_ideal, $nom['exclure_taxref']);
|
| 578 |
}
|
579 |
}
|
| Line 1540... |
Line 1541... |
| 1540 |
}
|
1541 |
}
|
| Line 1541... |
Line 1542... |
| 1541 |
|
1542 |
|
| 1542 |
private function formaterStyleNomGenre(&$genre) {
|
1543 |
private function formaterStyleNomGenre(&$genre) {
|
| 1543 |
$genre_fmt = '';
|
1544 |
$genre_fmt = '';
|
| 1544 |
if (preg_match('/^\s*([x+])\s+(.+)$/i', $genre, $match)) {
|
1545 |
if (preg_match('/^\s*([x+])\s+(.+)$/i', $genre, $match)) {
|
| 1545 |
$genre_fmt = strtolower($match[1]).' '.ucfirst(strtolower($match[2]));
|
1546 |
$genre_fmt = utf8_encode(strtolower(utf8_decode($match[1]))).' '.utf8_encode(ucfirst(strtolower(utf8_decode($match[2]))));
|
| 1546 |
} else {
|
1547 |
} else {
|
| 1547 |
$genre_fmt = ucfirst(strtolower($genre));
|
1548 |
$genre_fmt = utf8_encode(ucfirst(strtolower(utf8_decode($genre))));
|
| 1548 |
}
|
1549 |
}
|
| 1549 |
return $genre_fmt;
|
1550 |
return $genre_fmt;
|
| Line 1550... |
Line 1551... |
| 1550 |
}
|
1551 |
}
|