Skip to content
Snippets Groups Projects
Commit 7d387a15 authored by Sebastien ANDRE's avatar Sebastien ANDRE
Browse files

Merge branch...

Merge branch 'hotline#139527_problemes_d_affichages_de_notre_espace_presses_sur_notre_site_internet_les_notices_sont_existantes_mais_n_apparaissent_pas__indexation_des_auteurs' into 'hotline'

hotline : #139527 : Serial article facets missing

See merge request !4221
parents be3d631c ba963e10
Branches
Tags
3 merge requests!4238Master,!4237Hotline,!4221hotline : #139527 : Serial article facets missing
Pipeline #14911 passed with stage
in 28 minutes and 34 seconds
- ticket #139527 : Cosmogramme : Lorsque une notice de fascicule et les notices de dépouillement liées sont intégrées, les facettes auteurs et matières de l'ensemble des notices sont conservées.
\ No newline at end of file
......@@ -187,13 +187,7 @@ class Class_Cosmogramme_Integration_PhaseSerialArticlesIndex
$this->_setSeen($issue);
return $facets
->select(function($facet)
{
return !in_array(substr($facet, 0, 1),
[Class_CodifAuteur::CODE_FACETTE,
Class_CodifMatiere::CODE_FACETTE]);
});
return $facets;
}
......
......@@ -95,13 +95,13 @@ class Class_Cosmogramme_Integration_PhaseSerialArticlesIndexTest
$this->onLoaderOfModel(Class_Notice_SerialArticles::class)
->whenCalled('findAllBy')
->willDo(function() use($xmen, $iron_man, $orphan)
{
if ($this->_called)
return [];
{
if ($this->_called)
return [];
$this->_called = true;
return [$xmen, $orphan, $iron_man];
});
$this->_called = true;
return [$xmen, $orphan, $iron_man];
});
$this->onLoaderOfModel(Class_CodifAuteur::class);
$this->_prepareAuthor(1, 'LEExSTAN')
......@@ -200,3 +200,283 @@ class Class_Cosmogramme_Integration_PhaseSerialArticlesIndexTest
$this->assertEquals('2021-05-06 17:51:45', $this->_issue->getDateMaj());
}
}
/* hotline : #139527 */
abstract class RecordPerioWithFacettesTestCase
extends Class_Cosmogramme_Integration_PhaseTestCase {
protected
$_record,
$_article,
$_author_id = 1,
$_subject_id = 1;
protected function _getPreviousPhase() {
return (new Class_Cosmogramme_Integration_Phase(2))->beCron();
}
protected function _prepareFixtures() {
Class_CosmoVar::setValueOf('unimarc_zone_titre', '200$a');
$this->_record = $this->fixture(Class_Notice::class,
['id' => 222,
'clef_chapeau' => 'FEMME ACTUELLE',
'tome_alpha' => '1919',
'matieres' => '',
'auteurs' => '',
'facettes' => '',
'titres' => 'FEMME FEM ACTUELLE AKTUEL 05 JUILLET JUI 2021 11 1919',
]);
$marc = (new Class_NoticeUnimarc_Fluent)
->zoneWithChildren('200', ['a' => '15 recettes avec 5 produits de saison']);
$this->_prepareCodifsForArticle($marc);
$this->_article = $this->fixture(Class_Notice_SerialArticles::class,
['id' => 222,
'clef_chapeau' => 'FEMME ACTUELLE',
'clef_numero' => '1919',
'unimarc' => $marc->render(),
'date_maj' => $this->_chrono->mainStartDate(),
]);
$this->onLoaderOfModel(Class_Notice_SerialArticles::class)
->whenCalled('findAllBy')
->willDo(function ()
{
Class_Notice_SerialArticles::whenCalled('findAllBy')->answers([]);
return [$this->_article];
});
$time_source = new TimeSourceForTest('2021-09-27 09:00:00');
Class_Cosmogramme_Integration_PhaseSerialArticlesIndex::setTimeSource($time_source);
}
protected function _prepareCodifsForArticle($marc) {
return $this;
}
protected function _prepareAuthor($first_name, $last_name, $marc = null) {
$formes = $last_name . 'x' . $first_name;
$author = $this->fixture(Class_CodifAuteur::class,
['id' => $this->_author_id++,
'formes' => $formes,
]);
$this->onLoaderOfModel(Class_CodifAuteur::class);
Class_CodifAuteur::whenCalled('findFirstBy')
->with(['where' => "MATCH(formes) AGAINST('" . $formes . "' IN BOOLEAN MODE)"])
->answers($author);
if ($marc)
$marc->zoneWithChildren('702', ['a' => $last_name, 'b' => $first_name]);
return $this;
}
protected function _prepareSubject($name, $marc = null) {
Class_CosmoVar::setValueOf('unimarc_zone_matiere', '600$a');
$this->fixture(Class_CodifMatiere::class,
['id' => $this->_subject_id++,
'libelle' => $name,
]);
if ($marc)
$marc->zoneWithChildren('600', ['a' => $name]);
return $this;
}
public function setUp() {
parent::setUp();
$this->_phase = $this->_buildPhase('SerialArticlesIndex')
->setMemoryCleaner(function () {})
->setPrinter($this->_printer)
->run();
}
}
/* Record have one author and subject, Article nothing */
class PhaseSerialArticlesIndexRecordPerioWithFacetsArticleWhitoutFacetsTest
extends RecordPerioWithFacettesTestCase {
protected function _prepareFixtures() {
parent::_prepareFixtures();
$this->_record
->setMatieres('REVUE REVU')
->setAuteurs('DESSAUVAGES DESOVAJ JULIEN JULIN')
->setFacettes('A1 M1')
->assertSave();
return $this;
}
protected function _prepareCodifsForArticle($marc) {
$this->_prepareAuthor('JULIEN', 'DESSAUVAGES')
->_prepareSubject('REVUE');
return $this;
}
/** @test */
public function recordFacetsShouldContainsAuthorsA1andMatieresM1() {
$this->assertEquals('A1 M1', $this->_record->getFacettes());
}
/** @test */
public function recordMatieresShouldContainsSubjectsTerms() {
$this->assertEquals('REVUE REVU', $this->_record->getMatieres());
}
/** @test */
public function recordAuteursShouldContainsAuthorsTerms() {
$this->assertEquals('DESSAUVAGES DESOVAJ JULIEN JULIN',
$this->_record->getAuteurs());
}
}
/* Record have nothing, Article have one author and subject */
class PhaseSerialArticlesIndexRecordPerioWithoutFacetsArticleWithtFacetsTest
extends RecordPerioWithFacettesTestCase {
protected function _prepareCodifsForArticle($marc) {
$this->_prepareAuthor('JULIEN', 'DESSAUVAGES', $marc)
->_prepareSubject('REVUE', $marc);
return $this;
}
/** @test */
public function recordFacetsShouldContainsAuthorsA1andMatieresM1() {
$this->assertEquals('A1 M1', $this->_record->getFacettes());
}
/** @test */
public function recordMatieresShouldContainsSubjectsTerms() {
$this->assertEquals('REVUE REVU', $this->_record->getMatieres());
}
/** @test */
public function recordAuteursShouldContainsAuthorsTerms() {
$this->assertEquals('DESSAUVAGES DESOVAJ JULIEN JULIN',
$this->_record->getAuteurs());
}
}
/* Record have one author and subject, Article has the same author and subject */
class PhaseSerialArticlesIndexRecordPerioAndArticleHaveSameFacetsTest
extends RecordPerioWithFacettesTestCase {
protected function _prepareFixtures() {
parent::_prepareFixtures();
$this->_record
->setMatieres('REVUE REVU')
->setAuteurs('DESSAUVAGES DESOVAJ JULIEN JULIN')
->setFacettes('A1 M1')
->assertSave();
return $this;
}
protected function _prepareCodifsForArticle($marc) {
$this->_prepareAuthor('JULIEN', 'DESSAUVAGES', $marc)
->_prepareSubject('REVUE', $marc);
return $this;
}
/** @test */
public function recordFacetsShouldContainsAuthorsA1andMatieresM1() {
$this->assertEquals('A1 M1', $this->_record->getFacettes());
}
/** @test */
public function recordMatieresShouldContainsSubjectsTerms() {
$this->assertEquals('REVUE REVU', $this->_record->getMatieres());
}
/** @test */
public function recordAuteursShouldContainsAuthorsTerms() {
$this->assertEquals('DESSAUVAGES DESOVAJ JULIEN JULIN',
$this->_record->getAuteurs());
}
}
/* Record have one author and subject, Article have different author and subject */
class PhaseSerialArticlesIndexRecordPerioAndArticleHaveDifferentFacetsTest
extends RecordPerioWithFacettesTestCase {
protected function _prepareFixtures() {
parent::_prepareFixtures();
$this->_record
->setMatieres('REVUE REVU')
->setAuteurs('DESSAUVAGES DESOVAJ JULIEN JULIN')
->setFacettes('A1 M1')
->assertSave();
return $this;
}
protected function _prepareCodifsForArticle($marc) {
$this->_prepareAuthor('JULIEN', 'DESSAUVAGES')
->_prepareSubject('REVUE')
->_prepareAuthor('JAMIE', 'OLIVER', $marc)
->_prepareSubject('CUISINE', $marc);
return $this;
}
/** @test */
public function recordFacetsShouldContainsAuthorsA1_A2andMatieresM1_M2() {
$this->assertEquals('A1 A2 M1 M2', $this->_record->getFacettes());
}
/** @test */
public function recordMatieresShouldContainsSubjectsTerms() {
$this->assertEquals('CUISINE KUISIN REVUE REVU', $this->_record->getMatieres());
}
/** @test */
public function recordAuteursShouldContainsAuthorsTerms() {
$this->assertEquals('OLIVER OLIV JAMIE JAMI DESSAUVAGES DESOVAJ JULIEN JULIN',
$this->_record->getAuteurs());
}
}
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