Subversion Repositories eFlore/Projets.eflore-projets

Compare Revisions

Ignore whitespace Rev 855 → Rev 856

/trunk/services/tests/0.1/coste/CosteNomsTest.php
9,10 → 9,13
 
class CosteNomsTest extends ServiceEflorePhpUnit {
 
static $P = "coste";
static $S = "textes";
 
// test d'obtention d'information sur num_nom connu
public function testRessource() {
$url = ServiceEflorePhpUnit::creerUrl("textes2", array(182));
$retour = $this->consulterJson("textes2", "coste", array(182));
$url = ServiceEflorePhpUnit::creerUrl(self::$S, array(182));
$retour = $this->consulterJson(self::$S, self::$P, array(182));
$this->commonTestHeader($retour, $url);
$this->assertEquals(1, $retour['entete']['total'], "L'attribut 'total' devrait avoir la valeur 1. Voir : $url");
$this->commonTest($retour, $url);
23,8 → 26,8
}
 
public function testBdtfxRessource() {
$url = ServiceEflorePhpUnit::creerUrl("textes2", array("bdtfx.nn:182"));
$retour = $this->consulterJson("textes2", "coste", array("bdtfx.nn:182"));
$url = ServiceEflorePhpUnit::creerUrl(self::$S, array("bdtfx.nn:182"));
$retour = $this->consulterJson(self::$S, self::$P, array("bdtfx.nn:182"));
$this->commonTestHeader($retour, $url);
$this->assertEquals(1, $retour['entete']['total'], "L'attribut 'total' devrait avoir la valeur 1. Voir : $url");
$this->commonTest($retour, $url);
33,28 → 36,28
}
 
public function testNonExistantRessource() {
$url = ServiceEflorePhpUnit::creerUrl("textes2", array("-182"));
$retour = $this->consulterBrut("textes2", "coste", array("-182"));
$url = ServiceEflorePhpUnit::creerUrl(self::$S, array("-182"));
$retour = $this->consulterBrut(self::$S, self::$P, array("-182"));
$this->assertEquals("not supported", $retour, "error. Voir : $url");
}
 
// les critères se cumulent
public function testRessourceEtMasque() {
$url = ServiceEflorePhpUnit::creerUrl("textes2", array(182), array("masque.ns" => "ABC"));
$retour = $this->consulterJson("textes2", "coste", array(182), array("masque.ns" => "ABC"));
$url = ServiceEflorePhpUnit::creerUrl(self::$S, array(182), array("masque.ns" => "ABC"));
$retour = $this->consulterJson(self::$S, self::$P, array(182), array("masque.ns" => "ABC"));
$this->commonTestHeader($retour, $url);
$this->assertEquals(0, $retour['entete']['total'], "L'attribut 'total' devrait avoir la valeur 0. Voir : $url");
}
 
public function testRessourceFormatHTML() {
$url = ServiceEflorePhpUnit::creerUrl("textes2", array(182), array('txt.format' => 'htm'));
$retour = $this->consulterJson("textes2", "coste", array(182), array('txt.format' => 'htm'));
$url = ServiceEflorePhpUnit::creerUrl(self::$S, array(182), array('txt.format' => 'htm'));
$retour = $this->consulterJson(self::$S, self::$P, array(182), array('txt.format' => 'htm'));
$this->assertContains("span class", $retour['resultats']['182']['titre'], "error: ['resultats']['182']['titre']. Voir : $url");
}
 
public function testRessourceChamps() {
$url = ServiceEflorePhpUnit::creerUrl("textes2", array(182), array('retour.champs' => 'titre,tome,page,famille'));
$retour = $this->consulterJson("textes2", "coste", array(182), array('retour.champs' => 'titre,tome,page,famille'));
$url = ServiceEflorePhpUnit::creerUrl(self::$S, array(182), array('retour.champs' => 'titre,tome,page,famille'));
$retour = $this->consulterJson(self::$S, self::$P, array(182), array('retour.champs' => 'titre,tome,page,famille'));
$this->assertEquals(1, count($retour['resultats']), "error: ['resultats']['182']. Voir : $url");
$this->assertArrayHasKey("num_nom", $retour['resultats']['182'], "error: ['resultats']['182'], clef num_nom. Voir : $url");
$this->assertArrayHasKey("titre", $retour['resultats']['182'], "error: ['resultats']['182'], clef titre. Voir : $url");
68,8 → 71,8
 
 
public function testRechercheNS() {
$url = ServiceEflorePhpUnit::creerUrl("textes2", NULL, array("masque.ns" => "Roemeria", "recherche" => "etendue"));
$retour = $this->consulterJson("textes2", "coste", NULL, array("masque.ns" => "Roemeria", "recherche" => "etendue"));
$url = ServiceEflorePhpUnit::creerUrl(self::$S, NULL, array("masque.ns" => "Roemeria", "recherche" => "etendue"));
$retour = $this->consulterJson(self::$S, self::$P, NULL, array("masque.ns" => "Roemeria", "recherche" => "etendue"));
$this->commonTestHeader($retour, $url);
$this->assertEquals(3, $retour['entete']['total'], "L'attribut 'total' devrait avoir la valeur 3. Voir : $url");
$this->commonTest($retour, $url);
77,25 → 80,25
 
 
public function testRechercheTXT() {
$url = ServiceEflorePhpUnit::creerUrl("textes2", NULL, array("masque.txt" => "Nancy"));
$retour = $this->consulterJson("textes2", "coste", NULL, array("masque.txt" => "Nancy"));
$url = ServiceEflorePhpUnit::creerUrl(self::$S, NULL, array("masque.txt" => "Nancy"));
$retour = $this->consulterJson(self::$S, self::$P, NULL, array("masque.txt" => "Nancy"));
$this->assertEquals(2, $retour['entete']['total'], "L'attribut 'total' devrait avoir la valeur 2. Voir : $url");
$this->assertArrayHasKey("1774", $retour['resultats'], "error: ['resultats']['1774']. Voir : $url");
$this->assertArrayHasKey("1775", $retour['resultats'], "error: ['resultats']['1775']. Voir : $url");
 
$url = ServiceEflorePhpUnit::creerUrl("textes2", NULL, array("masque.txt" => "Nancy", "recherche" => "floue"));
$retour = $this->consulterJson("textes2", "coste", NULL, array("masque.txt" => "Nancy", "recherche" => "floue"));
$url = ServiceEflorePhpUnit::creerUrl(self::$S, NULL, array("masque.txt" => "Nancy", "recherche" => "floue"));
$retour = $this->consulterJson(self::$S, self::$P, NULL, array("masque.txt" => "Nancy", "recherche" => "floue"));
$this->assertEquals(2, $retour['entete']['total'], "L'attribut 'total' devrait avoir la valeur 2. Voir : $url");
$this->assertArrayHasKey("1774", $retour['resultats'], "error: ['resultats']['1774']. Voir : $url");
$this->assertArrayHasKey("1775", $retour['resultats'], "error: ['resultats']['1775']. Voir : $url");
 
$url = ServiceEflorePhpUnit::creerUrl("textes2", NULL, array("masque.txt" => "Nancy", "masque.tome" => 2));
$retour = $this->consulterJson("textes2", "coste", NULL, array("masque.txt" => "Nancy", "masque.tome" => 2));
$url = ServiceEflorePhpUnit::creerUrl(self::$S, NULL, array("masque.txt" => "Nancy", "masque.tome" => 2));
$retour = $this->consulterJson(self::$S, self::$P, NULL, array("masque.txt" => "Nancy", "masque.tome" => 2));
$this->assertEquals(1, $retour['entete']['total'], "L'attribut 'total' devrait avoir la valeur 1. Voir : $url");
$this->assertArrayHasKey("1774", $retour['resultats'], "error: ['resultats']['1774']. Voir : $url");
 
$url = ServiceEflorePhpUnit::creerUrl("textes2", NULL, array("masque.txt" => "Nancy", "masque.page" => 0));
$retour = $this->consulterJson("textes2", "coste", NULL, array("masque.txt" => "Nancy", "masque.page" => 0));
$url = ServiceEflorePhpUnit::creerUrl(self::$S, NULL, array("masque.txt" => "Nancy", "masque.page" => 0));
$retour = $this->consulterJson(self::$S, self::$P, NULL, array("masque.txt" => "Nancy", "masque.page" => 0));
$this->assertEquals(1, $retour['entete']['total'], "L'attribut 'total' devrait avoir la valeur 1. Voir : $url");
$this->assertArrayHasKey("1775", $retour['resultats'], "error: ['resultats']['1775']. Voir : $url");
}
104,8 → 107,8
// par compatibilité, "titre" signifie une recherche sur "tag" (le titre de la page wiki de la description
// ou des clefs de détermination)
public function testRechercheTag() {
$url = ServiceEflorePhpUnit::creerUrl("textes2", NULL, array("masque.titre" => "Esp0131RoemeriaViolacea"));
$retour = $this->consulterJson("textes2", "coste", NULL, array("masque.titre" => "Esp0131RoemeriaViolacea"));
$url = ServiceEflorePhpUnit::creerUrl(self::$S, NULL, array("masque.titre" => "Esp0131RoemeriaViolacea"));
$retour = $this->consulterJson(self::$S, self::$P, NULL, array("masque.titre" => "Esp0131RoemeriaViolacea"));
$this->commonTestHeader($retour, $url);
$this->assertEquals(2, $retour['entete']['total'], "L'attribut 'total' devrait avoir la valeur 2. Voir : $url");
$this->commonTest($retour, $url);
115,25 → 118,25
 
public function testRechercheFamille() {
// unknown famille
$url = ServiceEflorePhpUnit::creerUrl("textes2", NULL, array("masque.famille" => "ABC"));
$retour = $this->consulterJson("textes2", "coste", NULL, array("masque.famille" => "ABC"));
$url = ServiceEflorePhpUnit::creerUrl(self::$S, NULL, array("masque.famille" => "ABC"));
$retour = $this->consulterJson(self::$S, self::$P, NULL, array("masque.famille" => "ABC"));
$this->assertEquals(0, $retour['entete']['total'], "L'attribut 'total' devrait avoir la valeur 0. Voir : $url");
 
// par famille, mais pas de recherche étendue pour ça
$url = ServiceEflorePhpUnit::creerUrl("textes2", NULL, array("masque.famille" => "Sapind"));
$retour = $this->consulterJson("textes2", "coste", NULL, array("masque.famille" => "Sapind"));
$url = ServiceEflorePhpUnit::creerUrl(self::$S, NULL, array("masque.famille" => "Sapind"));
$retour = $this->consulterJson(self::$S, self::$P, NULL, array("masque.famille" => "Sapind"));
$this->assertEquals(0, $retour['entete']['total'], "L'attribut 'total' devrait avoir la valeur 0. Voir : $url");
 
$url = ServiceEflorePhpUnit::creerUrl("textes2", array(182), array("masque.famille" => "Sapindaceae"));
$retour = $this->consulterJson("textes2", "coste", array(182), array("masque.famille" => "Sapindaceae"));
$url = ServiceEflorePhpUnit::creerUrl(self::$S, array(182), array("masque.famille" => "Sapindaceae"));
$retour = $this->consulterJson(self::$S, self::$P, array(182), array("masque.famille" => "Sapindaceae"));
$this->assertEquals(1, $retour['entete']['total'], "L'attribut 'total' devrait avoir la valeur 1. Voir : $url");
 
$url = ServiceEflorePhpUnit::creerUrl("textes2", array(182), array("masque.famille" => "Sapind%"));
$retour = $this->consulterJson("textes2", "coste", array(182), array("masque.famille" => "Sapind%"));
$url = ServiceEflorePhpUnit::creerUrl(self::$S, array(182), array("masque.famille" => "Sapind%"));
$retour = $this->consulterJson(self::$S, self::$P, array(182), array("masque.famille" => "Sapind%"));
$this->assertEquals(1, $retour['entete']['total'], "L'attribut 'total' devrait avoir la valeur 1. Voir : $url");
 
$url = ServiceEflorePhpUnit::creerUrl("textes2", array(182), array("masque.famille" => "S_pindaceae"));
$retour = $this->consulterJson("textes2", "coste", array(182), array("masque.famille" => "S_pindaceae"));
$url = ServiceEflorePhpUnit::creerUrl(self::$S, array(182), array("masque.famille" => "S_pindaceae"));
$retour = $this->consulterJson(self::$S, self::$P, array(182), array("masque.famille" => "S_pindaceae"));
$this->assertEquals(1, $retour['entete']['total'], "L'attribut 'total' devrait avoir la valeur 1. Voir : $url");
}