diff --git a/VERSIONS_HOTLINE/139527 b/VERSIONS_HOTLINE/139527 new file mode 100644 index 0000000000000000000000000000000000000000..211ef1261182ef7df1daed5ba28e1f3bc1fc9013 --- /dev/null +++ b/VERSIONS_HOTLINE/139527 @@ -0,0 +1 @@ + - 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 diff --git a/library/Class/Cosmogramme/Integration/PhaseSerialArticlesIndex.php b/library/Class/Cosmogramme/Integration/PhaseSerialArticlesIndex.php index 945f0fbed1d291b18924a90f4dcd52c072488def..17ce3171c26426cd84b23d04abbf4511a8f65031 100644 --- a/library/Class/Cosmogramme/Integration/PhaseSerialArticlesIndex.php +++ b/library/Class/Cosmogramme/Integration/PhaseSerialArticlesIndex.php @@ -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; } diff --git a/tests/library/Class/Cosmogramme/Integration/PhaseSerialArticlesIndexTest.php b/tests/library/Class/Cosmogramme/Integration/PhaseSerialArticlesIndexTest.php index 43915d993e0aa5f197778b79a907269ac86e26ad..3adf4dc675794217c4ec244e22625d31bdc8ccf6 100644 --- a/tests/library/Class/Cosmogramme/Integration/PhaseSerialArticlesIndexTest.php +++ b/tests/library/Class/Cosmogramme/Integration/PhaseSerialArticlesIndexTest.php @@ -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()); + } +}