200 |
jpm |
1 |
<?php
|
|
|
2 |
require_once dirname(__FILE__).'/../ServicePhpUnit.php';
|
|
|
3 |
|
|
|
4 |
class NomDetailsBdtfxTest extends ServicePhpUnit {
|
|
|
5 |
|
|
|
6 |
private $nomDetailSqueletteUrl = 'http://localhost/service:eflore:0.1/bdtfx/noms/%s';
|
|
|
7 |
private $ontologieHrefTpl = 'http://localhost/service:eflore:0.1/bdnt/ontologies/rangTaxo:%s';
|
|
|
8 |
private $champsProjet = array(
|
203 |
jpm |
9 |
'presence_Ga' => 'presence_Ga.code',
|
|
|
10 |
'presence_Co' => 'presence_Co.code'
|
|
|
11 |
);
|
200 |
jpm |
12 |
|
|
|
13 |
public function __construct() {
|
203 |
jpm |
14 |
$this->projet = 'bdtfx';
|
200 |
jpm |
15 |
$this->service = 'noms';
|
203 |
jpm |
16 |
$this->classeTestee = 'NomDetailsBdtfx';
|
200 |
jpm |
17 |
}
|
|
|
18 |
|
|
|
19 |
public function initialiserService(NomsListe $service) {
|
|
|
20 |
$service->setDetailsHrefTpl($this->nomDetailSqueletteUrl);
|
|
|
21 |
$service->setOntologieHrefTpl($this->ontologieHrefTpl);
|
203 |
jpm |
22 |
$service->setChampsProjet($this->champsProjet);
|
200 |
jpm |
23 |
}
|
|
|
24 |
|
|
|
25 |
public function testSansParametres() {
|
|
|
26 |
$ressources = array('85');
|
|
|
27 |
$parametres = array();
|
|
|
28 |
|
|
|
29 |
$retour = $this->consulterBrut($ressources, $parametres);
|
|
|
30 |
|
|
|
31 |
$this->assertTrue(is_array($retour), 'Retour est un tableau');
|
|
|
32 |
$this->assertArrayHasKey('id', $retour, 'Présence champ id');
|
|
|
33 |
$this->assertSame(85, $retour['id'], 'Valeur champ id = 85');
|
|
|
34 |
$this->assertArrayHasKey('nom_sci', $retour, 'Présence champ nom_sci');
|
203 |
jpm |
35 |
|
|
|
36 |
$this->assertSame('Abutilon theophrasti', $retour['nom_sci'], 'Valeur champ nom_sci = Abutilon theophrasti');
|
200 |
jpm |
37 |
$this->assertArrayHasKey('nom_retenu.id', $retour, 'Présence champ nom_retenu.id');
|
203 |
jpm |
38 |
$this->assertSame(85, $retour['nom_retenu.id'], 'Valeur champ nom_sci = 85');
|
200 |
jpm |
39 |
$this->assertArrayHasKey('nom_retenu', $retour, 'Présence champ nom_retenu');
|
203 |
jpm |
40 |
$this->assertSame('Abutilon theophrasti', $retour['nom_retenu'], 'Valeur champ nom_retenu = Abutilon theophrasti');
|
200 |
jpm |
41 |
$this->assertArrayHasKey('nom_retenu.href', $retour, 'Présence champ nom_retenu.href');
|
203 |
jpm |
42 |
$urlNomRetenuHrefAttendue = sprintf($this->nomDetailSqueletteUrl, 85);
|
200 |
jpm |
43 |
$this->assertSame($urlNomRetenuHrefAttendue, $retour['nom_retenu.href'], "Valeur champ nom_retenu.href = $urlNomRetenuHrefAttendue");
|
|
|
44 |
|
|
|
45 |
$this->assertArrayHasKey('rang.code', $retour, 'Présence champ rang.code');
|
|
|
46 |
$this->assertSame('bdnt.rangTaxo:290', $retour['rang.code'], 'Valeur champ rang.code = bdnt.rangTaxo:290');
|
|
|
47 |
$this->assertArrayHasKey('rang', $retour, 'Présence champ rang');
|
|
|
48 |
$this->assertSame('Espèce', $retour['rang'], 'Valeur champ rang = Espèce');
|
|
|
49 |
|
|
|
50 |
$this->assertArrayHasKey('rang.href', $retour, 'Présence champ rang.href');
|
|
|
51 |
$hrefAttendue =sprintf($this->ontologieHrefTpl, 290);
|
|
|
52 |
$this->assertSame($hrefAttendue, $retour['rang.href'], "Valeur champ rang.href = $hrefAttendue");
|
|
|
53 |
|
203 |
jpm |
54 |
$this->assertArrayHasKey('nom_sci.genre', $retour, 'Présence champ nom_sci.genre');
|
|
|
55 |
$this->assertSame('Abutilon', $retour['nom_sci.genre'], "Valeur champ nom_sci.genre = 'Abutilon'");
|
|
|
56 |
$this->assertArrayHasKey('nom_sci.sp', $retour, 'Présence champ nom_sci.sp');
|
|
|
57 |
$this->assertSame('theophrasti', $retour['nom_sci.sp'], "Valeur champ nom_sci.sp = theophrasti");
|
|
|
58 |
|
|
|
59 |
$this->assertArrayHasKey('auteur', $retour, 'Présence champ auteur');
|
|
|
60 |
$this->assertSame('Medik.', $retour['auteur'], "Valeur champ auteur = 'Medik.'");
|
|
|
61 |
|
|
|
62 |
$this->assertArrayHasKey('presence_Ga.code', $retour, 'Présence champ presence_Ga.code'.print_r($retour,true));
|
|
|
63 |
$this->assertSame('P', $retour['presence_Ga.code'], "Valeur champ presence_Ga.code = 'P'");
|
|
|
64 |
$this->assertArrayHasKey('presence_Co.code', $retour, 'Présence champ "presence_Co.code');
|
|
|
65 |
$this->assertSame('P', $retour['presence_Co.code'], "Valeur champ page = P");
|
200 |
jpm |
66 |
}
|
|
|
67 |
|
203 |
jpm |
68 |
public function testNomSansCorrespondance() {
|
|
|
69 |
$ressources = array('98940');
|
|
|
70 |
$parametres = array();
|
|
|
71 |
|
|
|
72 |
$retour = $this->consulterBrut($ressources, $parametres);
|
|
|
73 |
|
|
|
74 |
$this->assertArrayNotHasKey('nom_retenu.id', $retour, 'Abscence champ nom_retenu.id');
|
|
|
75 |
$this->assertArrayHasKey('nom_retenu', $retour, 'Présence champ nom_retenu');
|
|
|
76 |
$this->assertSame(null, $retour['nom_retenu'], 'Valeur champ nom_retenu = null');
|
|
|
77 |
$this->assertArrayNotHasKey('nom_retenu.href', $retour, 'Abscence champ nom_retenu.href');
|
|
|
78 |
}
|
|
|
79 |
|
200 |
jpm |
80 |
}
|
|
|
81 |
?>
|