diff --git a/VERSIONS_HOTLINE/39778 b/VERSIONS_HOTLINE/39778 new file mode 100644 index 0000000000000000000000000000000000000000..841a3e52b362043eeb3b63d4954c8db4bfae7a6d --- /dev/null +++ b/VERSIONS_HOTLINE/39778 @@ -0,0 +1 @@ + - ticket #39778 : Amélioration de l'ergonomie du sélecteur des thèmes préférés. Tous les domaines sont à plat et triés par ordre alphabétique. \ No newline at end of file diff --git a/library/Class/Catalogue.php b/library/Class/Catalogue.php index 954c5307ef3a6d621a32cede1a84c451d8faa06b..ad292dcf5cbd27964c4eb89ea6e59e331069989f 100644 --- a/library/Class/Catalogue.php +++ b/library/Class/Catalogue.php @@ -976,10 +976,15 @@ class Class_Catalogue extends Storm_Model_Abstract { $data_panier[]=$panier->toDataForJson(); } + return $this->toDataForJsonWithCategoriesItems($data_domaines, $data_panier, $options); + } + + + public function toDataForJsonWithCategoriesItems($categories, $items, $options = []) { return ['id' => $this->getId(), 'label' => htmlspecialchars($this->getLibelle()), - 'categories' => $data_domaines, - 'items' => $data_panier, + 'categories' => $categories, + 'items' => $items, 'options' => array_merge(['ico' => URL_ADMIN_IMG.'picto/domaines_16.png'],$options)]; } @@ -1219,10 +1224,19 @@ class Class_Catalogue extends Storm_Model_Abstract { public function getViewableDomainJson() { $domains = Class_Catalogue::getLoader()->findAllCataloguesAIndexer(); - $data_domains=[]; - foreach($domains as $domain) { - $data_domains [] = $domain->toDataForJsonWithoutPaniers([]); - } + usort($domains, + function($a, $b) + { + return $a->getLibelle() > $b->getLibelle(); + }); + + $data_domains = array_map( + function($d) { + $datas = $d->toDataForJsonWithCategoriesItems([], []); + $datas['label'] = implode(' / ', $d->getPathParts()); + return $datas; + }, + $domains); return $data = ['id' => 'domains', 'label' => $this->_('Domaines'), diff --git a/tests/application/modules/opac/controllers/AbonneControllerSettingsTest.php b/tests/application/modules/opac/controllers/AbonneControllerSettingsTest.php index 42aa2467818e83da91c130c18743fd14f999ce34..14e98e319f24d3deb68a8c2b24f117b47bc47c8b 100644 --- a/tests/application/modules/opac/controllers/AbonneControllerSettingsTest.php +++ b/tests/application/modules/opac/controllers/AbonneControllerSettingsTest.php @@ -44,7 +44,17 @@ abstract class AbonneControllerSettingsTestCase extends AbstractControllerTestCa $this->_cinema = $this->fixture('Class_Catalogue', ['id' => 3, - 'libelle' => 'Cinema']); + 'libelle' => 'Cinema', + 'sous_domaines' => [ $this->fixture('Class_Catalogue', + ['id' => 31, + 'libelle' => 'Muet', + 'indexer' => '1']), + + $this->fixture('Class_Catalogue', + ['id' => 32, + 'libelle' => 'Couleurs', + 'indexer' => '1']) + ]]); $this->_user->setBookmarkedDomains([3]); } @@ -67,7 +77,7 @@ class AbonneControllerSettingsFormTest extends AbonneControllerSettingsTestCase /** @test */ - public function userBookmarkedDomainShouldBeEmpty() { + public function userBookmarkedDomainShouldContainsCinema() { $this->assertEmpty($this->_user->getBookmarkedDomains()); } } @@ -94,12 +104,28 @@ class AbonneControllerSettingsFormPostTest extends AbonneControllerSettingsTestC class AbonneControllerViewableDomainTest extends AbonneControllerSettingsTestCase { public function setUp() { parent::setUp(); + Class_Catalogue::find(3)->setIndexer(1)->save(); $this->dispatch('opac/abonne/viewable-domains-json', true); } /** @test */ public function domainMusicShouldBePresent() { - $this->assertContains('[{"id":"domains","label":"Domaines","categories":[{"id":1,"label":"Music","categories":[],"items":[],"options":{"ico":', $this->_response->getBody()); + $icon = BASE_URL . '/public/admin/images/picto/domaines_16.png'; + $expected = [ + ['id' => 'domains', + 'label' => 'Domaines', + 'categories' => [ + ['id' => 3, 'label' => 'Cinema', 'categories' => [], 'items' => [], 'options' => ['ico' => $icon]], + ['id' => 32, 'label' => 'Cinema / Couleurs', 'categories' => [], 'items' => [], 'options' => ['ico' => $icon]], + ['id' => 31, 'label' => 'Cinema / Muet', 'categories' => [], 'items' => [], 'options' => ['ico' => $icon]], + ['id' => 1, 'label' => 'Music', 'categories' => [], 'items' => [], 'options' => ['ico' => $icon]], + ['id' => 2, 'label' => 'Sport', 'categories' => [], 'items' => [], 'options' => ['ico' => $icon]], + ], + 'items' => [], + 'options' => ['ico' => $icon, 'multipleSelection' => true ]]]; + + $this->assertJsonStringEqualsJsonString(json_encode($expected), + $this->_response->getBody()); } } \ No newline at end of file diff --git a/tests/library/ZendAfi/View/Helper/Accueil/SitoTest.php b/tests/library/ZendAfi/View/Helper/Accueil/SitoTest.php index 321c19024e33c3071ce620db3073101a23664a7a..98b871d51f87cc28092750ca783693e3eb82ac10 100644 --- a/tests/library/ZendAfi/View/Helper/Accueil/SitoTest.php +++ b/tests/library/ZendAfi/View/Helper/Accueil/SitoTest.php @@ -245,13 +245,14 @@ class SitoViewHelperSelectItemsByRandomOrderTest extends SitoViewHelperTestCase for($i=0; $i < 10; $i++) $htmls[] = $this->_helper->getBoite(); - $this->assertEquals(2, count(array_unique($htmls))); + $this->assertEquals(2, count(array_unique($htmls)), json_encode($htmls)); } /** @test */ public function pageShouldNotContainsLinkToReloadModule() { - $this->assertNotXPath($this->html, '//a[contains(@href, "sito/widget-page/id_module/2/id_division/1")]'); + $this->assertNotXPath($this->html, + '//a[contains(@href, "sito/widget-page/id_module/2/id_division/1")]'); } }