Skip to content
Snippets Groups Projects
Commit d8f2846d authored by Patrick Barroca's avatar Patrick Barroca :grin:
Browse files

hotline #128944 : fix record usage count using common search criteria mechanics

parent 9902de3d
Branches
Tags
2 merge requests!4044Hotline,!4043hotline #128944 : fix record usage count using common search criteria mechanics
Pipeline #13513 passed with stage
in 51 minutes and 37 seconds
- ticket #128944 : Autorités : Correction d'une erreur de comptage des usages dans les notices bibliographiques
\ No newline at end of file
......@@ -30,6 +30,19 @@ class Class_CriteresRecherche_AuthoritiesParam {
$_authorities,
$_params;
public static function newForAuthority($record) {
if (!$record)
return new static();
$name = static::NAME_PREFIX . '_dummy';
$mode_name = static::MODE_PREFIX . $name;
$params = [$name => $record->getId(),
$mode_name => Class_CriteresRecherche_AuthorityParam::HIERARCHY_NONE];
return new static($params);
}
public function __construct($params=[]) {
$this->_authorities = new Storm_Collection;
$this->_params = $params;
......@@ -306,4 +319,4 @@ class Class_CriteresRecherche_AuthorityParam_Hierarchical
$this->_collectRecursiveFacetsFrom($record, $facets);
});
}
}
\ No newline at end of file
}
......@@ -30,11 +30,8 @@ class ZendAfi_View_Helper_AuthoritySearch_RecordUsages extends ZendAfi_View_Help
protected function _renderUsage($record) {
if (!$facets = $record->getDynamicFacetValues())
return $this->_('Utilisé dans aucune notice');
$criterias = (new Class_CriteresRecherche())
->setParams(['multifacets' => implode('-', $facets)]);
$criterias = Class_CriteresRecherche_AuthoritiesParam::newForAuthority($record)
->injectInto(new Class_CriteresRecherche);
if (!$count = $this->_countByCriterias($criterias))
return $this->_('Utilisé dans aucune notice');
......
......@@ -33,7 +33,7 @@ abstract class AuthoritiesTestCase extends AbstractControllerTestCase {
'type_doc' => 'j',
'annee' => '2017',
'type' => Class_Notice::TYPE_AUTHORITY,
'facettes' => 'HMOTS HMOTS0001',
'facettes' => 'HMOTS HMOTS0001 HNRNR0002',
'unimarc' => file_get_contents(__DIR__ . '/developpement_local.mrc')]);
$this->fixture('Class_Exemplaire',
......@@ -420,7 +420,11 @@ class AuthoritiesNoticeAjaxControllerTest extends AuthoritiesTestCase {
Zend_Registry::set('sql',
$this->mock()
->whenCalled('fetchAll')->answers($records));
->whenCalled('fetchAll')
->with("select id_notice, facettes from notices Where (MATCH(facettes) AGAINST('+(HMOTS0001)' IN BOOLEAN MODE)) and type=1",
true, false)
->answers($records)
->beStrict());
$this->dispatch('/noticeajax/detail/id/1');
}
......@@ -465,7 +469,7 @@ class AuthoritiesNoticeAjaxControllerTest extends AuthoritiesTestCase {
/** @test */
public function usageLinkShouldBePresent() {
$this->assertXPathContentContains('//a[contains(@href, "HMOTS0001")]',
$this->assertXPathContentContains('//a[contains(@href, "HMOTS_1_0")]',
utf8_encode('Utilisé dans 22 notices'));
}
}
......
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