From 90d1bb93e4b7e1c9ad79ffc4e12ff03f6015d465 Mon Sep 17 00:00:00 2001
From: llaffont <llaffont@afi-sa.fr>
Date: Thu, 30 Jul 2015 10:50:16 +0200
Subject: [PATCH] dev #22209 search result feed

better feed tite
---
 library/ZendAfi/Feed/SearchResultHeader.php   | 23 +++----
 .../RechercheControllerAtomTest.php           | 67 +++++++++++--------
 2 files changed, 48 insertions(+), 42 deletions(-)

diff --git a/library/ZendAfi/Feed/SearchResultHeader.php b/library/ZendAfi/Feed/SearchResultHeader.php
index dea6d65d8e3..d37474284e0 100644
--- a/library/ZendAfi/Feed/SearchResultHeader.php
+++ b/library/ZendAfi/Feed/SearchResultHeader.php
@@ -98,21 +98,19 @@ class ZendAfi_Feed_SearchResultHeader {
 
 
   public function visitSearchResult($search_result) {
-    $this->_description = $this->_plural($search_result->getRecordsCount(),
-                                         "Aucun résultat trouvé",
-                                         "Il y a %d résultat",
-                                         "Il y a %d résultats",
-                                         $search_result->getRecordsCount());
+    $this->_header->description = $this->_plural($search_result->getRecordsCount(),
+                                                 "Aucun résultat trouvé",
+                                                 "Il y a %d résultat",
+                                                 "Il y a %d résultats",
+                                                 $search_result->getRecordsCount());
 
     $search_result->acceptCriteresVisitor($this);
-    $this->_header->description = $this->_description
-      . '. '
-      . implode('. ', $this->_criterias);
+    $this->_header->title = $this->_('Recherche: ').implode('. ', $this->_criterias);
   }
 
 
   public function setErreur($error) {
-    $this->addCriteria($this->_('Erreur'), $error);
+    $this->_header->description .= $this->_('Erreur') . ': ' . $error;
   }
 
 
@@ -122,8 +120,7 @@ class ZendAfi_Feed_SearchResultHeader {
 
 
   public function visitExpression($expression) {
-    $this->_description .= ' ' . $this->_('pour: ') . $expression;
-    $this->_header->title = $this->_('Recherche') . ': ' . $expression;
+    $this->addCriteria($this->_('Expression'), $expression);
   }
 
 
@@ -142,12 +139,12 @@ class ZendAfi_Feed_SearchResultHeader {
 
 
   public function visitCatalogue($catalogue) {
-    $this->_description .= ' ' . $this->_('pour le catalogue: ') . $catalogue->getLibelle();
+    $this->addCriteria($this->_('Domaine'), $catalogue->getLibelle());
   }
 
 
   public function visitPanier($panier) {
-    $this->_description .= ' ' . $this->_('pour le panier: ') . $panier->getLibelle();
+    $this->addCriteria($this->_('Panier'), $panier->getLibelle());
   }
 
 
diff --git a/tests/application/modules/opac/controllers/RechercheControllerAtomTest.php b/tests/application/modules/opac/controllers/RechercheControllerAtomTest.php
index fa9a0d9d5a3..0bac0d26fc4 100644
--- a/tests/application/modules/opac/controllers/RechercheControllerAtomTest.php
+++ b/tests/application/modules/opac/controllers/RechercheControllerAtomTest.php
@@ -179,7 +179,7 @@ class RechercheControllerAtomWithTwoNoticesTest extends RechercheControllerAtomW
   public function feedTitleShouldBeRechercheHarryPotter() {
     $this->_xpath->assertXPathContentContains($this->_response->getBody(),
                                               '//atom:feed/atom:title',
-                                              'Recherche: Harry Potter');
+                                              'Recherche: Expression: Harry Potter');
   }
 
 
@@ -200,17 +200,17 @@ class RechercheControllerAtomWithTwoNoticesTest extends RechercheControllerAtomW
 
 
   /** @test */
-  public function feedSummaryShouldContainsTwoResults() {
+  public function feedSubtitleShouldContainsTwoResults() {
     $this->_xpath->assertXPathContentContains($this->_response->getBody(),
                                               '//atom:feed/atom:subtitle',
-                                              "Il y a 2 résultats pour: Harry Potter");
+                                              "Il y a 2 résultats");
   }
 
 
   /** @test */
-  public function feedSummaryShouldContainsCriteres() {
+  public function feedTitleShouldContainsCriteres() {
     $this->_xpath->assertXPathContentContains($this->_response->getBody(),
-                                              '//atom:feed/atom:subtitle',
+                                              '//atom:feed/atom:title',
                                               "Section: Adulte. Genre: Science-Fiction");
   }
 
@@ -248,7 +248,7 @@ class RechercheControllerAtomWithTwoNoticesTest extends RechercheControllerAtomW
 
 
   /** @test */
-  public function firstEntryContentShouldContainsSummary() {
+  public function firstEntryContentShouldContainsSubtitle() {
     $this->_xpath->assertXPathContentContains($this->_response->getBody(),
                                               '//atom:entry/atom:content',
                                               'Harry Potter il va tout dégommer');
@@ -287,9 +287,9 @@ class RechercheControllerAtomWithTwoNoticesTest extends RechercheControllerAtomW
 
 
   /** @test */
-  public function entrySummaryShouldNotBePresent() {
+  public function entrySubtitleShouldNotBePresent() {
     $this->_xpath->assertNotXPath($this->_response->getBody(),
-                                  '//atom:entry/atom:summary');
+                                  '//atom:entry/atom:subtitle');
   }
 }
 
@@ -307,7 +307,7 @@ class RechercheControllerAtomWithErrorTest extends RechercheControllerAtomWithTw
 
 
   /** @test */
-  public function feedSummaryShouldContainsSelectionWithoutNotices() {
+  public function feedSubtitleShouldContainsSelectionWithoutNotices() {
     $this->_xpath->assertXPathContentContains($this->_response->getBody(),
                                               '//atom:feed/atom:subtitle',
                                               'La sélection ne contient aucune notice');
@@ -343,10 +343,10 @@ class RechercheControllerAtomOnDomainTest extends RechercheControllerAtomWithTwo
 
 
   /** @test */
-  public function feedSummaryShouldContainsCatalogue() {
+  public function feedTitleShouldContainsDomaine() {
     $this->_xpath->assertXPathContentContains($this->_response->getBody(),
-                                              '//atom:feed/atom:subtitle',
-                                              "Il y a 2 résultats pour le catalogue: mangas");
+                                              '//atom:feed/atom:title',
+                                              "Domaine: mangas");
 
   }
 }
@@ -369,26 +369,26 @@ class RechercheControllerAtomOnPanierTypeDocNouveauteTest extends RechercheContr
 
 
   /** @test */
-  public function feedSummaryShouldContainsPanierMangas() {
+  public function feedTitleShouldContainsPanierMangas() {
     $this->_xpath->assertXPathContentContains($this->_response->getBody(),
-                                              '//atom:feed/atom:subtitle',
-                                              "Il y a 2 résultats pour le panier: mangas");
+                                              '//atom:feed/atom:title',
+                                              "Panier: mangas");
 
   }
 
 
   /** @test */
-  public function feedSummaryShouldContainsTypeDoc() {
+  public function feedTitleShouldContainsTypeDoc() {
     $this->_xpath->assertXPathContentContains($this->_response->getBody(),
-                                              '//atom:feed/atom:subtitle',
+                                              '//atom:feed/atom:title',
                                               "Type de document: livre");
   }
 
 
   /** @test */
-  public function feedSummaryShouldContainsNouveaute() {
+  public function feedTitleShouldContainsNouveaute() {
     $this->_xpath->assertXPathContentContains($this->_response->getBody(),
-                                              '//atom:feed/atom:subtitle',
+                                              '//atom:feed/atom:title',
                                               "Nouveautés de moins de: 3 mois");
   }
 }
@@ -401,9 +401,9 @@ class RechercheControllerAtomWithSerieTest extends RechercheControllerAtomWithTw
   }
 
   /** @test */
-  public function feedSummaryShouldContainsSerie() {
+  public function feedTitleShouldContainsSerie() {
     $this->_xpath->assertXPathContentContains($this->_response->getBody(),
-                                              '//atom:feed/atom:subtitle',
+                                              '//atom:feed/atom:title',
                                               'Série: Harry Potter');
   }
 }
@@ -427,9 +427,9 @@ class RechercheControllerAtomWithRubricTest extends RechercheControllerAtomWithT
   }
 
   /** @test */
-  public function feedSummaryShouldContainsRubriqueMangas() {
+  public function feedTitleShouldContainsRubriqueMangas() {
     $this->_xpath->assertXPathContentContains($this->_response->getBody(),
-                                              '//atom:feed/atom:subtitle',
+                                              '//atom:feed/atom:title',
                                               'Rubrique: mangas');
   }
 }
@@ -442,9 +442,9 @@ class RechercheControllerAtomWithCodeRebondTest extends RechercheControllerAtomW
   }
 
   /** @test */
-  public function feedSummaryShouldContainsRechercheElargie() {
+  public function feedTitleShouldContainsRechercheElargie() {
     $this->_xpath->assertXPathContentContains($this->_response->getBody(),
-                                              '//atom:feed/atom:subtitle',
+                                              '//atom:feed/atom:title',
                                               'Recherche élargie à: Science-Fiction');
   }
 }
@@ -458,18 +458,27 @@ class RechercheControllerAtomWithAdvancedSearchTest extends RechercheControllerA
 
 
   /** @test */
-  public function feedSummaryShouldContainsRechercheTitresOrAuteur() {
+  public function feedTitleShouldContainsRechercheTitresOrAuteur() {
     $this->_xpath->assertXPathContentContains($this->_response->getBody(),
-                                              '//atom:feed/atom:subtitle',
+                                              '//atom:feed/atom:title',
                                               'Et titre: potter. Ou auteur: rowling');
   }
 
 
   /** @test */
-  public function feedSummaryShouldContainsAnnexeAnnecy() {
+  public function feedTitleShouldContainsAnnexeAnnecy() {
     $this->_xpath->assertXPathContentContains($this->_response->getBody(),
-                                              '//atom:feed/atom:subtitle',
+                                              '//atom:feed/atom:title',
                                               'Annexe: Annecy');
   }
+
+
+  /** @test */
+  public function feedTitleShouldBeRendezVous() {
+    $this->_xpath->assertXPathContentContains($this->_response->getBody(),
+                                              '//atom:feed/atom:title',
+                                              'Recherche: Et titre: potter');
+  }
+
 }
 ?>
\ No newline at end of file
-- 
GitLab