Browse code

Merge pull request #460 from geops/master

Sort repository list case insensitive

Klaus Silveira authored on 19/05/2014 14:13:38
Showing 2 changed files
... ...
@@ -28,7 +28,8 @@ class Client extends BaseClient
28 28
      * Searches for valid repositories on the specified path
29 29
      *
30 30
      * @param  array $paths Array of paths where repositories will be searched
31
-     * @return array Found repositories, containing their name, path and description
31
+     * @return array Found repositories, containing their name, path and description sorted
32
+     *               by repository name
32 33
      */
33 34
     public function getRepositories($paths)
34 35
     {
... ...
@@ -45,7 +46,9 @@ class Client extends BaseClient
45 45
         }
46 46
 
47 47
         $allRepositories = array_unique($allRepositories, SORT_REGULAR);
48
-        asort($allRepositories);
48
+        uksort($allRepositories, function($k1, $k2) {
49
+            return strtolower($k2)<strtolower($k1);
50
+        });
49 51
 
50 52
         return $allRepositories;
51 53
     }
... ...
@@ -137,22 +137,22 @@ class InterfaceTest extends WebTestCase
137 137
         $this->assertTrue($client->getResponse()->isOk());
138 138
         $this->assertCount(1, $crawler->filter('title:contains("GitList")'));
139 139
 
140
-        $this->assertCount(1, $crawler->filter('div.repository-header a:contains("GitTest")'));
141
-        $this->assertEquals('/GitTest/', $crawler->filter('.repository-header a')->eq(0)->attr('href'));
142
-        $this->assertEquals('/GitTest/master/rss/', $crawler->filter('.repository-header a')->eq(1)->attr('href'));
143
-
144 140
         $this->assertCount(1, $crawler->filter('div.repository-header a:contains("detached-head")'));
145
-        $this->assertEquals('/detached-head/', $crawler->filter('.repository-header a')->eq(2)->attr('href'));
146
-        $this->assertEquals('/detached-head/master/rss/', $crawler->filter('.repository-header a')->eq(3)->attr('href'));
141
+        $this->assertEquals('/detached-head/', $crawler->filter('.repository-header a')->eq(0)->attr('href'));
142
+        $this->assertEquals('/detached-head/master/rss/', $crawler->filter('.repository-header a')->eq(1)->attr('href'));
147 143
 
148 144
         $this->assertCount(1, $crawler->filter('div.repository-header a:contains("develop")'));
149
-        $this->assertEquals('/develop/', $crawler->filter('.repository-header a')->eq(4)->attr('href'));
150
-        $this->assertEquals('/develop/master/rss/', $crawler->filter('.repository-header a')->eq(5)->attr('href'));
145
+        $this->assertEquals('/develop/', $crawler->filter('.repository-header a')->eq(2)->attr('href'));
146
+        $this->assertEquals('/develop/master/rss/', $crawler->filter('.repository-header a')->eq(3)->attr('href'));
151 147
 
152 148
         $this->assertCount(1, $crawler->filter('div.repository-header:contains("foobar")'));
153 149
         $this->assertCount(1, $crawler->filter('div.repository-body:contains("This is a test repo!")'));
154
-        $this->assertEquals('/foobar/', $crawler->filter('.repository-header a')->eq(6)->attr('href'));
155
-        $this->assertEquals('/foobar/master/rss/', $crawler->filter('.repository-header a')->eq(7)->attr('href'));
150
+        $this->assertEquals('/foobar/', $crawler->filter('.repository-header a')->eq(4)->attr('href'));
151
+        $this->assertEquals('/foobar/master/rss/', $crawler->filter('.repository-header a')->eq(5)->attr('href'));
152
+
153
+        $this->assertCount(1, $crawler->filter('div.repository-header a:contains("GitTest")'));
154
+        $this->assertEquals('/GitTest/', $crawler->filter('.repository-header a')->eq(6)->attr('href'));
155
+        $this->assertEquals('/GitTest/master/rss/', $crawler->filter('.repository-header a')->eq(7)->attr('href'));
156 156
 
157 157
         $this->assertCount(1, $crawler->filter('div.repository-header a:contains("nested/NestedRepo")'));
158 158
         $this->assertEquals('/nested/NestedRepo/', $crawler->filter('.repository-header a')->eq(8)->attr('href'));