diff --git a/library/ZendAfi/Feed/SearchResult.php b/library/ZendAfi/Feed/SearchResult.php index 09ace5463187ada362d44b3e30a6bd3705eb0730..da316f9067c78656491c3623f7ca36b13fde4843 100644 --- a/library/ZendAfi/Feed/SearchResult.php +++ b/library/ZendAfi/Feed/SearchResult.php @@ -33,10 +33,12 @@ class ZendAfi_Feed_SearchResult implements Zend_Feed_Builder_Interface { public function getHeader() { - return new Zend_Feed_Builder_Header( + $header = new Zend_Feed_Builder_Header( $this->_('Recherche') . ': ' .$this->_search_result->getSearchTerms(), Class_Url::absolute($this->_search_result->getUrl())); - + $header->generator = 'Bokeh Portal Library'; + $header->author = Class_Profil::getPortail()->getLibelle(); + return $header; } @@ -49,7 +51,7 @@ class ZendAfi_Feed_SearchResult implements Zend_Feed_Builder_Interface { public function newEntry($record) { - $this->_entry = new Zend_Feed_Builder_Entry($record->getTitrePrincipal(' - '), + $this->_entry = new Zend_Feed_Builder_Entry($record->getTitrePrincipal(' - ') . ' (' . ucfirst($record->getTypeDocLabel()) . ')', Class_Url::absolute($this->_view->urlNotice($record)), null); $record->acceptVisitor($this); @@ -74,6 +76,11 @@ class ZendAfi_Feed_SearchResult implements Zend_Feed_Builder_Interface { if ($auteurs) $this->_entry->author = ['name' => $auteurs[0]]; } + + + public function visitDateMaj($date_maj) { + $this->_entry->lastUpdate = strtotime($date_maj); + } } ?> \ No newline at end of file diff --git a/tests/application/modules/opac/controllers/RechercheControllerAtomTest.php b/tests/application/modules/opac/controllers/RechercheControllerAtomTest.php index d24bc3e940d0a88b55db164fcb7b4d9a76f12a28..01de840812cdb4655b4ae471d25867719629abfc 100644 --- a/tests/application/modules/opac/controllers/RechercheControllerAtomTest.php +++ b/tests/application/modules/opac/controllers/RechercheControllerAtomTest.php @@ -32,6 +32,11 @@ abstract class RechercheControllerAtomTestCase extends AbstractControllerTestCas $this->_prepareSql($mock_sql); Zend_Registry::set('sql', $mock_sql); + Class_Profil::getPortail()->setLibelle('Réseau du coin')->save(); + + Class_CosmoVar::newInstanceWithId('types_docs', ['liste' => '']); + Class_TypeDoc::find(Class_TypeDoc::LIVRE)->setLabel('livre')->save(); + $this->dispatch($this->_searchUrl(), true); $this->_json = json_decode($this->_response->getBody()); $this->_xpath = new Storm_Test_XPathXML(); @@ -66,6 +71,7 @@ class RechercheControllerAtomWithTwoNoticesTestCase extends RechercheControllerA 'unimarc' => $this->_unimarcFrom('harry_potter_ecole_sorciers.txt'), 'annee' => '1998', 'resume' => 'Harry Potter il va tout dégommer', + 'date_maj' => '2015-03-22 12:34:02', 'url_vignette' => 'http://ecx.images-amazon.com/images/I/51KVZWGHASL._SL160_.jpg', 'url_image' => 'http://ecx.images-amazon.com/images/I/51KVZWGHASL.jpg']); @@ -76,6 +82,7 @@ class RechercheControllerAtomWithTwoNoticesTestCase extends RechercheControllerA 'type_doc' => 104, 'unimarc' => $this->_unimarcFrom('rdv_a_kiruna.txt'), 'annee' => '2012', + 'date_maj' => '2015-01-12 12:34:02', 'url_vignette' => BASE_URL .'/userfiles/album/154191/thumb_154191_e7bcedba-743a-11e2-a43d-fb3bf58b5f60.png', 'url_image' => 'http://media.universcine.com/e7/bc/e7bcedba-743a-11e2-a43d-fb3bf58b5f60.png']); @@ -117,6 +124,22 @@ class RechercheControllerAtomWithTwoNoticesTestCase extends RechercheControllerA } + /** @test */ + public function feedGeneratorShouldBeBokeh() { + $this->_xpath->assertXPathContentContains($this->_response->getBody(), + '//atom:feed/atom:generator', + 'Bokeh Portal Library'); + } + + + /** @test */ + public function feedAuthorShouldBeReseauDuCoin() { + $this->_xpath->assertXPathContentContains($this->_response->getBody(), + '//atom:feed/atom:author', + 'Réseau du coin'); + } + + /** @test */ public function feedSelfLinkShouldBeAbsoluteSearchUrl() { $url = Class_Url::absolute('/recherche/simple/expressionRecherche/Harry+Potter/tri/%2A/format/atom/page_size/5'); @@ -129,10 +152,17 @@ class RechercheControllerAtomWithTwoNoticesTestCase extends RechercheControllerA public function feedFirstEntryTitleShouldBeHarryPotter() { $this->_xpath->assertXPathContentContains($this->_response->getBody(), '//atom:entry/atom:title', - 'Harry Potter n° 1 - A l\'école des sorciers'); + 'Harry Potter n° 1 - A l\'école des sorciers (Livre)'); } + /** @test */ + public function feedFirstEntryUpdatedShouldBe2015_03_22() { + $this->_xpath->assertXPathContentContains($this->_response->getBody(), + '//atom:entry/atom:updated', + '2015-03-22T12:34:02+01:00'); + } + /** @test */ public function firstEntryContentShouldContainsThumbnail() { @@ -157,6 +187,14 @@ class RechercheControllerAtomWithTwoNoticesTestCase extends RechercheControllerA } + /** @test */ + public function firstEntryIdShouldBePermalink() { + $this->_xpath->assertXPathContentContains($this->_response->getBody(), + '//atom:entry/atom:id', + 'clef/HARRYPOTTERALECOLEDESSORCIERS--ROWLINGJ-1-GALLIMARDJEUNESSE-2011-1/id/234'); + } + + /** @test */ public function firstEntryAuthorShouldBeRowling() { $this->_xpath->assertXPathContentContains($this->_response->getBody(), @@ -169,7 +207,7 @@ class RechercheControllerAtomWithTwoNoticesTestCase extends RechercheControllerA public function feedSecondEntryShouldBeRendezVous() { $this->_xpath->assertXPathContentContains($this->_response->getBody(), '//atom:entry/atom:title', - 'Rendez-vous à Kiruna'); + 'Rendez-vous à Kiruna (Arte VOD)'); }