Subversion Repositories Applications.referentiel

Compare Revisions

Ignore whitespace Rev 51 → Rev 64

/trunk/scripts/modules/tests/Tests.php
24,6 → 24,7
private $traitement = null;
private $manuel = null;
private $noms = null;
private $resultatDao = null;
private $traitementDao = null;
75,104 → 76,119
// Récupération des données à tester
$colonnes = $this->tableStructureDao->getColonnes($this->projet);
$analyses = $this->tableStructureDao->getAnalyse($this->projet);
$noms = $this->referentielDao->getTout($this->projet);
Debug::printr('Nbre noms :'.count($noms));
$noms = $this->classerNomsParNumNom($noms);
$noms_homonymie = $this->classerNomsParNomComplet($noms);
$this->noms = $this->referentielDao->getTout($this->projet);
Debug::printr('Nbre noms :'.count($this->noms));
// Lancement des tests unitaires
$this->testerNombreDeChamps($colonnes);
$this->testerNomDesChamps($colonnes);
$this->testerTypeDesChamps($colonnes);
$this->testerTailleDesChamps($colonnes, $analyses);
$this->testerNumNomClePrimaire($colonnes);
$resultats = array();
$resultats[] = $this->testerNombreDeChamps($colonnes);
$resultats[] = $this->testerNomDesChamps($colonnes);
$resultats[] = $this->testerTypeDesChamps($colonnes);
$resultats[] = $this->testerNumNomClePrimaire($colonnes);
$this->testerNumNomSuperieurAZero($noms);
$this->testerNumNomRetenuSuperieurAZero($noms);
$this->testerNumTaxSupEgalZeroUnique($noms);
$this->testerTaxSupPourTaxon($noms);
$this->testerExitenceTaxonSuperieur($noms);
$this->testerClassificationRang($noms);
$this->testerClassification($noms);
$this->testerRang($noms);
$this->testerNomCompletSupraGenerique($noms);
$this->testerNomCompletGenre($noms);
$this->testerNomCompletInfraGenre($noms);
$this->testerNomCompletEspece($noms);
$this->testerNomCompletInfraSpecifique($noms);
 
