diff --git a/VERSIONS_HOTLINE/43916 b/VERSIONS_HOTLINE/43916 new file mode 100644 index 0000000000000000000000000000000000000000..94c8b634bdd5b1f503e7cc9e8063592a9163afe0 --- /dev/null +++ b/VERSIONS_HOTLINE/43916 @@ -0,0 +1 @@ + - ticket #43916 : Recherche : tri par ordre alphabétique des favoris. \ No newline at end of file diff --git a/library/Class/MoteurRecherche/Facettes.php b/library/Class/MoteurRecherche/Facettes.php index 63bd29bcda2772df9eefb3201636c1b0b0fb06c3..14e79f6099515e95a71a37b962592a63cd483267 100644 --- a/library/Class/MoteurRecherche/Facettes.php +++ b/library/Class/MoteurRecherche/Facettes.php @@ -179,7 +179,11 @@ class Class_MoteurRecherche_Facettes { $codification = Class_Codification::getInstance(); $matches = []; - $user_bookmarks_codes = array_map(function($model) {return $model->getFacet();}, $user_bookmarks); + $user_bookmarks_codes = array_map(function($model) + { + return $model->getFacet(); + }, + $user_bookmarks); foreach($user_bookmarks_codes as $bookmark_code) { if(!isset($codes_count[$bookmark_code])) @@ -192,9 +196,13 @@ class Class_MoteurRecherche_Facettes { continue; $matches[] = ['id' => $bookmark_code, - 'label' => $facet->getCodeRubriqueLibelle() . ' : ' . $facet_label . ' (' . $codes_count[$bookmark_code] . ')']; + 'label' => sprintf('%s : %s (%d)', + $facet->getCodeRubriqueLibelle(), + $facet_label, + $codes_count[$bookmark_code])]; } + sort($matches, SORT_REGULAR); return $matches; } diff --git a/library/Class/Users.php b/library/Class/Users.php index 14a01ab2ed380ba75eb0ccbc7fc9bd332bded19c..23a0f7a453e95feed9a3e7edd499dfb53271983e 100644 --- a/library/Class/Users.php +++ b/library/Class/Users.php @@ -1720,7 +1720,8 @@ class Class_Users extends Storm_Model_Abstract { public function getBookmarks() { - return array_filter(array_merge($this->getBookmarkedDomains(), $this->getBookmarkedLibraries())); + return array_filter(array_merge($this->getBookmarkedDomains(), + $this->getBookmarkedLibraries())); } diff --git a/tests/library/Class/MoteurRecherche/MoteurRechercheFacettesTest.php b/tests/library/Class/MoteurRecherche/MoteurRechercheFacettesTest.php index 92a075150d03585615837981ba52388dde0d0ac8..ebf3ae25e7ae83e07b7415ffc9c1cbf4735ba4c1 100644 --- a/tests/library/Class/MoteurRecherche/MoteurRechercheFacettesTest.php +++ b/tests/library/Class/MoteurRecherche/MoteurRechercheFacettesTest.php @@ -203,27 +203,27 @@ class MoteurRechercheFacettesTest extends ModelTestCase { /** @test */ public function bookmarksShouldContainsDomainGamesFacet() { - $this->assertEquals(['id' => 'HCCCC0001', - 'label' => 'Domaines : Games (1)'], - $this->facettes['bookmarks'][0]); + $this->assertContains(['id' => 'HCCCC0001', + 'label' => 'Domaines : Games (1)'], + $this->facettes['bookmarks']); } /** @test */ public function bookmarksShouldContainsLibCran() { - $this->assertEquals(['id' => 'B3', - 'label' => 'Bibliothèque : Cran (1)'], - $this->facettes['bookmarks'][1]); + $this->assertContains(['id' => 'B3', + 'label' => 'Bibliothèque : Cran (1)'], + $this->facettes['bookmarks']); } /** @test */ public function bookmarksWithEmptySearchShouldNotBeEmpty() { $this->setupSearch(''); - $this->assertEquals([['id' => 'HCCCC0001', - 'label' => 'Domaines : Games (1)'], - ['id' => 'B3', - 'label' => 'Bibliothèque : Cran (1)']], $this->facettes['bookmarks']); + $this->assertEquals([['id' => 'B3', + 'label' => 'Bibliothèque : Cran (1)'], + ['id' => 'HCCCC0001', + 'label' => 'Domaines : Games (1)']], $this->facettes['bookmarks']); }