From 8f97eabbb8b373c62acf3ce5b79eb05ab6b856da Mon Sep 17 00:00:00 2001
From: gloas <gloas@afi-sa.fr>
Date: Mon, 4 Sep 2017 11:23:25 +0200
Subject: [PATCH] hotline #64150 fix libraries order in support

---
 VERSIONS_HOTLINE/64150                                      | 2 ++
 library/Class/Bib.php                                       | 4 ++--
 library/Class/Users.php                                     | 2 +-
 .../modules/admin/controllers/RedmineControllerTest.php     | 6 ++----
 4 files changed, 7 insertions(+), 7 deletions(-)
 create mode 100644 VERSIONS_HOTLINE/64150

diff --git a/VERSIONS_HOTLINE/64150 b/VERSIONS_HOTLINE/64150
new file mode 100644
index 00000000000..888937ab847
--- /dev/null
+++ b/VERSIONS_HOTLINE/64150
@@ -0,0 +1,2 @@
+ - ticket #64150 : Administration : Dans l'assistance, les bibliothèques sélectionnables sont triées par ordre alphabétique.
+ 
\ No newline at end of file
diff --git a/library/Class/Bib.php b/library/Class/Bib.php
index ef6747d99b1..e59d9aaeaf5 100644
--- a/library/Class/Bib.php
+++ b/library/Class/Bib.php
@@ -146,9 +146,9 @@ class BibLoader extends Storm_Model_Loader {
 
   public function byIdLabels($librairies) {
     $labels = [];
-    foreach ($librairies as $library) {
+    foreach ($librairies as $library)
       $labels[$library->getId()] = $library->getLibelle();
-    }
+
     return $labels;
   }
 
diff --git a/library/Class/Users.php b/library/Class/Users.php
index 821852579cd..c5c17052a52 100644
--- a/library/Class/Users.php
+++ b/library/Class/Users.php
@@ -1810,7 +1810,7 @@ class Class_Users extends Storm_Model_Abstract {
 
   public function getRedmineLibraries() {
     if($this->getRoleLevel() >= ZendAfi_Acl_AdminControllerRoles::MODO_PORTAIL)
-      return Class_Bib::findAll();
+      return Class_Bib::findAllBy(['order' => 'libelle']);
 
     return [$this->getRedmineLibrary()];
   }
diff --git a/tests/application/modules/admin/controllers/RedmineControllerTest.php b/tests/application/modules/admin/controllers/RedmineControllerTest.php
index fcfdb19b818..2be95ef46d1 100644
--- a/tests/application/modules/admin/controllers/RedmineControllerTest.php
+++ b/tests/application/modules/admin/controllers/RedmineControllerTest.php
@@ -404,15 +404,13 @@ class Admin_RedmineControllerWithMultipleAccountTest extends Admin_RedmineContro
   /** @test */
   public function annecyShouldBeSelected() {
     $this->assertXPathContentContains('//select[@name="library"]//option[@selected="selected"]',
-                                      'Mediatheque d\'Annecy',
-                                      $this->_response->getBody());
+                                      'Mediatheque d\'Annecy');
   }
 
 
   /** @test */
   public function chamberyShouldBeSelectable() {
-    $this->assertXPathContentContains('//select[@name="library"]//option', 'Mediatheque de Chambéry',
-                                      $this->_response->getBody());
+    $this->assertXPathContentContains('//select[@name="library"]//option[2]', 'Mediatheque de Chambéry');
   }
 
 
-- 
GitLab