$this->testerNomSupraGeneriqueEspaces($noms);
$this->testerNomSupraGeneriqueSyntaxe($noms);
$this->testerNomSupraGeneriqueRang($noms);
$this->testerGenreEspaces($noms);
$this->testerGenreSyntaxe($noms);
$this->testerGenreRang($noms);
$this->testerEpitheteInfraGeneriqueEspaces($noms);
$this->testerEpitheteInfraGeneriqueSyntaxe($noms);
$this->testerEpitheteInfraGeneriqueRang($noms);
$this->testerEpitheteSpEspaces($noms);
$this->testerEpitheteSpSyntaxe($noms);
$this->testerEpitheteSpRang($noms);
$this->testerTypeEpitheteEspaces($noms);
$this->testerTypeEpitheteSyntaxe($noms);
$this->testerTypeEpitheteHybridite($noms);
$this->testerEpitheteInfraSpEspaces($noms);
$this->testerEpitheteInfraSpSyntaxe($noms);
$this->testerEpitheteInfraSpRang($noms);
$this->testerGroupeCultivarSyntaxe($noms);
$this->testerGroupeCultivarRang($noms);
$this->testerCultivarSyntaxe($noms);
$this->testerCultivarRang($noms);
$this->testerNomCommercialSyntaxe($noms);
$this->testerNomCommercialPresenceCultivar($noms);
$this->testerAuteurSyntaxe($noms);
$this->testerAnneeSyntaxe($noms);
$this->testerBiblioOrigineSyntaxe($noms);
$this->testerHomonymieSyntaxe($noms);
$this->testerHomonymieExistence($noms, $noms_homonymie);
$this->testerBasionymeSyntaxe($noms);
$this->testerBasionymeExistence($noms);
$this->testerSynonymeProparteSyntaxe($noms);
$this->testerSynonymeProparteExistence($noms);
$this->testerSynonymeDouteuxSyntaxe($noms);
$this->testerSynonymeMalAppliqueSyntaxe($noms);
$this->testerSynonymeOrthographiqueSyntaxe($noms);
$this->testerSynonymeOrthographiqueExistence($noms);
$this->testerHybrideParent01Syntaxe($noms);
$this->testerHybrideParent01Existence($noms);
$this->testerHybrideParent02Syntaxe($noms);
$this->testerHybrideParent02Existence($noms);
$this->testerPresenceSyntaxe($noms);
$this->testerStatutOrigineSyntaxe($noms);
$this->testerStatutIntroductionSyntaxe($noms);
$this->testerStatutCultureSyntaxe($noms);
// Si la structure est bonne nous lançons les autres tests
Debug::printr($resultats);
if ($this->verifierResultats($resultats)) {
$this->testerTailleDesChamps($colonnes, $analyses);
$this->testerNumNomSuperieurAZero();
$this->testerNumNomRetenuSuperieurAZero();
$this->testerNumTaxSupEgalZeroUnique();
$this->testerTaxSupPourTaxon();
$this->testerExitenceTaxonSuperieur();
$this->testerClassificationRang();
$this->testerClassification();
$this->testerRang();
$this->testerNomCompletSupraGenerique();
$this->testerNomCompletGenre();
$this->testerNomCompletInfraGenre();
$this->testerNomCompletEspece();
$this->testerNomCompletInfraSpecifique();
$this->testerNomSupraGeneriqueEspaces();
$this->testerNomSupraGeneriqueSyntaxe();
$this->testerNomSupraGeneriqueRang();
$this->testerGenreEspaces();
$this->testerGenreSyntaxe();
$this->testerGenreRang();
$this->testerEpitheteInfraGeneriqueEspaces();
$this->testerEpitheteInfraGeneriqueSyntaxe();
$this->testerEpitheteInfraGeneriqueRang();
$this->testerEpitheteSpEspaces();
$this->testerEpitheteSpSyntaxe();
$this->testerEpitheteSpRang();
$this->testerTypeEpitheteEspaces();
$this->testerTypeEpitheteSyntaxe();
$this->testerTypeEpitheteHybridite();
$this->testerEpitheteInfraSpEspaces();
$this->testerEpitheteInfraSpSyntaxe();
$this->testerEpitheteInfraSpRang();
$this->testerGroupeCultivarSyntaxe();
$this->testerGroupeCultivarRang();
$this->testerCultivarSyntaxe();
$this->testerCultivarRang();
$this->testerNomCommercialSyntaxe();
$this->testerNomCommercialPresenceCultivar();
$this->testerAuteurSyntaxe();
$this->testerAnneeSyntaxe();
$this->testerBiblioOrigineSyntaxe();
$this->testerHomonymieSyntaxe();
$this->testerHomonymieExistence();
$this->testerBasionymeSyntaxe();
$this->testerBasionymeExistence();
$this->testerSynonymeProparteSyntaxe();
$this->testerSynonymeProparteExistence();
$this->testerSynonymeDouteuxSyntaxe();
$this->testerSynonymeMalAppliqueSyntaxe();
$this->testerSynonymeOrthographiqueSyntaxe();
$this->testerSynonymeOrthographiqueExistence();
$this->testerHybrideParent01Syntaxe();
$this->testerHybrideParent01Existence();
$this->testerHybrideParent02Syntaxe();
$this->testerHybrideParent02Existence();
$this->testerPresenceSyntaxe();
$this->testerStatutOrigineSyntaxe();
$this->testerStatutIntroductionSyntaxe();
$this->testerStatutCultureSyntaxe();
}
}
private function verifierResultats($resultats) {
$ok = true;
foreach ($resultats as $resultat) {
if ($resultat == '0') {
$ok = false;
break;
}
}
return $ok;
}
//+--------------------------------------------------------------------------------------------------------------+//
// Enregistrement des résultats
private function traiterResultatTest($info) {
Debug::printr($info['nom']);
if (isset($info['message'])) {
if (is_array($info['message'])) {
$info['message'] = $this->getVue('tests/squelettes/message_table', $info);
181,12 → 197,13
}
}
$this->resultatDao->ajouter($this->traitement['id_traitement'], $info);
$info = null;
}
//+--------------------------------------------------------------------------------------------------------------+//
// TESTS
private function testerStatutCultureSyntaxe($noms) {
private function testerStatutCultureSyntaxe() {
$info = array('nom' => 'statut_culture -> syntaxe',
'description' => "Le champ statut_culture peut contenir :\n".
" - le symbole tiret «-» une autre information non référencée...\n".
197,7 → 214,7
// Réalisation du test
$noms_erreur = array();
foreach ($noms as $nom) {
foreach ($this->noms as &$nom) {
if ($nom['statut_culture'] != '') {
if (!$this->verifierStatutCulture($nom['statut_culture'])) {
$noms_erreur[] = array($nom['num_nom'], $nom['statut_culture']);
212,11 → 229,12
} else {
$info['resultat'] = true;
}
$noms_erreur = null;
$this->traiterResultatTest($info);
}
private function testerStatutIntroductionSyntaxe($noms) {
private function testerStatutIntroductionSyntaxe() {
$info = array('nom' => 'statut_introduction -> syntaxe',
'description' => "Le champ statut_introduction peut contenir :\n".
" - le symbole tiret «-» une autre information non référencée...\n".
227,7 → 245,7
// Réalisation du test
$noms_erreur = array();
foreach ($noms as $nom) {
foreach ($this->noms as &$nom) {
if ($nom['statut_introduction'] != '') {
if (!$this->verifierStatutIntroduction($nom['statut_introduction'])) {
$noms_erreur[] = array($nom['num_nom'], $nom['statut_introduction']);
242,11 → 260,12
} else {
$info['resultat'] = true;
}
$noms_erreur = null;
$this->traiterResultatTest($info);
}
private function testerStatutOrigineSyntaxe($noms) {
private function testerStatutOrigineSyntaxe() {
$info = array('nom' => 'statut_origine -> syntaxe',
'description' => "Le champ statut_origine peut contenir :\n".
" - le symbole tiret «-» une autre information non référencée...\n".
257,7 → 276,7
// Réalisation du test
$noms_erreur = array();
foreach ($noms as $nom) {
foreach ($this->noms as &$nom) {
if ($nom['statut_origine'] != '') {
if (!$this->verifierStatutOrigine($nom['statut_origine'])) {
$noms_erreur[] = array($nom['num_nom'], $nom['statut_origine']);
272,11 → 291,12
} else {
$info['resultat'] = true;
}
$noms_erreur = null;
$this->traiterResultatTest($info);
}
private function testerPresenceSyntaxe($noms) {
private function testerPresenceSyntaxe() {
$info = array('nom' => 'presence -> syntaxe',
'description' => "Le champ presence contient soit :\n".
" - le symbole tiret «-» une autre information non référencée...\n".
287,7 → 307,7
// Réalisation du test
$noms_erreur = array();
foreach ($noms as $nom) {
foreach ($this->noms as &$nom) {
if ($nom['presence'] != '') {
if (!$this->verifierPresence($nom['presence'])) {
$noms_erreur[] = array($nom['num_nom'], $nom['presence']);
302,11 → 322,12
} else {
$info['resultat'] = true;
}
$noms_erreur = null;
$this->traiterResultatTest($info);
}
private function testerHybrideParent02Existence($noms) {
private function testerHybrideParent02Existence() {
$info = array('nom' => 'hybride_parent_02 -> existence',
'description' => "Si le champ hybride_parent_02 contient un nombre alors il doit correspondre à une valeur du champ ".
"num_nom.",
314,9 → 335,9
// Réalisation du test
$noms_erreur = array();
foreach ($noms as $nom) {
foreach ($this->noms as &$nom) {
if ($nom['hybride_parent_02'] != '') {
if (!isset($noms[$nom['hybride_parent_02']]) && $nom['hybride_parent_02'] != '0') {
if (!isset($this->noms[$nom['hybride_parent_02']]) && $nom['hybride_parent_02'] != '0') {
$noms_erreur[] = array($nom['num_nom'], $this->repererEspace($nom['hybride_parent_02']));
}
}
329,11 → 350,12
} else {
$info['resultat'] = true;
}
$noms_erreur = null;
$this->traiterResultatTest($info);
}
private function testerHybrideParent02Syntaxe($noms) {
private function testerHybrideParent02Syntaxe() {
$info = array('nom' => 'hybride_parent_02 -> syntaxe',
'description' => "Le champ hybride_parent_02 contient soit :\n".
" - une valeur vide.\n".
342,7 → 364,7
// Réalisation du test
$noms_erreur = array();
foreach ($noms as $nom) {
foreach ($this->noms as &$nom) {
if ($nom['hybride_parent_02'] != '') {
if (!$this->verifierNombre($nom['hybride_parent_02'])) {
$noms_erreur[] = array($nom['num_nom'], $this->repererEspace($nom['hybride_parent_02']));
357,12 → 379,13
} else {
$info['resultat'] = true;
}
$noms_erreur = null;
$this->traiterResultatTest($info);
}
private function testerHybrideParent01Existence($noms) {
private function testerHybrideParent01Existence() {
$info = array('nom' => 'hybride_parent_01 -> existence',
'description' => "Si le champ hybride_parent_01 contient un nombre alors il doit correspondre à une valeur du champ ".
"num_nom.",
370,9 → 393,9
// Réalisation du test
$noms_erreur = array();
foreach ($noms as $nom) {
foreach ($this->noms as &$nom) {
if ($nom['hybride_parent_01'] != '' && $nom['hybride_parent_01'] != '0') {
if (!isset($noms[$nom['hybride_parent_01']])) {
if (!isset($this->noms[$nom['hybride_parent_01']])) {
$noms_erreur[] = array($nom['num_nom'], $this->repererEspace($nom['hybride_parent_01']));
}
}
385,11 → 408,12
} else {
$info['resultat'] = true;
}
$noms_erreur = null;
$this->traiterResultatTest($info);
}
private function testerHybrideParent01Syntaxe($noms) {
private function testerHybrideParent01Syntaxe() {
$info = array('nom' => 'hybride_parent_01 -> syntaxe',
'description' => "Le champ hybride_parent_01 contient soit :\n".
" - une valeur vide.\n".
398,7 → 422,7
// Réalisation du test
$noms_erreur = array();
foreach ($noms as $nom) {
foreach ($this->noms as &$nom) {
if ($nom['hybride_parent_01'] != '') {
if (!$this->verifierNombre($nom['hybride_parent_01'])) {
$noms_erreur[] = array($nom['num_nom'], $this->repererEspace($nom['hybride_parent_01']));
413,11 → 437,12
} else {
$info['resultat'] = true;
}
$noms_erreur = null;
$this->traiterResultatTest($info);
}
private function testerSynonymeOrthographiqueExistence($noms) {
private function testerSynonymeOrthographiqueExistence() {
$info = array('nom' => 'synonyme_orthographique -> existence',
'description' => "Si le champ synonyme_orthographique contient un nombre alors il doit correspondre à une valeur du champ ".
"num_nom.",
425,9 → 450,9
// Réalisation du test
$noms_erreur = array();
foreach ($noms as $nom) {
foreach ($this->noms as &$nom) {
if ($nom['synonyme_orthographique'] != '') {
if (!isset($noms[$nom['synonyme_orthographique']])) {
if (!isset($this->noms[$nom['synonyme_orthographique']])) {
$noms_erreur[] = array($nom['num_nom'], $nom['synonyme_orthographique']);
}
}
440,11 → 465,12
} else {
$info['resultat'] = true;
}
$noms_erreur = null;
$this->traiterResultatTest($info);
}
private function testerSynonymeOrthographiqueSyntaxe($noms) {
private function testerSynonymeOrthographiqueSyntaxe() {
$info = array('nom' => 'synonyme_orthographique -> syntaxe',
'description' => "Le champ synonyme_orthographique contient soit :\n".
" - une valeur vide.\n".
453,7 → 479,7
// Réalisation du test
$noms_erreur = array();
foreach ($noms as $nom) {
foreach ($this->noms as $nom) {
if ($nom['synonyme_orthographique'] != '') {
if (!$this->verifierNombre($nom['synonyme_orthographique'])) {
$noms_erreur[] = array($nom['num_nom'], $nom['synonyme_orthographique']);
468,11 → 494,12
} else {
$info['resultat'] = true;
}
$noms_erreur = null;
$this->traiterResultatTest($info);
}
private function testerSynonymeMalAppliqueSyntaxe($noms) {
private function testerSynonymeMalAppliqueSyntaxe() {
$info = array('nom' => 'synonyme_mal_applique -> syntaxe',
'description' => "Le champ synonyme_mal_applique contient soit :\n".
" - une valeur vide.\n".
481,7 → 508,7
// Réalisation du test
$noms_erreur = array();
foreach ($noms as $nom) {
foreach ($this->noms as &$nom) {
if ($nom['synonyme_mal_applique'] != '') {
if (!$this->verifierBooleen($nom['synonyme_mal_applique'])) {
$noms_erreur[] = array($nom['num_nom'], $nom['synonyme_mal_applique']);
496,11 → 523,12
} else {
$info['resultat'] = true;
}
$noms_erreur = null;
$this->traiterResultatTest($info);
}
private function testerSynonymeDouteuxSyntaxe($noms) {
private function testerSynonymeDouteuxSyntaxe() {
$info = array('nom' => 'synonyme_douteux -> syntaxe',
'description' => "Le champ synonyme_douteux contient soit :\n".
" - une valeur vide.\n".
509,7 → 537,7
// Réalisation du test
$noms_erreur = array();
foreach ($noms as $nom) {
foreach ($this->noms as &$nom) {
if ($nom['synonyme_douteux'] != '') {
if (!$this->verifierBooleen($nom['synonyme_douteux'])) {
$noms_erreur[] = array($nom['num_nom'], $nom['synonyme_douteux']);
524,11 → 552,12
} else {
$info['resultat'] = true;
}
$noms_erreur = null;
$this->traiterResultatTest($info);
}
private function testerSynonymeProparteExistence($noms) {
private function testerSynonymeProparteExistence() {
$info = array('nom' => 'synonyme_proparte -> existence',
'description' => "Si le champ synonyme_proparte contient un ou plusieurs nombres alors chacun d'entre eux ".
"doit correspondre à une valeur du champ num_nom.",
536,12 → 565,12
// Réalisation du test
$noms_erreur = array();
foreach ($noms as $nom) {
foreach ($this->noms as &$nom) {
if ($nom['synonyme_proparte'] != '') {
$num_nom_a_verifier = explode(',', $nom['synonyme_proparte']);
$num_nom_en_erreur = array();
foreach ($num_nom_a_verifier as $num_nom) {
if (!isset($noms[$num_nom])) {
if (!isset($this->noms[$num_nom])) {
$num_nom_en_erreur[] = $num_nom;
}
}
558,11 → 587,12
} else {
$info['resultat'] = true;
}
$noms_erreur = null;
$this->traiterResultatTest($info);
}
private function testerSynonymeProparteSyntaxe($noms) {
private function testerSynonymeProparteSyntaxe() {
$info = array('nom' => 'synonyme_proparte -> syntaxe',
'description' => "Le champ synonyme_proparte contient soit :\n".
" - une valeur vide.\n".
572,7 → 602,7
// Réalisation du test
$noms_erreur = array();
foreach ($noms as $nom) {
foreach ($this->noms as &$nom) {
if ($nom['synonyme_proparte'] != '') {
if (!$this->verifierNombreSuite($nom['synonyme_proparte'])) {
$noms_erreur[] = array($nom['num_nom'], $nom['synonyme_proparte']);
587,11 → 617,12
} else {
$info['resultat'] = true;
}
$noms_erreur = null;
$this->traiterResultatTest($info);
}
private function testerBasionymeExistence($noms) {
private function testerBasionymeExistence() {
$info = array('nom' => 'basionyme -> existence',
'description' => "Si le champ basionyme contient un nombre alors il doit correspondre à une valeur du champ ".
"num_nom.",
599,9 → 630,9
// Réalisation du test
$noms_erreur = array();
foreach ($noms as $nom) {
foreach ($this->noms as &$nom) {
if ($nom['basionyme'] != '') {
if (!isset($noms[$nom['basionyme']])) {
if (!isset($this->noms[$nom['basionyme']])) {
$noms_erreur[] = array($nom['num_nom'], $nom['basionyme']);
}
}
614,11 → 645,12
} else {
$info['resultat'] = true;
}
$noms_erreur = null;
$this->traiterResultatTest($info);
}
private function testerBasionymeSyntaxe($noms) {
private function testerBasionymeSyntaxe() {
$info = array('nom' => 'basionyme -> syntaxe',
'description' => "Le champ basionyme contient :\n".
" - un nombre ou une valeur vide.\n",
626,7 → 658,7
// Réalisation du test
$noms_erreur = array();
foreach ($noms as $nom) {
foreach ($this->noms as &$nom) {
if ($nom['basionyme'] != '') {
if (!$this->verifierNombre($nom['basionyme'])) {
$noms_erreur[] = array($nom['num_nom'], $nom['basionyme']);
641,19 → 673,22
} else {
$info['resultat'] = true;
}
$noms_erreur = null;
$this->traiterResultatTest($info);
}
private function testerHomonymieExistence($noms, $noms_homonymie) {
private function testerHomonymieExistence() {
$info = array('nom' => 'homonyme -> existence',
'description' => "Si le champ homonyme contient «1» alors plusieurs noms doivent posséder la même valeur ".
"dans le champ nom_complet.",
'resultat' => false);
$noms_homonymie = $this->classerNomsParNomComplet();
// Réalisation du test
$noms_erreur = array();
foreach ($noms as $nom) {
foreach ($this->noms as &$nom) {
if ($nom['homonyme'] != '0' && $nom['homonyme'] != '') {
if ($noms_homonymie[$nom['nom_complet']] <= 1) {
$noms_erreur[] = array($nom['num_nom'], $nom['nom_complet']);
660,6 → 695,7
}
}
}
$noms_homonymie = null;
// Analyse des résultats
if (count($noms_erreur) > 0) {
668,11 → 704,12
} else {
$info['resultat'] = true;
}
$noms_erreur = null;
$this->traiterResultatTest($info);
}
private function testerHomonymieSyntaxe($noms) {
private function testerHomonymieSyntaxe() {
$info = array('nom' => 'homonyme -> syntaxe',
'description' => "Le champ homonyme contient :\n".
" - le chiffre 1 ou une valeur vide.\n",
680,7 → 717,7
// Réalisation du test
$noms_erreur = array();
foreach ($noms as $nom) {
foreach ($this->noms as &$nom) {
if ($nom['homonyme'] != '') {
if (!$this->verifierBooleen($nom['homonyme'])) {
$noms_erreur[] = array($nom['num_nom'], $nom['homonyme']);
695,11 → 732,12
} else {
$info['resultat'] = true;
}
$noms_erreur = null;
$this->traiterResultatTest($info);
}
private function testerBiblioOrigineSyntaxe($noms) {
private function testerBiblioOrigineSyntaxe() {
$info = array('nom' => 'biblio_origine -> syntaxe',
'description' => "Le champ biblio_origine se compose de plusieurs parties séparées par des caractères ".
"précis qui sont dans l'ordre de gauche à droite :\n".
720,7 → 758,7
// Réalisation du test
$noms_erreur = array();
foreach ($noms as $nom) {
foreach ($this->noms as &$nom) {
if ($nom['biblio_origine'] != '') {
if (!$this->verifierBiblioOrigine($nom['biblio_origine'])) {
$biblio_traite = $this->repererEspace($nom['biblio_origine']);
736,11 → 774,12
} else {
$info['resultat'] = true;
}
$noms_erreur = null;
$this->traiterResultatTest($info);
}
private function testerAnneeSyntaxe($noms) {
private function testerAnneeSyntaxe() {
$info = array('nom' => 'annee -> syntaxe',
'description' => "Le champ annee doit :\n".
" - contenir un nombre de 4 chiffre\n".
749,7 → 788,7
// Réalisation du test
$noms_erreur = array();
foreach ($noms as $nom) {
foreach ($this->noms as &$nom) {
if ($nom['annee'] != '') {
if (!$this->verifierAnnee($nom['annee'])) {
$noms_erreur[] = array($nom['num_nom'], $nom['annee']);
764,11 → 803,12
} else {
$info['resultat'] = true;
}
$noms_erreur = null;
$this->traiterResultatTest($info);
}
private function testerAuteurSyntaxe($noms) {
private function testerAuteurSyntaxe() {
$info = array('nom' => 'auteur -> syntaxe',
'description' => "Le champ auteur doit :\n".
" - contenir l'intitulé complet des noms de l'auteur ou des auteurs ayant publiés à l'origine la combinaison latine courante.\n".
784,7 → 824,7
// Réalisation du test
$noms_erreur = array();
foreach ($noms as $nom) {
foreach ($this->noms as &$nom) {
if ($nom['auteur'] != '') {
if (!$this->verifierAuteur($nom['auteur'])) {
$intitule_traite = $this->repererEspace($nom['auteur']);
800,11 → 840,12
} else {
$info['resultat'] = true;
}
$noms_erreur = null;
$this->traiterResultatTest($info);
}
private function testerNomCommercialSyntaxe($noms) {
private function testerNomCommercialSyntaxe() {
$info = array('nom' => 'nom_commercial -> syntaxe',
'description' => "Le champ nom_commercial doit contenir un nom commercial conforme aux règles du ".
"Code Internationnal de Nomenclature des Plantes Cultivées (CINPC) ".
813,7 → 854,7
// Réalisation du test
$noms_erreur = array();
foreach ($noms as $nom) {
foreach ($this->noms as &$nom) {
if ($nom['nom_commercial'] != '') {
if (!$this->verifierNomCommercial($nom['nom_commercial'])) {
$epithete_traite = $this->repererEspace($nom['nom_commercial']);
829,11 → 870,12
} else {
$info['resultat'] = true;
}
$noms_erreur = null;
$this->traiterResultatTest($info);
}
private function testerNomCommercialPresenceCultivar($noms) {
private function testerNomCommercialPresenceCultivar() {
$info = array('nom' => 'nom_commercial -> groupe_cultivar OU cultivar non vide',
'description' => "Si le champ nom_commercial contier un nom commercial alors le champ cultivar OU ".
"cultivar_groupe ne doit pas être vide.",
841,8 → 883,8
// Réalisation du test
$noms_erreur = array();
foreach ($noms as $nom) {
if ($nom['nom_commercial'] != '' && ($nom['cultivar'] == '' && $nom['cultivar_groupe'] == '')) {
foreach ($this->noms as &$nom) {
if ((isset($nom['nom_commercial']) && $nom['nom_commercial'] != '') && ($nom['cultivar'] == '' && $nom['cultivar_groupe'] == '')) {
$noms_erreur[] = array($nom['num_nom'], $nom['nom_complet']);
}
}
854,11 → 896,12
} else {
$info['resultat'] = true;
}
$noms_erreur = null;
$this->traiterResultatTest($info);
}
private function testerCultivarSyntaxe($noms) {
private function testerCultivarSyntaxe() {
$info = array('nom' => 'cultivar -> syntaxe',
'description' => "Le champ cultivar_groupe doit contenir :\n".
" - un nom de cultivar conforme aux règles du Code Internationnal de Nomenclature des Plantes ".
874,7 → 917,7
// Réalisation du test
$noms_erreur = array();
foreach ($noms as $nom) {
foreach ($this->noms as &$nom) {
if ($nom['cultivar'] != '') {
if (!$this->verifierEpitheteCultivar($nom['cultivar'])) {
$epithete_traite = $this->repererEspace($nom['cultivar']);
890,11 → 933,12
} else {
$info['resultat'] = true;
}
$noms_erreur = null;
$this->traiterResultatTest($info);
}
private function testerCultivarRang($noms) {
private function testerCultivarRang() {
$info = array('nom' => "cultivar -> rang >= {$this->manuel['rang_genre']}",
'description' => "Si le champ cultivar n'est pas vide alors le rang du nom doit être supérieur ou égal à {$this->manuel['rang_genre']}.",
'resultat' => false);
901,7 → 945,7
// Réalisation du test
$noms_erreur = array();
foreach ($noms as $nom) {
foreach ($this->noms as &$nom) {
if ($nom['cultivar'] != '') {
if ($nom['rang'] < $this->manuel['rang_genre']) {
$noms_erreur[] = array($nom['num_nom'], $nom['nom_complet'], $nom['rang']);
916,11 → 960,12
} else {
$info['resultat'] = true;
}
$noms_erreur = null;
$this->traiterResultatTest($info);
}
private function testerGroupeCultivarSyntaxe($noms) {
private function testerGroupeCultivarSyntaxe() {
$info = array('nom' => 'cultivar_groupe -> syntaxe',
'description' => "Le champ cultivar_groupe doit contenir un nom de groupe de cultivar conforme aux règles ".
"du code des plantes cultivées qui se compose de caractères alphanumériques (A-Z,a-z et 0-9) incluant ".
931,7 → 976,7
// Réalisation du test
$noms_erreur = array();
foreach ($noms as $nom) {
foreach ($this->noms as &$nom) {
if ($nom['cultivar_groupe'] != '') {
if (!$this->verifierEpitheteGroupeCultivar($nom['cultivar_groupe'])) {
$epithete_traite = $this->repererEspace($nom['cultivar_groupe']);
947,11 → 992,12
} else {
$info['resultat'] = true;
}
$noms_erreur = null;
$this->traiterResultatTest($info);
}
private function testerGroupeCultivarRang($noms) {
private function testerGroupeCultivarRang() {
$info = array('nom' => "cultivar_groupe -> rang >= {$this->manuel['rang_genre']}",
'description' => "Si le champ cultivar_groupe n'est pas vide alors le rang du nom doit être supérieur ou égal à {$this->manuel['rang_genre']}.",
'resultat' => false);
958,7 → 1004,7
// Réalisation du test
$noms_erreur = array();
foreach ($noms as $nom) {
foreach ($this->noms as &$nom) {
if ($nom['cultivar_groupe'] != '') {
if ($nom['rang'] < $this->manuel['rang_genre']) {
$noms_erreur[] = array($nom['num_nom'], $nom['nom_complet'], $nom['rang']);
973,11 → 1019,12
} else {
$info['resultat'] = true;
}
$noms_erreur = null;
$this->traiterResultatTest($info);
}
private function testerEpitheteInfraSpEspaces($noms) {
private function testerEpitheteInfraSpEspaces() {
$info = array('nom' => 'epithete_infra_sp -> espaces en trop',
'description' => "Le champ epithete_infra_sp ne doit pas contenir d'espace avant ou aprés le nom.\n".
"Si des espaces sont compris dans la valeur du champ, il ne doit pas y avoir plusieurs espaces consécutifs.",
985,7 → 1032,7
// Réalisation du test
$noms_erreur = array();
foreach ($noms as $nom) {
foreach ($this->noms as &$nom) {
if ($nom['epithete_infra_sp'] != '') {
if (preg_match('/(?:^\s+(?!:\s+)|(?!:\s+)\s{2,}(?!:\s+)|(?!:\s+)\s+$)/', $nom['epithete_infra_sp'])) {
$epithete_traite = $this->repererEspace($nom['epithete_infra_sp']);
1001,11 → 1048,12
} else {
$info['resultat'] = true;
}
$noms_erreur = null;
$this->traiterResultatTest($info);
}
private function testerEpitheteInfraSpSyntaxe($noms) {
private function testerEpitheteInfraSpSyntaxe() {
$info = array('nom' => 'epithete_infra_sp -> syntaxe',
'description' => "Le champ epithete_infra_sp peut contenir :\n".
" - un mot unique composé de lettres minuscules avec ou sans tréma (¨) et de tirets (-). \n".
1017,7 → 1065,7
// Réalisation du test
$noms_erreur = array();
foreach ($noms as $nom) {
foreach ($this->noms as &$nom) {
if ($nom['epithete_infra_sp'] != '') {
$mots = explode(' ', $nom['epithete_infra_sp']);
foreach ($mots as $mot) {
1036,11 → 1084,12
} else {
$info['resultat'] = true;
}
$noms_erreur = null;
$this->traiterResultatTest($info);
}
private function testerEpitheteInfraSpRang($noms) {
private function testerEpitheteInfraSpRang() {
$info = array('nom' => "epithete_infra_sp -> rang > {$this->manuel['rang_sp']}",
'description' => "Si le champ epithete_infra_sp n'est pas vide alors le rang du nom doit être supérieur à {$this->manuel['rang_sp']}.",
'resultat' => false);
1047,7 → 1096,7
// Réalisation du test
$noms_erreur = array();
foreach ($noms as $nom) {
foreach ($this->noms as &$nom) {
if ($nom['epithete_infra_sp'] != '') {
if ($nom['rang'] < $this->manuel['rang_sp']) {
$noms_erreur[] = array($nom['num_nom'], $nom['nom_complet'], $nom['rang']);
1062,11 → 1111,12
} else {
$info['resultat'] = true;
}
$noms_erreur = null;
$this->traiterResultatTest($info);
}
private function testerTypeEpitheteEspaces($noms) {
private function testerTypeEpitheteEspaces() {
$info = array('nom' => 'type_epithete -> espaces en trop',
'description' => "Le champ type_epithete ne doit pas contenir d'espace.",
'resultat' => false);
1073,7 → 1123,7
// Réalisation du test
$noms_erreur = array();
foreach ($noms as $nom) {
foreach ($this->noms as &$nom) {
if ($nom['type_epithete'] != '') {
if (preg_match('/\s+/', $nom['type_epithete'])) {
$valeur_traitee = $this->repererEspace($nom['epithete_sp']);
1093,7 → 1143,7
$this->traiterResultatTest($info);
}
private function testerTypeEpitheteSyntaxe($noms) {
private function testerTypeEpitheteSyntaxe() {
$info = array('nom' => 'type_epithete -> syntaxe',
'description' => "Le champ type_epithete doit contenir un mot unique composé de lettres minuscules sans ".
" accents et de tirets (-). Il commence par une lettre minuscule sans accent.",
1101,7 → 1151,7
// Réalisation du test
$noms_erreur = array();
foreach ($noms as $nom) {
foreach ($this->noms as &$nom) {
if ($nom['type_epithete'] != '') {
if (!$this->verifierTypeEpithete($nom['type_epithete'])) {
$noms_erreur[] = array($nom['num_nom'], $nom['type_epithete']);
1120,7 → 1170,7
$this->traiterResultatTest($info);
}
private function testerTypeEpitheteHybridite($noms) {
private function testerTypeEpitheteHybridite() {
$info = array('nom' => 'type_epithete -> hybridité',
'description' => "Le champ type_epithete ne doit pas contenir de préfixe indiquant l'hybridité comme : \n".
" - «n-» \n".
1129,7 → 1179,7
// Réalisation du test
$noms_erreur = array();
foreach ($noms as $nom) {
foreach ($this->noms as &$nom) {
if ($nom['type_epithete'] != '') {
if (preg_match('/^(?:n-|notho-)/', $nom['type_epithete'])) {
$noms_erreur[] = array($nom['num_nom'], $nom['type_epithete']);
1159,6 → 1209,7
$info['resultat'] = true;
}
$this->traiterResultatTest($info);
return ($info['resultat'] ? '1' : '0');
}
private function testerNomDesChamps($colonnes) {
1186,6 → 1237,7
}
$this->traiterResultatTest($info);
return ($info['resultat'] ? '1' : '0');
}
private function testerTypeDesChamps($colonnes) {
1225,6 → 1277,7
}
$this->traiterResultatTest($info);
return ($info['resultat'] ? '1' : '0');
}
private function testerTailleDesChamps($colonnes, $analyses) {
1281,9 → 1334,10
}
$this->traiterResultatTest($info);
return ($info['resultat'] ? '1' : '0');
}
private function testerNumNomSuperieurAZero($noms) {
private function testerNumNomSuperieurAZero() {
$info = array('nom' => 'num_nom -> supérieur à 0',
'description' => "Le champ num_nom doit contenir des nombres entiers supérieurs à 0.",
'resultat' => false);
1290,7 → 1344,7
// Réalisation du test
$noms_erreur = array();
foreach ($noms as $nom) {
foreach ($this->noms as &$nom) {
if ($nom['num_nom'] <= 0) {
$noms_erreur[] = $nom['num_nom'];
}
1306,7 → 1360,7
$this->traiterResultatTest($info);
}
private function testerNumNomRetenuSuperieurAZero($noms) {
private function testerNumNomRetenuSuperieurAZero() {
$info = array('nom' => 'num_nom_retenu -> supérieur à 0',
'description' => "Le champ num_nom_retenu doit contenir des nombres entiers supérieurs à 0 ou être vide.",
'resultat' => false);
1313,7 → 1367,7
// Réalisation du test
$noms_erreur = array();
foreach ($noms as $nom) {
foreach ($this->noms as &$nom) {
if ($nom['num_nom_retenu'] != '' && $nom['num_nom_retenu'] <= 0) {
$noms_erreur[] = $nom['num_nom'];
}
1329,7 → 1383,7
$this->traiterResultatTest($info);
}
private function testerNumTaxSupEgalZeroUnique($noms) {
private function testerNumTaxSupEgalZeroUnique() {
$info = array('nom' => 'num_tax_sup -> égal à 0 unique',
'description' => "Un seul enregistrement doit posséder la valeur 0 dans le champ num_tax_sup. Il correspond au premier taxon de la classification.",
'resultat' => false);
1336,7 → 1390,7
// Réalisation du test
$noms_erreur = array();
foreach ($noms as $nom) {
foreach ($this->noms as &$nom) {
if (preg_match('/^0$/', $nom['num_tax_sup'])) {
$noms_erreur[] = $nom['num_nom'];
}
1352,7 → 1406,7
$this->traiterResultatTest($info);
}
private function testerTaxSupPourTaxon($noms) {
private function testerTaxSupPourTaxon() {
$info = array('nom' => 'Classification -> uniquement pour les taxons',
'description' => "Seul les enregistrements représentant un taxon doivent posséder une valeur dans le champ num_tax_sup.\n".
"Si num_nom_retenu est différent de num_nom (= nom synonyme) alors num_tax_sup doit être vide.",
1360,7 → 1414,7
// Réalisation du test
$noms_erreur = array();
foreach ($noms as $nom) {
foreach ($this->noms as &$nom) {
if ($nom['num_nom_retenu'] != $nom['num_nom'] && $nom['num_tax_sup'] != '') {
$noms_erreur[] = $nom['num_nom'];
}
1376,7 → 1430,7
$this->traiterResultatTest($info);
}
private function testerExitenceTaxonSuperieur($noms) {
private function testerExitenceTaxonSuperieur() {
$info = array('nom' => 'Classification -> existence du taxon supérieur',
'description' => "Pour chaque enregistrement représentant un taxon doit posséder un taxon supérieur sauf la racine de la classification.",
'resultat' => false);
1383,9 → 1437,9
// Réalisation du test
$noms_erreur = array();
foreach ($noms as $nom) {
foreach ($this->noms as &$nom) {
if ($nom['num_nom_retenu'] == $nom['num_nom']) {
if ($nom['num_tax_sup'] != 0 && !isset($noms[$nom['num_tax_sup']])) {
if ($nom['num_tax_sup'] != 0 && !isset($this->noms[$nom['num_tax_sup']])) {
$noms_erreur[] = $nom['num_nom'];
}
}
1401,7 → 1455,7
$this->traiterResultatTest($info);
}
private function testerClassificationRang($noms) {
private function testerClassificationRang() {
$info = array('nom' => 'Classification -> taxon supérieur avec rang inférieur',
'description' => "Pour chaque enregistrement représentant un taxon, chaque taxon supérieur doit avoir un rang inférieur au taxon courant.",
'resultat' => false);
1408,10 → 1462,10
// Réalisation du test
$noms_erreur = array();
foreach ($noms as $nom) {
foreach ($this->noms as &$nom) {
if ($nom['num_nom_retenu'] == $nom['num_nom']) {
if (isset($noms[$nom['num_tax_sup']])) {
$nom_sup = $noms[$nom['num_tax_sup']];
if (isset($this->noms[$nom['num_tax_sup']])) {
$nom_sup = $this->noms[$nom['num_tax_sup']];
if ($nom_sup['rang'] > $nom['rang']) {
$noms_erreur[] = $nom['num_nom'];
}
1429,7 → 1483,7
$this->traiterResultatTest($info);
}
private function testerClassification($noms) {
private function testerClassification() {
$info = array('nom' => 'Classification -> racine liée à chaque noeud',
'description' => "Pour chaque enregistrement, la classification doit pouvoir être remonté jusqu'à un même nom unique possédant une valeur num_tax_sup de 0.",
'resultat' => false);
1436,9 → 1490,9
// Réalisation du test
$noms_erreur = array();
foreach ($noms as $nom) {
foreach ($this->noms as &$nom) {
if ($nom['num_nom_retenu'] == $nom['num_nom']) {
$classif_ok = $this->remonterClassif($noms, $nom);
$classif_ok = $this->remonterClassif($nom);
if ($classif_ok === false) {
$noms_erreur[] = $nom['num_nom'];
}
1455,17 → 1509,21
$this->traiterResultatTest($info);
}
private function remonterClassif(&$noms, $nom) {
if (!isset($noms[$nom['num_tax_sup']]) && $nom['num_tax_sup'] == '0') {
return true;
} else if (!isset($noms[$nom['num_tax_sup']]) && $nom['num_tax_sup'] != '0') {
private function remonterClassif($nom) {
if (is_int($nom['num_tax_sup'])) {
if (!isset($this->noms[$nom['num_tax_sup']]) && $nom['num_tax_sup'] == '0') {
return true;
} else if (!isset($this->noms[$nom['num_tax_sup']]) && $nom['num_tax_sup'] != '0') {
return false;
} else {
return $this->remonterClassif($this->noms[$nom['num_tax_sup']]);
}
} else {
return false;
} else {
return $this->remonterClassif($noms, $noms[$nom['num_tax_sup']]);
}
}
private function testerRang($noms) {
private function testerRang() {
$info = array('nom' => 'rang',
'description' => "Le rang doit correspondre à un valeur numérique définit dans le manuel.",
'resultat' => false);
1474,7 → 1532,7
// Réalisation du test
$noms_erreur = array();
foreach ($noms as $nom) {
foreach ($this->noms as &$nom) {
if (!isset($rangs[$nom['rang']])) {
$noms_erreur[] = $nom['num_nom'];
}
1490,7 → 1548,7
$this->traiterResultatTest($info);
}
private function testerNomCompletSupraGenerique($noms) {
private function testerNomCompletSupraGenerique() {
$info = array('nom' => 'nom_complet -> noms supra-génériques',
'description' => "Si le rang est < à {$this->manuel['rang_genre']} le nom_complet doit correspondre à la valeur du champ nom_supra_generique. ".
"Les valeurs des champs cultivar_groupe, cultivar et nom_commercial peuvent s'y ajouter.",
1498,7 → 1556,7
// Réalisation du test
$noms_erreur = array();
foreach ($noms as $nom) {
foreach ($this->noms as &$nom) {
if ($nom['rang'] < $this->manuel['rang_genre']) {
$suffixe_plte_cultivee = $this->construireSuffixeNomPltCultivee($nom);
$nom_complet_ideal = $this->formaterStyleNomGenre($nom['nom_supra_generique']);
1521,7 → 1579,7
$this->traiterResultatTest($info);
}
private function testerNomCompletGenre($noms) {
private function testerNomCompletGenre() {
$info = array('nom' => 'nom_complet -> noms de genres',
'description' => "Si le rang est = à {$this->manuel['rang_genre']} le nom_complet doit correspondre à la valeur du champ genre. ".
"Les valeurs des champs cultivar_groupe, cultivar et nom_commercial peuvent s'y ajouter.",
1529,7 → 1587,7
// Réalisation du test
$noms_erreur = array();
foreach ($noms as $nom) {
foreach ($this->noms as &$nom) {
if ($nom['rang'] == $this->manuel['rang_genre']) {
$suffixe_plte_cultivee = $this->construireSuffixeNomPltCultivee($nom);
$nom_complet_ideal = $this->formaterStyleNomGenre($nom['genre']);
1552,7 → 1610,7
$this->traiterResultatTest($info);
}
private function testerNomCompletInfraGenre($noms) {
private function testerNomCompletInfraGenre() {
$info = array('nom' => 'nom_complet -> noms infra-génériques',
'description' => "Si le rang est > à {$this->manuel['rang_genre']} et < à {$this->manuel['rang_sp']} le nom_complet doit correspondre à une des formules suivantes : \n".
" genre + ' ' + type_epithete + ' ' + epithete_infra_generique \n".
1562,7 → 1620,7
// Réalisation du test
$noms_erreur = array();
foreach ($noms as $nom) {
foreach ($this->noms as &$nom) {
if ($nom['rang'] > $this->manuel['rang_genre'] && $nom['rang'] < $this->manuel['rang_sp']) {
$suffixe_plte_cultivee = $this->construireSuffixeNomPltCultivee($nom);
$nom_complet_ideal = '';
1590,11 → 1648,12
} else {
$info['resultat'] = true;
}
$noms_erreur = null;
$this->traiterResultatTest($info);
}
private function testerNomCompletEspece($noms) {
private function testerNomCompletEspece() {
$info = array('nom' => "nom_complet -> noms d'espèce",
'description' => "Si le rang est = à {$this->manuel['rang_sp']} le nom_complet doit correspondre à la formule : \n".
" genre + ' ' + epithete_sp \n".
1603,7 → 1662,7
// Réalisation du test
$noms_erreur = array();
foreach ($noms as $nom) {
foreach ($this->noms as &$nom) {
if ($nom['rang'] == $this->manuel['rang_sp']) {
$suffixe_plte_cultivee = $this->construireSuffixeNomPltCultivee($nom);
$nom_complet_ideal = $this->formaterStyleNomGenre($nom['genre']);
1623,11 → 1682,12
} else {
$info['resultat'] = true;
}
$noms_erreur = null;
$this->traiterResultatTest($info);
}
private function testerNomCompletInfraSpecifique($noms) {
private function testerNomCompletInfraSpecifique() {
$info = array('nom' => 'nom_complet -> noms infra-spécifiques',
'description' => "Si le rang est > à {$this->manuel['rang_sp']} le nom_complet doit correspondre à la formule : \n".
" genre + ' ' + epithete_sp + ' ' + type_epithete + ' ' + epithete_infra_generique\n".
1636,7 → 1696,7
// Réalisation du test
$noms_erreur = array();
foreach ($noms as $nom) {
foreach ($this->noms as &$nom) {
if ($nom['rang'] > $this->manuel['rang_sp']) {
$suffixe_plte_cultivee = $this->construireSuffixeNomPltCultivee($nom);
$nom_complet_ideal = $this->formaterStyleNomGenre($nom['genre']);
1658,11 → 1718,12
} else {
$info['resultat'] = true;
}
$noms_erreur = null;
$this->traiterResultatTest($info);
}
private function testerNomSupraGeneriqueEspaces($noms) {
private function testerNomSupraGeneriqueEspaces() {
$info = array('nom' => 'nom_supra_generique -> espaces en trop',
'description' => "Le champ nom_supra_generique ne doit pas contenir d'espace avant ou aprés le nom.",
'resultat' => false);
1669,7 → 1730,7
// Réalisation du test
$noms_erreur = array();
foreach ($noms as $nom) {
foreach ($this->noms as &$nom) {
if ($nom['nom_supra_generique'] != '') {
if (preg_match('/(?:^\s+(?!:\s+)|(?!:\s+)\s+$)/', $nom['nom_supra_generique'])) {
$nom_supra_generique_traite = $this->repererEspace($nom['nom_supra_generique']);
1685,11 → 1746,12
} else {
$info['resultat'] = true;
}
$noms_erreur = null;
$this->traiterResultatTest($info);
}
private function testerNomSupraGeneriqueSyntaxe($noms) {
private function testerNomSupraGeneriqueSyntaxe() {
$info = array('nom' => 'nom_supra_generique -> syntaxe',
'description' => "Le champ nom_supra_generique contient un mot composé de lettres minuscules avec ou sans tréma (¨) et de tirets (-). \n".
"La première lettre (avec ou sans tréma) du mot doit être en majuscule.",
1697,7 → 1759,7
// Réalisation du test
$noms_erreur = array();
foreach ($noms as $nom) {
foreach ($this->noms as &$nom) {
if ($nom['nom_supra_generique'] != '') {
if (!preg_match('/^[A-ZÄËḦÏÖÜẄẌŸ][-a-zäëḧïöẗüẅẍÿ]+$/', $nom['nom_supra_generique'])) {
$nom_supra_generique_traite = $this->repererEspace($nom['nom_supra_generique']);
1713,11 → 1775,12
} else {
$info['resultat'] = true;
}
$noms_erreur = null;
$this->traiterResultatTest($info);
}
private function testerNomSupraGeneriqueRang($noms) {
private function testerNomSupraGeneriqueRang() {
$info = array('nom' => "nom_supra_generique -> rang < {$this->manuel['rang_genre']}",
'description' => "Si le champ nom_supra_generique n'est pas vide alors le rang du nom doit être inférieur à {$this->manuel['rang_genre']}.",
'resultat' => false);
1724,7 → 1787,7
// Réalisation du test
$noms_erreur = array();
foreach ($noms as $nom) {
foreach ($this->noms as &$nom) {
if ($nom['nom_supra_generique'] != '') {
if ($nom['rang'] >= $this->manuel['rang_genre']) {
$noms_erreur[] = array($nom['num_nom'], $nom['nom_complet'], $nom['rang']);
1739,11 → 1802,12
} else {
$info['resultat'] = true;
}
$noms_erreur = null;
$this->traiterResultatTest($info);
}
private function testerGenreEspaces($noms) {
private function testerGenreEspaces() {
$info = array('nom' => 'genre -> espaces en trop',
'description' => "Le champ genre ne doit pas contenir d'espace avant ou aprés le nom.\n".
"Si des espaces sont compris dans la valeur du champ, il ne doit pas y avoir plusieurs espaces consécutifs.",
1751,7 → 1815,7
// Réalisation du test
$noms_erreur = array();
foreach ($noms as $nom) {
foreach ($this->noms as &$nom) {
if ($nom['genre'] != '') {
if (preg_match('/(?:^\s+(?!:\s+)|(?!:\s+)\s{2,}(?!:\s+)|(?!:\s+)\s+$)/', $nom['genre'])) {
$nom_traite = $this->repererEspace($nom['genre']);
1767,11 → 1831,12
} else {
$info['resultat'] = true;
}
$noms_erreur = null;
$this->traiterResultatTest($info);
}
private function testerGenreSyntaxe($noms) {
private function testerGenreSyntaxe() {
$info = array('nom' => 'genre -> syntaxe',
'description' => "Le champ genre peut contenir :\n".
" - un mot unique composé de lettres minuscules avec ou sans tréma (¨) et de tirets (-). \n".
1783,7 → 1848,7
// Réalisation du test
$noms_erreur = array();
foreach ($noms as $nom) {
foreach ($this->noms as &$nom) {
if ($nom['genre'] != '') {
$mots = explode(' ', $nom['genre']);
foreach ($mots as $mot) {
1802,11 → 1867,12
} else {
$info['resultat'] = true;
}
$noms_erreur = null;
$this->traiterResultatTest($info);
}
private function testerGenreRang($noms) {
private function testerGenreRang() {
$info = array('nom' => "genre -> rang >= {$this->manuel['rang_genre']}",
'description' => "Si le champ genre n'est pas vide alors le rang du nom doit être supérieur ou égal à {$this->manuel['rang_genre']}.",
'resultat' => false);
1813,7 → 1879,7
// Réalisation du test
$noms_erreur = array();
foreach ($noms as $nom) {
foreach ($this->noms as &$nom) {
if ($nom['genre'] != '') {
if ($nom['rang'] < $this->manuel['rang_genre']) {
$noms_erreur[] = array($nom['num_nom'], $nom['nom_complet'], $nom['rang']);
1828,11 → 1894,12
} else {
$info['resultat'] = true;
}
$noms_erreur = null;
$this->traiterResultatTest($info);
}
private function testerEpitheteInfraGeneriqueSyntaxe($noms) {
private function testerEpitheteInfraGeneriqueSyntaxe() {
$info = array('nom' => 'epithete_infra_generique -> syntaxe',
'description' => "Le champ epithete_infra_generique est composé de lettres minuscules avec ou sans tréma (¨) et de tirets (-). \n".
"La première lettre (avec ou sans tréma) doit être en majuscule.",
1840,7 → 1907,7
// Réalisation du test
$noms_erreur = array();
foreach ($noms as $nom) {
foreach ($this->noms as &$nom) {
if ($nom['epithete_infra_generique'] != '') {
if (!preg_match('/^[A-ZÄËḦÏÖÜẄẌŸ][-a-zäëḧïöẗüẅẍÿ]+/', $nom['epithete_infra_generique'])) {
$epithete_traite = $this->repererEspace($nom['epithete_infra_generique']);
1856,11 → 1923,12
} else {
$info['resultat'] = true;
}
$noms_erreur = null;
$this->traiterResultatTest($info);
}
private function testerEpitheteInfraGeneriqueRang($noms) {
private function testerEpitheteInfraGeneriqueRang() {
$info = array('nom' => "epithete_infra_generique -> {$this->manuel['rang_genre']} < rang < {$this->manuel['rang_sp']}",
'description' => "Si le champ epithete_infra_generique n'est pas vide alors le rang du nom doit être compris \n".
"entre {$this->manuel['rang_genre']} et {$this->manuel['rang_sp']}.",
1868,7 → 1936,7
// Réalisation du test
$noms_erreur = array();
foreach ($noms as $nom) {
foreach ($this->noms as &$nom) {
if ($nom['epithete_infra_generique'] != '') {
if ($nom['rang'] <= $this->manuel['rang_genre'] || $nom['rang'] >= $this->manuel['rang_sp']) {
$noms_erreur[] = array($nom['num_nom'], $nom['nom_complet'], $nom['rang']);
1883,11 → 1951,12
} else {
$info['resultat'] = true;
}
$noms_erreur = null;
$this->traiterResultatTest($info);
}
private function testerEpitheteInfraGeneriqueEspaces($noms) {
private function testerEpitheteInfraGeneriqueEspaces() {
$info = array('nom' => 'epithete_infra_generique -> espaces en trop',
'description' => "Le champ epithete_infra_generique ne doit pas contenir d'espace avant ou aprés sa valeur.",
'resultat' => false);
1894,7 → 1963,7
// Réalisation du test
$noms_erreur = array();
foreach ($noms as $nom) {
foreach ($this->noms as &$nom) {
if ($nom['epithete_infra_generique'] != '') {
if (preg_match('/(?:^\s+(?!:\s+)|(?!:\s+)\s{2,}(?!:\s+)|(?!:\s+)\s+$)/', $nom['epithete_infra_generique'])) {
$epithete_traite = $this->repererEspace($nom['epithete_infra_generique']);
1910,11 → 1979,12
} else {
$info['resultat'] = true;
}
$noms_erreur = null;
$this->traiterResultatTest($info);
}
private function testerEpitheteSpEspaces($noms) {
private function testerEpitheteSpEspaces() {
$info = array('nom' => 'epithete_sp -> espaces en trop',
'description' => "Le champ epithete_sp ne doit pas contenir d'espace avant ou aprés le nom.\n".
"Si des espaces sont compris dans la valeur du champ, il ne doit pas y avoir plusieurs espaces consécutifs.",
1922,7 → 1992,7
// Réalisation du test
$noms_erreur = array();
foreach ($noms as $nom) {
foreach ($this->noms as &$nom) {
if ($nom['epithete_sp'] != '') {
if (preg_match('/(?:^\s+(?!:\s+)|(?!:\s+)\s{2,}(?!:\s+)|(?!:\s+)\s+$)/', $nom['epithete_sp'])) {
$epithete_traite = $this->repererEspace($nom['epithete_sp']);
1938,11 → 2008,12
} else {
$info['resultat'] = true;
}
$noms_erreur = null;
$this->traiterResultatTest($info);
}
private function testerEpitheteSpSyntaxe($noms) {
private function testerEpitheteSpSyntaxe() {
$info = array('nom' => 'epithete_sp -> syntaxe',
'description' => "Le champ epithete_sp peut contenir :\n".
" - un mot unique composé de lettres minuscules [a-z] incluant les caractères [ëï-]. \n".
1955,7 → 2026,7
// Réalisation du test
$noms_erreur = array();
foreach ($noms as $nom) {
foreach ($this->noms as &$nom) {
if ($nom['epithete_sp'] != '') {
$mots = explode(' ', $nom['epithete_sp']);
foreach ($mots as $mot) {
1974,11 → 2045,12
} else {
$info['resultat'] = true;
}
$noms_erreur = null;
$this->traiterResultatTest($info);
}
private function testerEpitheteSpRang($noms) {
private function testerEpitheteSpRang() {
$info = array('nom' => "epithete_sp -> rang >= {$this->manuel['rang_sp']}",
'description' => "Si le champ epithete_sp n'est pas vide alors le rang du nom doit être supérieur ou égal à {$this->manuel['rang_sp']}.",
'resultat' => false);
1985,7 → 2057,7
// Réalisation du test
$noms_erreur = array();
foreach ($noms as $nom) {
foreach ($this->noms as &$nom) {
if ($nom['epithete_sp'] != '') {
if ($nom['rang'] < $this->manuel['rang_sp']) {
$noms_erreur[] = array($nom['num_nom'], $nom['nom_complet'], $nom['rang']);
2000,6 → 2072,7
} else {
$info['resultat'] = true;
}
$noms_erreur = null;
$this->traiterResultatTest($info);
}
2007,31 → 2080,31
//+--------------------------------------------------------------------------------------------------------------+//
// MÉTHODES COMMUNES aux TESTS
private function verifierPresence($valeur) {
private function verifierPresence(&$valeur) {
$codes = $this->manuel['codes_presence'];
$ok = $this->verifierStatuts($valeur, $codes);
return $ok;
}
private function verifierStatutOrigine($valeur) {
private function verifierStatutOrigine(&$valeur) {
$codes = $this->manuel['codes_statuts_origine'];
$ok = $this->verifierStatuts($valeur, $codes);
return $ok;
}
private function verifierStatutIntroduction($valeur) {
private function verifierStatutIntroduction(&$valeur) {
$codes = $this->manuel['codes_statuts_introduction'];
$ok = $this->verifierStatuts($valeur, $codes);
return $ok;
}
private function verifierStatutCulture($valeur) {
private function verifierStatutCulture(&$valeur) {
$codes = $this->manuel['codes_statuts_culture'];
$ok = $this->verifierStatuts($valeur, $codes);
return $ok;
}
private function verifierStatuts($valeur, $codes) {
private function verifierStatuts(&$valeur, &$codes) {
$ok = true;
if (!preg_match("/^(?:|-|[$codes](?:-[A-Z])?)$/", $valeur)) {
$ok = false;
2039,7 → 2112,7
return $ok;
}
private function verifierBooleen($valeur) {
private function verifierBooleen(&$valeur) {
$ok = true;
if (!preg_match('/^1$/', $valeur)) {
$ok = false;
2047,7 → 2120,7
return $ok;
}
private function verifierNombre($valeur) {
private function verifierNombre(&$valeur) {
$ok = true;
if (!preg_match('/^[0-9]+$/', $valeur)) {
$ok = false;
2055,7 → 2128,7
return $ok;
}
private function verifierNombreSuite($valeur) {
private function verifierNombreSuite(&$valeur) {
$ok = true;
if (!preg_match('/^(?:[0-9]+,)*[0-9]+$/', $valeur)) {
$ok = false;
2063,7 → 2136,7
return $ok;
}
private function verifierTypeEpithete($type) {
private function verifierTypeEpithete(&$type) {
$ok = false;
$rejetes = $this->manuel['type_epithete_rejetes'];
if (preg_replace("/^(?:$rejetes)$/", '', $type) == '') {
2074,7 → 2147,7
return $ok;
}
private function verifierBiblioOrigine($intitule) {
private function verifierBiblioOrigine(&$intitule) {
$ok = true;
if (preg_match('/(?:^\s+|\s{2,}|\s+$)/', $intitule)) {
$ok = false;// Contient des espaces en trop
2086,7 → 2159,7
return $ok;
}
private function verifierAnnee($annee) {
private function verifierAnnee(&$annee) {
$ok = true;
if (!preg_match('/^[0-9]{4}$/', $annee)) {
$ok = false;
2096,7 → 2169,7
return $ok;
}
private function verifierAuteur($intitule) {
private function verifierAuteur(&$intitule) {
$ok = true;
$acceptes = $this->manuel['auteur_acceptes'];
if (!preg_match("/^(?:$acceptes)$/", $intitule)) {
2119,7 → 2192,7
return $ok;
}
private function verifierNomCommercial($epithete) {
private function verifierNomCommercial(&$epithete) {
$ok = false;
if (preg_match("/^[[:upper:][:punct:][:digit:][:space:]]+$/", $epithete)) {
$ok = true;
2127,7 → 2200,7
return $ok;
}
private function verifierEpitheteCultivar($epithete) {
private function verifierEpitheteCultivar(&$epithete) {
$ok = true;
$acceptes = $this->manuel['cultivar_acceptes'];
if (!preg_match("/^(?:$acceptes)$/", $epithete)) {
2162,7 → 2235,7
return $ok;
}
private function verifierEpitheteGroupeCultivar($epithete) {
private function verifierEpitheteGroupeCultivar(&$epithete) {
$ok = true;
$acceptes = $this->manuel['cultivar_gp_acceptes'];
if (!preg_match("/^(?:$acceptes)$/", $epithete)) {
2200,7 → 2273,7
return $ok;
}
private function verifierEpitheteSp($epithete) {
private function verifierEpitheteSp(&$epithete) {
$ok = false;
if (preg_match('/^[a-zëï][-a-zëï]+$/', $epithete)) {
$ok = true;
2210,7 → 2283,7
return $ok;
}
private function verifierEpitheteGenre($epithete) {
private function verifierEpitheteGenre(&$epithete) {
$ok = false;
if (preg_match('/^[A-ZËÏ](?:[-a-zëï]+|[a-zëï]+-[A-ZËÏ][a-zëï]+)$/', $epithete)) {
$ok = true;
2218,7 → 2291,7
return $ok;
}
private function formaterStyleNomGenre($genre) {
private function formaterStyleNomGenre(&$genre) {
$genre_fmt = '';
if (preg_match('/^\s*([x+])\s+(.+)$/i', $genre, $match)) {
$genre_fmt = strtolower($match[1]).' '.ucfirst(strtolower($match[2]));
2233,7 → 2306,7
return $nom_complet;
}
private function construireSuffixeNomPltCultivee($nom) {
private function construireSuffixeNomPltCultivee(&$nom) {
$suffixe = array();
$suffixe[] = $this->construireNomCultivarGroupe($nom);
$suffixe[] = $this->construireNomCommercial($nom);
2242,7 → 2315,7
return implode(' ', $suffixe);
}
private function construireNomCultivarGroupe($nom) {
private function construireNomCultivarGroupe(&$nom) {
$nom_groupe_cultivar = '';
if ($nom['cultivar_groupe'] != '') {
if (preg_match('/ gx$/', $nom['cultivar_groupe'])) {
2254,7 → 2327,7
return $nom_groupe_cultivar;
}
private function construireNomCommercial($nom) {
private function construireNomCommercial(&$nom) {
$nom_commercial = '';
if ($nom['nom_commercial'] != '') {
$nom_commercial = strtoupper($nom['nom_commercial']);
2262,7 → 2335,7
return $nom_commercial;
}
private function construireNomCultivar($nom) {
private function construireNomCultivar(&$nom) {
$nom_cultivar = '';
if ($nom['cultivar'] != '') {
$nom_cultivar = "'".$nom['cultivar']."'";
2270,17 → 2343,9
return $nom_cultivar;
}
private function classerNomsParNumNom($noms) {
private function classerNomsParNomComplet() {
$noms_classes = array();
foreach ($noms as $nom) {
$noms_classes[$nom['num_nom']] = $nom;
}
return $noms_classes;
}
private function classerNomsParNomComplet($noms) {
$noms_classes = array();
foreach ($noms as $nom) {
foreach ($this->noms as &$nom) {
if (!isset($noms_classes[$nom['nom_complet']])) {
$noms_classes[$nom['nom_complet']] = 1;
} else {