Skip to content
Snippets Groups Projects
Commit 8dcc9517 authored by Laurent's avatar Laurent
Browse files

dev #81899 search author by name

parent c8667d58
Branches
Tags
3 merge requests!3297WIP: Master,!2924Dev#81899 pairing fiche auteur,!2923Dev#81899 pairing fiche auteur
Pipeline #5568 canceled with stage
in 13 minutes and 14 seconds
'81899' =>
['Label' => $this->_('[Pairing] Fiche auteur'),
'Desc' => '',
'Image' => '',
['Label' => $this->_('Fiche auteur'),
'Desc' => $this->_('La fiche auteur permet de mettre en avant différents axes de découverte du fonds à partir d'un auteur'),
'Image' => 'http://wiki.bokeh-library-portal.org/images/thumb/f/f4/Author_page.png/502px-Author_page.png',
'Video' => '',
'Category' => '',
'Category' => $this->_('Recherche'),
'Right' => function($feature_description, $user) {return true;},
'Wiki' => '',
'Test' => '',
'Wiki' => 'http://wiki.bokeh-library-portal.org/index.php?title=Fiche_auteur',
'Test' => '/author/view/named/molière',
'Date' => '2018-11-19'],
\ No newline at end of file
......@@ -20,12 +20,14 @@
*/
class AuthorController extends ZendAfi_Controller_Action {
public function viewAction() {
public function viewAction() {
Class_ScriptLoader::getInstance()
->addOPACScript('author_sheet.js')
->addJQueryReady('$("div.author").authorSheet()');
$author = Class_CodifAuteur::find($this->_getParam('id'));
if (!$author = $this->_findAuthor())
throw new Zend_Controller_Action_Exception($this->view->_('Désolé, cette page n\'existe pas'), 404);
$search_result = $this->_findRecordsForAuthor($author);
$all_records = $this->_sortRecordsFrom($search_result,
$author->getFacetCode());
......@@ -41,6 +43,17 @@ class AuthorController extends ZendAfi_Controller_Action {
}
protected function _findAuthor() {
if ($id = (int)$this->_getParam('id'))
return Class_CodifAuteur::find($id);
if ($name = $this->_getParam('named'))
return Class_CodifAuteur::findWithFullName($name);
return null;
}
protected function _findRecordsForAuthor($author) {
$author_code = $author->getFacetCode();
......
......@@ -77,16 +77,8 @@ abstract class AuthorPageTestCase extends AbstractControllerTestCase {
[9, 'A2408 M6'],
[10, 'A2408 A3']]);
Zend_Registry::set('sql', $this->mock_sql);
}
}
class AuthorPageViewTest extends AuthorPageTestCase {
public function setUp() {
parent::setUp();
Class_CosmoVar::newInstanceWithId('url_services')->setValeur('http://cache.org');
Class_WebService_AllServices::setHttpClient($http_client = $this->mock());
......@@ -102,9 +94,16 @@ class AuthorPageViewTest extends AuthorPageTestCase {
'vignette' => 'http://images.fr/hugo_thumb.jpg',
'image' => 'http://images.fr/hugo_big.jpg']))
->beStrict();
}
}
class AuthorPageViewByIdTest extends AuthorPageTestCase {
public function setUp() {
parent::setUp();
$this->dispatch('/author/view/id/2408');
}
......@@ -220,6 +219,39 @@ class AuthorPageViewTest extends AuthorPageTestCase {
class AuthorPageViewByNameTest extends AuthorPageTestCase {
/** @test */
public function searchVictorHugoShouldShowVictorHugo() {
Storm_Test_ObjectWrapper::onLoaderOfModel('Class_CodifAuteur')
->whenCalled('findWithFullName')
->with('Victor Hugo')
->answers(Class_CodifAuteur::find(2408));
$this->dispatch('/author/view/named/Victor+Hugo');
$this->assertXPathContentContains('//h1', 'Victor Hugo', $this->_response->getBody());
}
/** @test */
public function searchUnknownShouldDisplay404() {
Storm_Test_ObjectWrapper::onLoaderOfModel('Class_CodifAuteur')
->whenCalled('findWithFullName')
->answers(null);
try {
$this->dispatch('/author/view/named/Unknown');
} catch(Zend_Controller_Action_Exception $e) {
$this->assertEquals(404, $e->getCode());
return;
}
$this->fail('should raise error 404 not found');
}
}
class AuthorPageViewRecordDetailTest extends AuthorPageTestCase {
public function setUp() {
parent::setUp();
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment