diff --git a/VERSIONS_HOTLINE/185491 b/VERSIONS_HOTLINE/185491 new file mode 100644 index 0000000000000000000000000000000000000000..37bb9e4af8b8d18ba402dedb568740f2dcc99d6f --- /dev/null +++ b/VERSIONS_HOTLINE/185491 @@ -0,0 +1 @@ + - correctif #185491 : Newsletter : Les sous-domaines sont maintenant sélectionnables pour les lettres d'information \ No newline at end of file diff --git a/library/Class/Catalogue/Loader.php b/library/Class/Catalogue/Loader.php index 13ecbe72ff98c9cb2b3ced68cab02fc6fc4ce96c..444eb1a7fff85b8534895309e42d3f54e4b205bd 100644 --- a/library/Class/Catalogue/Loader.php +++ b/library/Class/Catalogue/Loader.php @@ -65,8 +65,10 @@ class Class_Catalogue_Loader extends Storm_Model_Loader { public function findTopCatalogues() : array { - return Class_Catalogue::findAllBy(['where' => 'parent_id is null', - 'order' => 'libelle']); + return Class_Catalogue::query() + ->is_null('parent_id') + ->order('libelle') + ->fetchAll(); } @@ -326,7 +328,7 @@ class Class_Catalogue_Loader extends Storm_Model_Loader { $liste[$catalogue->getId()] = implode(' > ', $catalogue->getPathParts()); $sous_domaines = $catalogue->getSousDomaines(); foreach($sous_domaines as $sous_domaine) - $this->_addCataloguePathAndChildrenTo($sous_domaine, $liste); + $liste = $liste + $this->_addCataloguePathAndChildrenTo($sous_domaine, $liste); return $liste; } diff --git a/tests/application/modules/admin/controllers/CatalogueControllerTest.php b/tests/application/modules/admin/controllers/CatalogueControllerTest.php index 04ec6e4610e10fc68957acd9f34598798e3d6384..be87c646fc1054e478a09ce9c2dda7df817c8a5c 100644 --- a/tests/application/modules/admin/controllers/CatalogueControllerTest.php +++ b/tests/application/modules/admin/controllers/CatalogueControllerTest.php @@ -27,37 +27,53 @@ abstract class AdminCatalogueControllerTestCase extends AbstractControllerTestCa public function setUp() { parent::setUp(); - $this->bib_annecy = Class_Bib::newInstanceWithId(2, - ['libelle' => 'Annecy', - 'responsable' => 'Ludivine', - 'aff_zone' => '', - 'ville' => 'Annecy', - 'url_web' => 'http://www.annecy.fr', - 'mail' => 'jp@annecy.com', - 'telephone' => '04 50 51 32 12', - 'article_categories' => []]); - - $this->bib_cran = Class_Bib::newInstanceWithId(3, ['libelle' => 'Cran-Gévrier']); + $this->bib_annecy = $this->fixture(Class_Bib::class, + ['id' => 2, + 'libelle' => 'Annecy', + 'responsable' => 'Ludivine', + 'aff_zone' => '', + 'ville' => 'Annecy', + 'url_web' => 'http://www.annecy.fr', + 'mail' => 'jp@annecy.com', + 'telephone' => '04 50 51 32 12', + 'article_categories' => []]); + + $this->bib_cran = $this->fixture(Class_Bib::class, + ['id' => 3, + 'libelle' => 'Cran-Gévrier']); $this->onLoaderOfModel('Class_Bib') ->whenCalled('findAll') ->answers([$this->bib_annecy, $this->bib_cran]); - $panier_jeunesse_dupont = Class_PanierNotice::newInstanceWithId(3, - ['libelle' => 'selection jeunesse', - 'user' => Class_Users::newInstanceWithId(45, ['nom' => 'Dupont','date_maj' => '']), - 'catalogues' => []]); - - $duchamp = Class_Users::newInstanceWithId(98, ['nom' => 'Duchamp', 'date_maj' => '']); - $panier_adulte_duchamp = Class_PanierNotice::newInstanceWithId(8, - ['libelle' => 'selection adulte', - 'user' => $duchamp, - 'catalogues' => []]); - - $panier_senior_duchamp = Class_PanierNotice::newInstanceWithId(9, - ['libelle' => 'selection senior', - 'user' => $duchamp, - 'catalogues' => []]); + $panier_jeunesse_dupont = $this->fixture(Class_PanierNotice::class, + ['id' => 3, + 'libelle' => 'selection jeunesse', + 'user' => $this->fixture(Class_Users::class, + ['id' => 45, + 'nom' => 'Dupont', + 'login' => 'dupontdebois', + 'password' => 'quontraversait', + 'date_maj' => '']), + 'catalogues' => []]); + + $duchamp = $this->fixture(Class_Users::class, + ['id' => 98, + 'login' => 'pduchamp', + 'password' => 'aufonddujardin', + 'nom' => 'Duchamp', + 'date_maj' => '']); + $panier_adulte_duchamp = $this->fixture(Class_PanierNotice::class, + ['id' => 8, + 'libelle' => 'selection adulte', + 'user' => $duchamp, + 'catalogues' => []]); + + $panier_senior_duchamp = $this->fixture(Class_PanierNotice::class, + ['id' => 9, + 'libelle' => 'selection senior', + 'user' => $duchamp, + 'catalogues' => []]); $this->onLoaderOfModel('Class_PanierNotice') ->whenCalled('save')->answers(true) @@ -70,39 +86,51 @@ abstract class AdminCatalogueControllerTestCase extends AbstractControllerTestCa ->whenCalled('delete')->answers(true) ->whenCalled('save')->answers(true); - $this->_catalogue_adultes = Class_Catalogue::newInstanceWithId(6, - ['libelle' => 'Adultes', - 'description' => 'Mon catalogue', - 'oai_spec' => 'adultes', - 'type_doc' => '1;3;4;5', - 'annee_debut' => 2012, - 'annee_fin' => 2012, - 'annexe' => 0, - 'dewey' => 78308, - 'sous_domaines' => [], - 'bibliotheque' => 1, - 'paniers' => []]); - - $this->user_referent=Class_Users::newInstanceWithId(2,['login' => 'referent', - 'role_level' => ZendAfi_Acl_AdminControllerRoles::MODO_PORTAIL, - 'pseudo' => 'referent', - 'date_maj' => '']); - $histoire = Class_Catalogue::newInstanceWithId(100, - [ 'libelle' => 'Histoire', - 'sous_domaines' => [ - Class_Catalogue::newInstanceWithId(200, [ 'libelle' => 'Politique', - 'parent_id' => 100, - 'dewey' =>78308, - 'paniers' => [] - ]), - - Class_Catalogue::newInstanceWithId(300, [ 'libelle'=>'Moyen-age', - 'user' => $this->user_referent, - 'parent_id' => 100, - 'paniers' => [] ])], - - 'panier_notices' => [$panier_jeunesse_dupont, $panier_adulte_duchamp] - ]); + $this->_catalogue_adultes = $this->fixture(Class_Catalogue::class, + ['id' => 6, + 'parent_id' => null, + 'libelle' => 'Adultes', + 'description' => 'Mon catalogue', + 'oai_spec' => 'adultes', + 'type_doc' => '1;3;4;5', + 'annee_debut' => 2012, + 'annee_fin' => 2012, + 'annexe' => 0, + 'dewey' => 78308, + 'sous_domaines' => [], + 'bibliotheque' => 1, + 'paniers' => []]); + + $this->user_referent= $this->fixture(Class_Users::class, + ['id' => 2, + 'login' => 'referent', + 'role_level' => ZendAfi_Acl_AdminControllerRoles::MODO_PORTAIL, + 'password' => 'iamlegend', + 'pseudo' => 'referent', + 'date_maj' => '']); + + $histoire = $this->fixture(Class_Catalogue::class, + ['id' => 100, + 'libelle' => 'Histoire', + 'sous_domaines' => + [ + $this->fixture(Class_Catalogue::class, + ['id' => 200, + 'libelle' => 'Politique', + 'parent_id' => 100, + 'dewey' =>78308, + 'paniers' => [] + ]), + $this->fixture(Class_Catalogue::class, + ['id' => 300, + 'libelle'=>'Moyen-age', + 'user' => $this->user_referent, + 'parent_id' => 100, + 'paniers' => [] ]) + ], + + 'panier_notices' => [$panier_jeunesse_dupont, $panier_adulte_duchamp] + ]); $this->onLoaderOfModel('Class_Catalogue') ->whenCalled('updateNoticesWithFacette') diff --git a/tests/library/Class/CatalogueTest.php b/tests/library/Class/CatalogueTest.php index 7be782a4fb7aef5bd6808b686a0b2bb5371bf54a..89d88e093d86b30e5bf6da897c3857f2be380f64 100644 --- a/tests/library/Class/CatalogueTest.php +++ b/tests/library/Class/CatalogueTest.php @@ -534,14 +534,22 @@ class CatalogueParentTest extends ModelTestCase { public function setUp() { parent::setUp(); - $this->_histoire = Class_Catalogue::newInstanceWithId(100, [ 'libelle' => 'Histoire', - 'parent_id' => 0]); - $this->_jeux = Class_Catalogue::newInstanceWithId(600, [ 'libelle' => 'Jeux>', - 'parent_id' => 0]); - $this->_politique = Class_Catalogue::newInstanceWithId(200, [ 'libelle' => 'Politique', - 'parent_id' => 100]); - $this->_moyenage = Class_Catalogue::newInstanceWithId(300, [ 'libelle'=>'Moyen-age', - 'parent_id' => 100]); + $this->_histoire = $this->fixture(Class_Catalogue::class, + [ 'id' => 100, + 'libelle' => 'Histoire', + 'parent_id' => null]); + $this->_jeux = $this->fixture(Class_Catalogue::class, + [ 'id'=> 600, + 'libelle' => 'Jeux', + 'parent_id' => null]); + $this->_politique = $this->fixture(Class_Catalogue::class, + [ 'id'=> 200, + 'libelle' => 'Politique', + 'parent_id' => 100]); + $this->_moyenage = $this->fixture(Class_Catalogue::class, + ['id' => 300, + 'libelle'=>'Moyen-age', + 'parent_id' => 100]); Storm_Test_ObjectWrapper::onLoaderOfModel('Class_Catalogue') ->whenCalled('findAllBy') ->with(['role' => 'domaine_parent', @@ -614,6 +622,17 @@ class CatalogueParentTest extends ModelTestCase { public function cataloguePolitiquePathShouldBeSlashHistoireSlashPolitique() { $this->assertEquals('/Histoire/Politique', $this->_politique->getPath()); } + + + /** @see https://forge.afi-sa.net/issues/185491 */ + /** @test */ + public function getCatalogueForComboShouldContainsHistoirePolitique() { + $this->assertEquals([0 => '', + 100 => 'Histoire', + 200 => 'Histoire > Politique', + 300 => 'Histoire > Moyen-age', + 600 => 'Jeux'], Class_Catalogue::getCataloguesForCombo()); + } } diff --git a/tests/library/ZendAfi/View/Helper/Accueil/DomainBrowserTest.php b/tests/library/ZendAfi/View/Helper/Accueil/DomainBrowserTest.php index 0f434f62e92a76a11c24e91f8a2e006135466118..9066c7b0e2d3f291ded6240b302875483c58c9c4 100644 --- a/tests/library/ZendAfi/View/Helper/Accueil/DomainBrowserTest.php +++ b/tests/library/ZendAfi/View/Helper/Accueil/DomainBrowserTest.php @@ -38,25 +38,29 @@ abstract class ZendAfi_View_Helper_Accueil_DomainBrowserTestCase extends ViewHel Class_CodifThesaurus::beVolatile(); - $this->fixture('Class_Catalogue', + $this->fixture(Class_Catalogue::class, ['id' => 1, 'libelle' => 'Metal']); - $this->fixture('Class_Catalogue', + $this->fixture(Class_Catalogue::class, ['id' => 5, 'libelle' => 'Mes domaines', - 'sous_domaines' => [ - $this->fixture('Class_Catalogue', - ['id' => 2, - 'libelle' => 'Jazz', - 'sous_domaines' => [ - $this->fixture('Class_Catalogue', - ['id' => 21, - 'libelle' => 'BeBop', - 'url_img' => 'http://bokeh.org/images/dancing_man.gif']), - $this->fixture('Class_Catalogue', - ['id' => 22, - 'libelle' => 'Acid']) - ]])]]); + 'sous_domaines' => + [ + $this->fixture(Class_Catalogue::class, + ['id' => 2, + 'libelle' => 'Jazz', + 'sous_domaines' => + [ + $this->fixture(Class_Catalogue::class, + ['id' => 21, + 'libelle' => 'BeBop', + 'url_img' => 'http://bokeh.org/images/dancing_man.gif']), + $this->fixture(Class_Catalogue::class, + ['id' => 22, + 'libelle' => 'Acid']) + ] + ]) + ]]); } @@ -113,10 +117,10 @@ abstract class ZendAfi_View_Helper_Accueil_DomainBrowserViewThumbnailsTestCase e parent::setUp(); $this->helper = new ZendAfi_View_Helper_Accueil_DomainBrowser(9, [ - 'division' => 1, - 'type_module' => 'DOMAIN_BROWSER', - 'preferences' => [ - 'display_mode' => Class_Systeme_ModulesAppli::LISTE_FORMAT_VIGNETTES + 'division' => 1, + 'type_module' => 'DOMAIN_BROWSER', + 'preferences' => [ + 'display_mode' => Class_Systeme_ModulesAppli::LISTE_FORMAT_VIGNETTES ]]); $this->helper->setView(new ZendAfi_Controller_Action_Helper_View()); @@ -135,7 +139,7 @@ class ZendAfi_View_Helper_Accueil_DomainBrowserViewThumbnailsTest extends ZendAf /** @test */ public function linkForDomainJazzShouldBePresent() { - $this->assertXPath($this->_html, '//div[contains(@class,"domains")]//ul[@class="children"]//a[contains(@href, "/domains/browse/id/2/id_module/9")]', $this->_html); + $this->assertXPath($this->_html, '//div[contains(@class,"domains")]//ul[@class="children"]//a[contains(@href, "/domains/browse/id/5/id_module/9")]', $this->_html); } } @@ -217,4 +221,4 @@ class ZendAfi_View_Helper_Accueil_DomainBrowserBrowsingRootTest extends ZendAfi_ $this->assertNotXPath($this->_html,'//div[@class="breadcrumb_domains"]',$this->_html); } } -?> \ No newline at end of file +?> diff --git a/tests/scenarios/DomainsPerLibraries/DomainsPerLibrariesTest.php b/tests/scenarios/DomainsPerLibraries/DomainsPerLibrariesTest.php index 5c973f762d8a2ed35275cabbc1ab6e2aaaa7e07e..446c212830f6ba143973f40eb6cae6b269cbc3bb 100644 --- a/tests/scenarios/DomainsPerLibraries/DomainsPerLibrariesTest.php +++ b/tests/scenarios/DomainsPerLibraries/DomainsPerLibrariesTest.php @@ -737,14 +737,7 @@ class DomainsPerLibrariesCatalogueControllerJsonRendersTest extends DomainsPerLi 'label' => 'Domaines', 'categories' => [['id' => 'Alderaan', 'label' => 'Alderaan', - 'categories' => [[ - 'id' => 6, - 'label' => 'Alderaan characters', - 'categories' => [], - 'items' => [], - 'options' => $item_options], - - ['id' => 4, + 'categories' => [['id' => 4, 'label' => 'Alderaan places', 'categories' => [[ 'id' => 6, @@ -759,12 +752,6 @@ class DomainsPerLibrariesCatalogueControllerJsonRendersTest extends DomainsPerLi 'items' => [], 'options' => $item_options]], 'items' => [], - 'options' => $item_options], - - ['id' => 5, - 'label' => 'Alderaan towns', - 'categories' => [], - 'items' => [], 'options' => $item_options]], 'items' => [], 'options' => $library_options], @@ -786,12 +773,6 @@ class DomainsPerLibrariesCatalogueControllerJsonRendersTest extends DomainsPerLi 'label' => 'All places', 'categories' => [], 'items' => [], - 'options' => $item_options], - - ['id' => 3, - 'label' => 'Wookiees', - 'categories' => [], - 'items' => [], 'options' => $item_options]], 'items' => [], 'options' => $library_options], @@ -825,18 +806,13 @@ class DomainsPerLibrariesCatalogueControllerJsonRendersTest extends DomainsPerLi $this->dispatch('admin/catalogue/browsable-domains', true); $datas = json_decode($this->_response->getBody(), true); + $item_options = ['ico' => (Class_Url::baseUrl() . '/public/admin/images/picto/domaines_16.png'), 'multipleSelection' => false]; $this->assertEquals([['id' => 'Alderaan', 'label' => 'Alderaan', - 'categories' => [['id' => 6, - 'label' => 'Alderaan characters', - 'categories' => [], - 'items' => [], - 'options' => $item_options], - - ['id' => 4, + 'categories' => [['id' => 4, 'label' => 'Alderaan places', 'categories' => [], 'items' => [['id' => 6, @@ -846,12 +822,6 @@ class DomainsPerLibrariesCatalogueControllerJsonRendersTest extends DomainsPerLi ['id' => 5, 'label' => 'Alderaan towns', 'options' => $item_options]], - 'options' => $item_options], - - ['id' => 5, - 'label' => 'Alderaan towns', - 'categories' => [], - 'items' => [], 'options' => $item_options]], 'items' => [], 'options' => []], @@ -871,12 +841,6 @@ class DomainsPerLibrariesCatalogueControllerJsonRendersTest extends DomainsPerLi 'label' => 'All places', 'categories' => [], 'items' => [], - 'options' => $item_options], - - ['id' => 3, - 'label' => 'Wookiees', - 'categories' => [], - 'items' => [], 'options' => $item_options]], 'items' => [], 'options' => []],